]> git.donarmstrong.com Git - biopieces.git/commitdiff
added tests to remove_primers
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 17 Nov 2011 19:57:32 +0000 (19:57 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 17 Nov 2011 19:57:32 +0000 (19:57 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1662 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/remove_primers
bp_test/in/remove_primers.in [new file with mode: 0644]
bp_test/out/remove_primers.out.1 [new file with mode: 0644]
bp_test/test/test_remove_primers [new file with mode: 0755]

index 108f5856746485329dbc812daf56d07693b42f33..9c8457ccb527bd50281e2a202dc47ae1003959f6 100755 (executable)
@@ -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 (file)
index 0000000..25a0b27
--- /dev/null
@@ -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 (file)
index 0000000..f916230
--- /dev/null
@@ -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 (executable)
index 0000000..b4f98c3
--- /dev/null
@@ -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