From: martinahansen Date: Fri, 4 Jan 2013 10:23:15 +0000 (+0000) Subject: updated pcr_seq and added tests X-Git-Url: https://git.donarmstrong.com/?p=biopieces.git;a=commitdiff_plain;h=5ced0e7864e9645e56c6c618da1f04e0a4d667fc updated pcr_seq and added tests git-svn-id: http://biopieces.googlecode.com/svn/trunk@2054 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/bp_bin/pcr_seq b/bp_bin/pcr_seq index f545773..8700276 100755 --- a/bp_bin/pcr_seq +++ b/bp_bin/pcr_seq @@ -51,6 +51,7 @@ class Pcr command = "scan_for_matches" # command << " -c" + command << " -o 1" command << " #{pat_file}" command << " < #{@infile}" command << " > #{outfile}" @@ -152,14 +153,25 @@ class Pattern end casts = [] -casts << {:long=>'forward', :short=>'f', :type=>'string', :mandatory=>true, :default=>nil, :allowed=>nil, :disallowed=>nil} -casts << {:long=>'reverse', :short=>'r', :type=>'string', :mandatory=>true, :default=>nil, :allowed=>nil, :disallowed=>nil} -casts << {:long=>'max_dist', :short=>'m', :type=>'uint', :mandatory=>true, :default=>5000, :allowed=>nil, :disallowed=>"0"} +casts << {:long=>'forward', :short=>'f', :type=>'string', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil} +casts << {:long=>'forward_rc', :short=>'F', :type=>'string', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil} +casts << {:long=>'reverse', :short=>'r', :type=>'string', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil} +casts << {:long=>'reverse_rc', :short=>'R', :type=>'string', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil} +casts << {:long=>'max_dist', :short=>'m', :type=>'uint', :mandatory=>true, :default=>5000, :allowed=>nil, :disallowed=>"0"} options = Biopieces.options_parse(ARGV, casts) tmpdir = Biopieces.mktmpdir infile = File.join(tmpdir, "in.fna") +if options[:forward_rc] + options[:forward] = Seq.new("test", options[:forward_rc], 'dna').revcomp.seq +end + +if options[:reverse_rc] + options[:reverse] = Seq.new("test", options[:reverse_rc], 'dna').revcomp.seq +end + +raise ArgumentError, "no adaptor specified" unless options[:forward] or options[:reverse] Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| Fasta.open(infile, mode="w") do |ios| input.each_record do |record| diff --git a/bp_test/in/pcr_seq.in b/bp_test/in/pcr_seq.in new file mode 100644 index 0000000..7dbdf89 --- /dev/null +++ b/bp_test/in/pcr_seq.in @@ -0,0 +1,16 @@ +SEQ_NAME: forward_reverse +SEQ: tgCGATCGAGCTactagctagctatcatcgatctgAGTCAGTCATct +SEQ_LEN: 47 +--- +SEQ_NAME: forward_RCforward +SEQ: tgCGATCGAGCTactagctagctatcatcgatctgAGCTCGATCGct +SEQ_LEN: 47 +--- +SEQ_NAME: RCreverse_reverse +SEQ: tgATGACTGACTactagctagctatcatcgatctgAGTCAGTCATct +SEQ_LEN: 47 +--- +SEQ_NAME: RCreverse_RCforward +SEQ: tgATGACTGACTactagctagctatcatcgatctgAGCTCGATCGct +SEQ_LEN: 47 +--- diff --git a/bp_test/out/pcr_seq.out.1 b/bp_test/out/pcr_seq.out.1 new file mode 100644 index 0000000..263bc98 --- /dev/null +++ b/bp_test/out/pcr_seq.out.1 @@ -0,0 +1,52 @@ +SEQ_NAME: forward_reverse +SEQ: tgCGATCGAGCTactagctagctatcatcgatctgAGTCAGTCATct +SEQ_LEN: 47 +--- +SEQ_NAME: forward_RCforward +SEQ: tgCGATCGAGCTactagctagctatcatcgatctgAGCTCGATCGct +SEQ_LEN: 47 +--- +SEQ_NAME: RCreverse_reverse +SEQ: tgATGACTGACTactagctagctatcatcgatctgAGTCAGTCATct +SEQ_LEN: 47 +--- +SEQ_NAME: RCreverse_RCforward +SEQ: tgATGACTGACTactagctagctatcatcgatctgAGCTCGATCGct +SEQ_LEN: 47 +--- +SEQ_NAME: forward_reverse +SEQ: CGATCGAGCTactagctagctatcatcgatctgAGTCAGTCAT +SEQ_LEN: 43 +REC_TYPE: PCR +STRAND: + +TYPE: FORWARD_REVERSE +PCR_BEG: 3 +PCR_END: 45 +--- +SEQ_NAME: forward_RCforward +SEQ: CGATCGAGCTactagctagctatcatcgatctgAGCTCGATCG +SEQ_LEN: 43 +REC_TYPE: PCR +STRAND: + +TYPE: FORWARD_FORWARD +PCR_BEG: 3 +PCR_END: 45 +--- +SEQ_NAME: RCreverse_reverse +SEQ: ATGACTGACTactagctagctatcatcgatctgAGTCAGTCAT +SEQ_LEN: 43 +REC_TYPE: PCR +STRAND: + +TYPE: REVERSE_REVERSE +PCR_BEG: 3 +PCR_END: 45 +--- +SEQ_NAME: RCreverse_RCforward +SEQ: ATGACTGACTactagctagctatcatcgatctgAGCTCGATCG +SEQ_LEN: 43 +REC_TYPE: PCR +STRAND: + +TYPE: REVERSE_FORWARD +PCR_BEG: 3 +PCR_END: 45 +--- diff --git a/bp_test/out/pcr_seq.out.2 b/bp_test/out/pcr_seq.out.2 new file mode 100644 index 0000000..7dbdf89 --- /dev/null +++ b/bp_test/out/pcr_seq.out.2 @@ -0,0 +1,16 @@ +SEQ_NAME: forward_reverse +SEQ: tgCGATCGAGCTactagctagctatcatcgatctgAGTCAGTCATct +SEQ_LEN: 47 +--- +SEQ_NAME: forward_RCforward +SEQ: tgCGATCGAGCTactagctagctatcatcgatctgAGCTCGATCGct +SEQ_LEN: 47 +--- +SEQ_NAME: RCreverse_reverse +SEQ: tgATGACTGACTactagctagctatcatcgatctgAGTCAGTCATct +SEQ_LEN: 47 +--- +SEQ_NAME: RCreverse_RCforward +SEQ: tgATGACTGACTactagctagctatcatcgatctgAGCTCGATCGct +SEQ_LEN: 47 +--- diff --git a/bp_test/out/pcr_seq.out.3 b/bp_test/out/pcr_seq.out.3 new file mode 100644 index 0000000..ca89353 --- /dev/null +++ b/bp_test/out/pcr_seq.out.3 @@ -0,0 +1,25 @@ +SEQ_NAME: forward_reverse +SEQ: tgCGATCGAGCTactagctagctatcatcgatctgAGTCAGTCATct +SEQ_LEN: 47 +--- +SEQ_NAME: forward_RCforward +SEQ: tgCGATCGAGCTactagctagctatcatcgatctgAGCTCGATCGct +SEQ_LEN: 47 +--- +SEQ_NAME: RCreverse_reverse +SEQ: tgATGACTGACTactagctagctatcatcgatctgAGTCAGTCATct +SEQ_LEN: 47 +--- +SEQ_NAME: RCreverse_RCforward +SEQ: tgATGACTGACTactagctagctatcatcgatctgAGCTCGATCGct +SEQ_LEN: 47 +--- +SEQ_NAME: RCreverse_reverse +SEQ: ATGACTGACTactagctagctatcatcgatctgAGTCAGTCAT +SEQ_LEN: 43 +REC_TYPE: PCR +STRAND: + +TYPE: REVERSE_REVERSE +PCR_BEG: 3 +PCR_END: 45 +--- diff --git a/bp_test/out/pcr_seq.out.4 b/bp_test/out/pcr_seq.out.4 new file mode 100644 index 0000000..9cc0964 --- /dev/null +++ b/bp_test/out/pcr_seq.out.4 @@ -0,0 +1,25 @@ +SEQ_NAME: forward_reverse +SEQ: tgCGATCGAGCTactagctagctatcatcgatctgAGTCAGTCATct +SEQ_LEN: 47 +--- +SEQ_NAME: forward_RCforward +SEQ: tgCGATCGAGCTactagctagctatcatcgatctgAGCTCGATCGct +SEQ_LEN: 47 +--- +SEQ_NAME: RCreverse_reverse +SEQ: tgATGACTGACTactagctagctatcatcgatctgAGTCAGTCATct +SEQ_LEN: 47 +--- +SEQ_NAME: RCreverse_RCforward +SEQ: tgATGACTGACTactagctagctatcatcgatctgAGCTCGATCGct +SEQ_LEN: 47 +--- +SEQ_NAME: forward_RCforward +SEQ: CGATCGAGCTactagctagctatcatcgatctgAGCTCGATCG +SEQ_LEN: 43 +REC_TYPE: PCR +STRAND: + +TYPE: FORWARD_FORWARD +PCR_BEG: 3 +PCR_END: 45 +--- diff --git a/bp_test/out/pcr_seq.out.5 b/bp_test/out/pcr_seq.out.5 new file mode 100644 index 0000000..7dbdf89 --- /dev/null +++ b/bp_test/out/pcr_seq.out.5 @@ -0,0 +1,16 @@ +SEQ_NAME: forward_reverse +SEQ: tgCGATCGAGCTactagctagctatcatcgatctgAGTCAGTCATct +SEQ_LEN: 47 +--- +SEQ_NAME: forward_RCforward +SEQ: tgCGATCGAGCTactagctagctatcatcgatctgAGCTCGATCGct +SEQ_LEN: 47 +--- +SEQ_NAME: RCreverse_reverse +SEQ: tgATGACTGACTactagctagctatcatcgatctgAGTCAGTCATct +SEQ_LEN: 47 +--- +SEQ_NAME: RCreverse_RCforward +SEQ: tgATGACTGACTactagctagctatcatcgatctgAGCTCGATCGct +SEQ_LEN: 47 +--- diff --git a/bp_test/test/test_pcr_seq b/bp_test/test/test_pcr_seq new file mode 100755 index 0000000..c04bfe2 --- /dev/null +++ b/bp_test/test/test_pcr_seq @@ -0,0 +1,23 @@ +#!/bin/bash + +source "$BP_DIR/bp_test/lib/test.sh" + +run "$bp -f CGATCGAGCT -r AGTCAGTCAT -I $in -O $tmp" +assert_no_diff $tmp $out.1 +clean + +run "$bp -f CGATCGAGCT -r AGTCAGTCAT -m 1 -I $in -O $tmp" +assert_no_diff $tmp $out.2 +clean + +run "$bp -F CGATCGAGCT -r AGTCAGTCAT -I $in -O $tmp" +assert_no_diff $tmp $out.3 +clean + +run "$bp -f CGATCGAGCT -R AGTCAGTCAT -I $in -O $tmp" +assert_no_diff $tmp $out.4 +clean + +run "$bp -F CGATCGAGCT -R AGTCAGTCAT -I $in -O $tmp" +assert_no_diff $tmp $out.5 +clean