X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Fapi%2Finternal%2FBamStandardIndex_p.cpp;h=43f12ebf8838ce505180e11891e749c5313fcfd4;hb=55bd722399551caec548b6ca9a60151199118b88;hp=6d8273e9c1477a965aebb0bea553026014c90d4a;hpb=590fa357b9b9a8dfdad2f8dc0c3c113c3b26fbfe;p=bamtools.git diff --git a/src/api/internal/BamStandardIndex_p.cpp b/src/api/internal/BamStandardIndex_p.cpp index 6d8273e..43f12eb 100644 --- a/src/api/internal/BamStandardIndex_p.cpp +++ b/src/api/internal/BamStandardIndex_p.cpp @@ -1,7 +1,6 @@ // *************************************************************************** // BamStandardIndex.cpp (c) 2010 Derek Barnett // Marth Lab, Department of Biology, Boston College -// All rights reserved. // --------------------------------------------------------------------------- // Last modified: 24 June 2011 (DB) // --------------------------------------------------------------------------- @@ -264,7 +263,7 @@ bool BamStandardIndex::Create(void) { // open new index file (read & write) string indexFilename = m_reader->Filename() + Extension(); if ( !OpenFile(indexFilename, "w+b") ) { - cerr << "BamStandardIndex ERROR: could not open ouput index file: " << indexFilename + cerr << "BamStandardIndex ERROR: could not open output index file: " << indexFilename << ", aborting index creation" << endl; return false; } @@ -435,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() );