From a16562f4c0840928a91ad42ad77f3c4a20af6d5c Mon Sep 17 00:00:00 2001 From: nkindlon <nek3d@virginia.edu> Date: Fri, 3 Jan 2014 14:57:46 -0500 Subject: [PATCH] Added fix for Bam files with empty headers. Added test for this to unit test. --- .../FileReaders/InputStreamMgr.cpp | 5 +---- test/intersect/gdc.bam | Bin 0 -> 204 bytes test/intersect/gdc_exp | 12 ++++++++++++ test/intersect/new_test-intersect.sh | 9 +++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 test/intersect/gdc.bam create mode 100644 test/intersect/gdc_exp diff --git a/src/utils/FileRecordTools/FileReaders/InputStreamMgr.cpp b/src/utils/FileRecordTools/FileReaders/InputStreamMgr.cpp index 1f9d0441..5b1d0a9c 100644 --- a/src/utils/FileRecordTools/FileReaders/InputStreamMgr.cpp +++ b/src/utils/FileRecordTools/FileReaders/InputStreamMgr.cpp @@ -204,10 +204,7 @@ bool InputStreamMgr::detectBamOrBgzip(int &numChars, int currChar) _bamReader = new BamTools::BamReader(); - _bamReader->OpenStream(_finalInputStream); - QuickString bamHeader(_bamReader->GetHeaderText()); - - if (bamHeader.empty()) { + if (!_bamReader->OpenStream(_finalInputStream)) { //This is NOT a bam file, but it is bgzipped. _pushBackStreamBuf->clear(); //Put all bytes read so far back onto the scan buffer, then reset diff --git a/test/intersect/gdc.bam b/test/intersect/gdc.bam new file mode 100644 index 0000000000000000000000000000000000000000..80dcfaa0b3080652c64d10497e4ecfb4e223a389 GIT binary patch literal 204 zcmb2|=3rp}f&Xj_PR>jW`V7TIUs6*Tm;?^89XToK>So7dF7il{aZRF?s1#6{JevA? zhRrDr40;M_f8T2!;aJr8!(OD}$)8W3gCv<6ctjN$c?CXvE=~LJxgc#zOIBHPw%CES zJDr^wS3i?WGSSvb++HbVILmg{hU|SVJ@Z*rIetp^r@6bonN{6!@y?@%4WXZz7Ukr* XY?WjXkL`Z`f)UexX$EGH>%jm3<v~Hn literal 0 HcmV?d00001 diff --git a/test/intersect/gdc_exp b/test/intersect/gdc_exp new file mode 100644 index 00000000..442b7f28 --- /dev/null +++ b/test/intersect/gdc_exp @@ -0,0 +1,12 @@ +chr2L 10 15 None 255 + 10 15 0,0,0 1 5, 0, +chr2L 70 75 None 255 - 70 75 0,0,0 1 5, 0, +chr2L 70 75 None 255 - 70 75 0,0,0 1 5, 0, +chr2L 140 145 None 255 - 140 145 0,0,0 1 5, 0, +chr2L 140 145 None 255 - 140 145 0,0,0 1 5, 0, +chr2L 150 155 None 255 - 150 155 0,0,0 1 5, 0, +chr2L 210 215 None 255 + 210 215 0,0,0 1 5, 0, +chr2L 70 75 None 255 + 70 75 0,0,0 1 5, 0, +chr2L 70 75 None 255 + 70 75 0,0,0 1 5, 0, +chr2L 140 145 None 255 + 140 145 0,0,0 1 5, 0, +chr2L 140 145 None 255 + 140 145 0,0,0 1 5, 0, +chr2L 160 165 None 255 + 160 165 0,0,0 1 5, 0, diff --git a/test/intersect/new_test-intersect.sh b/test/intersect/new_test-intersect.sh index 056278b4..85c6a8bb 100755 --- a/test/intersect/new_test-intersect.sh +++ b/test/intersect/new_test-intersect.sh @@ -605,6 +605,15 @@ check obs exp rm obs exp +########################################################### +# Test that we can process a Bam file with no text in +# it's header. +############################################################ +echo " intersect.new.t53...\c" +$BT intersect -a gdc.bam -b gdc.bam -bed > obs +check obs gdc_exp +rm obs + -- GitLab