From: gabeiscoding Date: Fri, 23 Sep 2011 15:35:34 +0000 (-0600) Subject: In standard indexed BAM files with with sparce coverage (our test case was a roughly... X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=db63f7c21ac6e4dc1198a7cc211f2375788889fb;p=bamtools.git In standard indexed BAM files with with sparce coverage (our test case was a roughly 1M read RNAseq BAM file), queries made to intervals may not have any of the candidate offesets present in the index as the BAM index only contains bins that have reads. Without this bail out, we would get a crash. Returning false silently is the preferred behavior in our view as it allows our read logic to go to the next query and does not add noise to stderr. --- diff --git a/src/api/internal/BamStandardIndex_p.cpp b/src/api/internal/BamStandardIndex_p.cpp index b92c47b..11f570a 100644 --- a/src/api/internal/BamStandardIndex_p.cpp +++ b/src/api/internal/BamStandardIndex_p.cpp @@ -434,6 +434,12 @@ bool BamStandardIndex::GetOffset(const BamRegion& region, int64_t& offset, bool* return false; } + // if not candidate offsets are present in the indexed (most likely sparce coverage) + // then silently bail + if( offsets.size() == 0 ) { + return false; + } + // ensure that offsets are sorted before processing sort( offsets.begin(), offsets.end() );