[med-svn] [bedtools] 09/14: Fixed intersect bug so that bed query with Bam DB correctly gives bed output. Added unit test.

Charles Plessy plessy at moszumanska.debian.org
Thu Mar 6 22:56:44 UTC 2014


This is an automated email from the git hooks/post-receive script.

plessy pushed a commit to branch master
in repository bedtools.

commit 9509809235906e0924a60a9c38abd39075547d1e
Author: nkindlon <nek3d at virginia.edu>
Date:   Tue Mar 4 14:22:24 2014 -0500

    Fixed intersect bug so that bed query with Bam DB correctly gives bed output. Added unit test.
---
 src/utils/Contexts/ContextBase.cpp | 12 +++---------
 test/intersect/test-intersect.sh   | 11 ++++++++++-
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/utils/Contexts/ContextBase.cpp b/src/utils/Contexts/ContextBase.cpp
index adbc47a..16d2402 100644
--- a/src/utils/Contexts/ContextBase.cpp
+++ b/src/utils/Contexts/ContextBase.cpp
@@ -94,15 +94,9 @@ bool ContextBase::determineOutputType() {
 		return true;
 	}
 
-	//Otherwise, if there are any BAM files in the input,
-	//then the output should be BAM.
-	for (_i = 0; _i < (int)_files.size(); _i++) {
-		if (_files[_i]->getFileType() == FileRecordTypeChecker::BAM_FILE_TYPE) {
-			setOutputFileType(FileRecordTypeChecker::BAM_FILE_TYPE);
-			_bamHeaderAndRefIdx = _i;
-			_outputTypeDetermined = true;
-			return true;
-		}
+	//Otherwise, if the input is BAM, then the output is BAM
+	if (getFile(0)->getFileType() == FileRecordTypeChecker::BAM_FILE_TYPE) {
+		setOutputFileType(FileRecordTypeChecker::BAM_FILE_TYPE);
 	}
 
 	//Okay, it's bed.
diff --git a/test/intersect/test-intersect.sh b/test/intersect/test-intersect.sh
index da0ba96..e6c2c67 100644
--- a/test/intersect/test-intersect.sh
+++ b/test/intersect/test-intersect.sh
@@ -446,7 +446,16 @@ echo \
 "chr1^I10^I20^I345.7^Iwhy?^I-^Ichr1^I11^I21^I345.7^Iwhy?^I+" > exp
 $BT intersect -a bed6.strand.bed -b bed6.strand2.bed -wa -wb -S | cat -t > obs
 check obs exp
-
 rm obs exp
 
+##################################################################
+#  Test that intersect of bed query with BAM DB gives Bed output.
+##################################################################
+echo "    intersect.t37...\c"
+echo \
+"chr1	10	20	a1	1	+
+chr1	100	200	a2	2	-" > exp
+$BT intersect -a a.bed -b a.bam > obs
+
+
 rm one_block.bam two_blocks.bam three_blocks.bam
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/bedtools.git



More information about the debian-med-commit mailing list