From 52a98118550e2d4024b8c50538a0f6a968938ef8 Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Sat, 25 Nov 2023 19:08:53 -0800 Subject: [PATCH] roi: ensuring regions file is a regular file because otherwise we might not be able to read it multiple times to verify its contents; this can be improved later and the restrition removed --- src/analysis/roimethstat.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/analysis/roimethstat.cpp b/src/analysis/roimethstat.cpp index 08357ed9..ee2e8569 100644 --- a/src/analysis/roimethstat.cpp +++ b/src/analysis/roimethstat.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "GenomicRegion.hpp" #include "LevelsCounter.hpp" @@ -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() || @@ -299,6 +302,7 @@ get_bed_columns(const string ®ions_file) { return n_columns; } + int main_roimethstat(int argc, const char **argv) { try { @@ -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)