diff --git a/src/coverageBed/coverageBed.cpp b/src/coverageBed/coverageBed.cpp index f54772620a3f09f7560ed8876ffec12ddc1676d6..4af2edb262b211736d2ab47bc95e566867523854 100644 --- a/src/coverageBed/coverageBed.cpp +++ b/src/coverageBed/coverageBed.cpp @@ -85,10 +85,12 @@ void BedCoverage::CollectCoverageBam(string bamFile) { // that we can easily compare "A" to it for overlaps _bedB->loadBedCovFileIntoMap(); - // open the BAM file + // open the BAM file BamReader reader; - reader.Open(bamFile); - + if (!reader.Open(bamFile)) { + cerr << "Failed to open BAM file " << bamFile << endl; + exit(1); + } // get header & reference information string header = reader.GetHeaderText(); RefVector refs = reader.GetReferenceData(); diff --git a/src/genomeCoverageBed/genomeCoverageBed.cpp b/src/genomeCoverageBed/genomeCoverageBed.cpp index cdb044464ec49e96c4cd2b4b4d256a41e8354baa..621c461daa6c97118b49073aabac1983e8f12ef3 100644 --- a/src/genomeCoverageBed/genomeCoverageBed.cpp +++ b/src/genomeCoverageBed/genomeCoverageBed.cpp @@ -211,7 +211,10 @@ void BedGenomeCoverage::CoverageBam(string bamFile) { // open the BAM file BamReader reader; - reader.Open(bamFile); + if (!reader.Open(bamFile)) { + cerr << "Failed to open BAM file " << bamFile << endl; + exit(1); + } // get header & reference information string header = reader.GetHeaderText(); diff --git a/src/intersectBed/intersectBed.cpp b/src/intersectBed/intersectBed.cpp index 3382b2dfca8de0ac17cb85b5e6803734c30ab42d..4f25c1b35acfdbe92df37c68416a9e9248ea7d7c 100644 --- a/src/intersectBed/intersectBed.cpp +++ b/src/intersectBed/intersectBed.cpp @@ -308,7 +308,11 @@ void BedIntersect::IntersectBam(string bamFile) { // open the BAM file BamReader reader; BamWriter writer; - reader.Open(bamFile); + if (!reader.Open(bamFile)) { + cerr << "Failed to open BAM file " << bamFile << endl; + exit(1); + } + // get header & reference information string bamHeader = reader.GetHeaderText(); RefVector refs = reader.GetReferenceData(); diff --git a/src/pairToBed/pairToBed.cpp b/src/pairToBed/pairToBed.cpp index a08c6736822d2b5ce9012381cf31ca58bc04c855..7db744fc812eaa1dae678aad771ff95f94fc1aaf 100644 --- a/src/pairToBed/pairToBed.cpp +++ b/src/pairToBed/pairToBed.cpp @@ -383,7 +383,10 @@ void BedIntersectPE::IntersectBamPE(string bamFile) { // open the BAM file BamReader reader; BamWriter writer; - reader.Open(bamFile); + if (!reader.Open(bamFile)) { + cerr << "Failed to open BAM file " << bamFile << endl; + exit(1); + } // get header & reference information string bamHeader = reader.GetHeaderText(); diff --git a/src/tagBam/tagBam.cpp b/src/tagBam/tagBam.cpp index 384094d5812f44d981cc7bbe5d43266178b3d2ca..5c7590fbb96dc048f68251715366e6716101e256 100644 --- a/src/tagBam/tagBam.cpp +++ b/src/tagBam/tagBam.cpp @@ -64,7 +64,11 @@ void TagBam::Tag() { // open the BAM file BamReader reader; BamWriter writer; - reader.Open(_bamFile); + if (!reader.Open(_bamFile)) { + cerr << "Failed to open BAM file " << _bamFile << endl; + exit(1); + } + // get header & reference information string bamHeader = reader.GetHeaderText(); RefVector refs = reader.GetReferenceData(); diff --git a/src/utils/chromsweep/chromsweep.cpp b/src/utils/chromsweep/chromsweep.cpp index 88456f36bbe4ac3c6a543d8aa262834a8984359b..e3c4afad367320aa1ead02687cb916b3664a669f 100644 --- a/src/utils/chromsweep/chromsweep.cpp +++ b/src/utils/chromsweep/chromsweep.cpp @@ -169,9 +169,9 @@ bool ChromSweep::Next(pair<BED, vector<BED> > &next) { { if (IsValidHit(_curr_qy, _curr_db)) { _hits.push_back(_curr_db); - } - _cache.push_back(_curr_db); - _db->GetNextBed(_curr_db, true); + } + _cache.push_back(_curr_db); + _db->GetNextBed(_curr_db, true); } // add the hits for this query to the pump _results.push(make_pair(_curr_qy, _hits)); diff --git a/src/windowBed/windowBed.cpp b/src/windowBed/windowBed.cpp index 852a475b33a3494dfaff8e0723cf2d195679396a..55342db0eb7d2c275509bf6f28c44d59d5ad2787 100644 --- a/src/windowBed/windowBed.cpp +++ b/src/windowBed/windowBed.cpp @@ -158,7 +158,11 @@ void BedWindow::WindowIntersectBam(string bamFile) { // open the BAM file BamReader reader; BamWriter writer; - reader.Open(bamFile); + if (!reader.Open(bamFile)) { + cerr << "Failed to open BAM file " << bamFile << endl; + exit(1); + } + // get header & reference information string bamHeader = reader.GetHeaderText();