Skip to content

Commit

Permalink
roi: ensuring regions file is a regular file because otherwise we mig…
Browse files Browse the repository at this point in the history
…ht not be able to read it multiple times to verify its contents; this can be improved later and the restrition removed
  • Loading branch information
andrewdavidsmith committed Nov 26, 2023
1 parent cd4003a commit 52a9811
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/analysis/roimethstat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <unordered_map>
#include <utility>
#include <vector>
#include <filesystem>

#include "GenomicRegion.hpp"
#include "LevelsCounter.hpp"
Expand All @@ -49,6 +50,8 @@ using std::vector;

using bamxx::bgzf_file;

namespace fs = std::filesystem;

bool
cmp_within_chrom(const GenomicRegion &r1, const GenomicRegion &r2) {
return (r1.get_start() < r2.get_start() ||
Expand Down Expand Up @@ -299,6 +302,7 @@ get_bed_columns(const string &regions_file) {
return n_columns;
}


int
main_roimethstat(int argc, const char **argv) {
try {
Expand Down Expand Up @@ -391,6 +395,10 @@ Columns (beyond the first 6) in the BED format output:

if (VERBOSE) cerr << "loading regions" << endl;

if (!fs::is_regular_file(regions_file))
// otherwise we could not read the file twice
throw runtime_error("regions file must be regular file");

// MAGIC: below allow for ==3 or >=6 columns in the bed format
const auto n_columns = get_bed_columns(regions_file);
if (n_columns != 3 && n_columns < 6)
Expand Down

0 comments on commit 52a9811

Please sign in to comment.