From: martinahansen Date: Thu, 17 Nov 2011 19:57:32 +0000 (+0000) Subject: added tests to remove_primers X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a58032461bec4031795378d32a5a389e6f98a59f;p=biopieces.git added tests to remove_primers git-svn-id: http://biopieces.googlecode.com/svn/trunk@1662 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/bp_bin/remove_primers b/bp_bin/remove_primers index 108f585..9c8457c 100755 --- a/bp_bin/remove_primers +++ b/bp_bin/remove_primers @@ -47,6 +47,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| if record.has_key? :SEQ seq = Seq.new_bp(record) pos = 0 + len = 0 if forward = seq.patscan(options[:forward].to_s, pos, options[:mismatches], options[:insertions], options[:deletions]) record[:FORWARD_POS] = forward.last.pos @@ -61,10 +62,16 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| record[:REVERSE_LEN] = reverse.first.length pos = 0 len = reverse.first.pos - seq.subseq!(pos, len) if len > 0 + + if len == 0 + seq.seq = "" + seq.qual = "" if seq.qual + else + seq.subseq!(pos, len) + end end - if pos > 0 + if forward or reverse record.merge!(seq.to_bp) end diff --git a/bp_test/in/remove_primers.in b/bp_test/in/remove_primers.in new file mode 100644 index 0000000..25a0b27 --- /dev/null +++ b/bp_test/in/remove_primers.in @@ -0,0 +1,20 @@ +SEQ_NAME: test1 +SEQ: tcagtACTGAGCTAGCAGCGGTGCGccgcaaacgacggtgaccaggcgcaggcggcgagcaccgcattctgcggTGCTGGACTGGGTGGAGCACatcaa +SEQ_LEN: 99 +--- +SEQ_NAME: test2 +SEQ: ACTGAGCTAGCAGCGGTGCGccgcaaacgacggtgaccaggcgcaggcggcgagcaccgcattctgcggTGCTGGACTGGGTGGAGCAC +SEQ_LEN: 89 +--- +SEQ_NAME: test3 +SEQ: ccgcaaacgacggtgaccaggcgcaggcggcgagcaccgcattctgcggTGCTGGACTGGGTGGAGCAC +SEQ_LEN: 69 +--- +SEQ_NAME: test4 +SEQ: TGCTGGACTGGGTGGAGCACatcaa +SEQ_LEN: 25 +--- +SEQ_NAME: test5 +SEQ: TGCTGGACTGGGTGGAGCAC +SEQ_LEN: 20 +--- diff --git a/bp_test/out/remove_primers.out.1 b/bp_test/out/remove_primers.out.1 new file mode 100644 index 0000000..f916230 --- /dev/null +++ b/bp_test/out/remove_primers.out.1 @@ -0,0 +1,34 @@ +SEQ_NAME: test1 +SEQ: ccgcaaacgacggtgaccaggcgcaggcggcgagcaccgcattctgcgg +SEQ_LEN: 49 +FORWARD_POS: 5 +FORWARD_LEN: 20 +REVERSE_POS: 49 +REVERSE_LEN: 20 +--- +SEQ_NAME: test2 +SEQ: ccgcaaacgacggtgaccaggcgcaggcggcgagcaccgcattctgcgg +SEQ_LEN: 49 +FORWARD_POS: 0 +FORWARD_LEN: 20 +REVERSE_POS: 49 +REVERSE_LEN: 20 +--- +SEQ_NAME: test3 +SEQ: ccgcaaacgacggtgaccaggcgcaggcggcgagcaccgcattctgcgg +SEQ_LEN: 49 +REVERSE_POS: 49 +REVERSE_LEN: 20 +--- +SEQ_NAME: test4 +SEQ: +SEQ_LEN: 0 +REVERSE_POS: 0 +REVERSE_LEN: 20 +--- +SEQ_NAME: test5 +SEQ: +SEQ_LEN: 0 +REVERSE_POS: 0 +REVERSE_LEN: 20 +--- diff --git a/bp_test/test/test_remove_primers b/bp_test/test/test_remove_primers new file mode 100755 index 0000000..b4f98c3 --- /dev/null +++ b/bp_test/test/test_remove_primers @@ -0,0 +1,7 @@ +#!/bin/bash + +source "$BP_DIR/bp_test/lib/test.sh" + +run "$bp -f ACTGAGCTAGCAGCGGTGCG -r TGCTGGACTGGGTGGAGCAC -m 0 -i 0 -d 0 -I $in -O $tmp" +assert_no_diff $tmp $out.1 +clean