From 81d8f5f74f0a71bb1483b9525b79160078be117a Mon Sep 17 00:00:00 2001 From: martinahansen Date: Thu, 29 Sep 2011 09:12:55 +0000 Subject: [PATCH] added delimiter to join_seq git-svn-id: http://biopieces.googlecode.com/svn/trunk@1537 74ccb610-7750-0410-82ae-013aeee3265d --- bp_bin/join_seq | 7 +++++-- bp_test/out/join_seq.out.2 | 21 +++++++++++++++++++++ bp_test/test/test_join_seq | 4 ++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 bp_test/out/join_seq.out.2 diff --git a/bp_bin/join_seq b/bp_bin/join_seq index f071f41..ce36e59 100755 --- a/bp_bin/join_seq +++ b/bp_bin/join_seq @@ -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 index 0000000..76289f6 --- /dev/null +++ b/bp_test/out/join_seq.out.2 @@ -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 +--- diff --git a/bp_test/test/test_join_seq b/bp_test/test/test_join_seq index 61c5709..3bdcf90 100755 --- a/bp_test/test/test_join_seq +++ b/bp_test/test/test_join_seq @@ -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 -- 2.39.5