]> git.donarmstrong.com Git - biopieces.git/commitdiff
added delimiter to join_seq
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 29 Sep 2011 09:12:55 +0000 (09:12 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 29 Sep 2011 09:12:55 +0000 (09:12 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1537 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/join_seq
bp_test/out/join_seq.out.2 [new file with mode: 0644]
bp_test/test/test_join_seq

index f071f41d0dcc6a5165267a85f426a719f2a21fa8..ce36e5944a665753c2e43aae8b660a0935dcd81e 100755 (executable)
@@ -33,9 +33,11 @@ require 'maasha/fasta'
 require 'maasha/seq'
 
 casts = []
+casts << {:long=>'delimiter', :short=>'d', :type=>'string', :mandatory=>true, :default=>"", :allowed=>nil, :disallowed=>nil}
 
 options = Biopieces.options_parse(ARGV, casts)
 
+sequences = []
 seq = Seq.new(nil, "")
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
@@ -44,13 +46,14 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
       unless seq.seq_name 
         seq.seq_name = record[:SEQ_NAME]
       end
-      seq.seq << record[:SEQ]
+      sequences << record[:SEQ]
     end
 
     output.puts record
   end
 
-  if seq.seq != ""
+  unless sequences.empty?
+    seq.seq = sequences.join(options[:delimiter].to_s)
     new_record = seq.to_bp
     new_record[:REC_TYPE] = "JOIN"
     output.puts new_record
diff --git a/bp_test/out/join_seq.out.2 b/bp_test/out/join_seq.out.2
new file mode 100644 (file)
index 0000000..76289f6
--- /dev/null
@@ -0,0 +1,21 @@
+SEQ_NAME: test1
+SEQ: aaaa
+SEQ_LEN: 4
+---
+SEQ_NAME: test2
+SEQ: tttt
+SEQ_LEN: 4
+---
+SEQ_NAME: test3
+SEQ: cccc
+SEQ_LEN: 4
+---
+SEQ_NAME: test4
+SEQ: gggg
+SEQ_LEN: 4
+---
+SEQ_NAME: test1
+SEQ: aaaaXttttXccccXgggg
+SEQ_LEN: 19
+REC_TYPE: JOIN
+---
index 61c570925c960531a3e4b24eb994deff0d49ef25..3bdcf90076fc0fee84b39ab5727c65448c27ef62 100755 (executable)
@@ -5,3 +5,7 @@ source "$BP_DIR/bp_test/lib/test.sh"
 run "$bp -I $in -O $tmp"
 assert_no_diff $tmp $out.1
 clean
+
+run "$bp -I $in -d 'X' -O $tmp"
+assert_no_diff $tmp $out.2
+clean