From db63f7c21ac6e4dc1198a7cc211f2375788889fb Mon Sep 17 00:00:00 2001 From: gabeiscoding Date: Fri, 23 Sep 2011 09:35:34 -0600 Subject: [PATCH] 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. --- src/api/internal/BamStandardIndex_p.cpp | 6 ++++++ 1 file changed, 6 insertions(+) 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() ); -- 2.39.5