File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -159,11 +159,23 @@ regions_by_chrom(vector<GenomicRegion> ®ions,
159159 regions.shrink_to_fit ();
160160}
161161
162+
162163inline bool
163164file_exists (const string &filename) {
164165 return (access (filename.c_str (), F_OK) == 0 );
165166}
166167
168+
169+ static bool
170+ is_compressed_file (const string &filename) {
171+ const bgzf_file f (filename.c_str (), " r" );
172+ htsFormat fmt;
173+ const int ret = hts_detect_format (f.f ->fp , &fmt);
174+ if (ret != 0 ) throw runtime_error (" failed to detect format: " + filename);
175+ return fmt.compression != no_compression;
176+ }
177+
178+
167179int
168180main_selectsites (int argc, const char **argv) {
169181
@@ -215,6 +227,12 @@ main_selectsites(int argc, const char **argv) {
215227 if (isdir (sites_file.c_str ()) || !file_exists (sites_file))
216228 throw runtime_error (" bad input sites file: " + sites_file);
217229
230+ if (is_compressed_file (sites_file)) {
231+ LOAD_ENTIRE_FILE = true ;
232+ if (VERBOSE)
233+ cerr << " input file is so must be loaded" << endl;
234+ }
235+
218236 vector<GenomicRegion> regions;
219237 ReadBEDFile (regions_file, regions);
220238 if (!check_sorted (regions))
You can’t perform that action at this time.
0 commit comments