From a949711879aa421a6e36c4b7f34305525d64a585 Mon Sep 17 00:00:00 2001 From: martinahansen Date: Mon, 6 Jun 2011 15:21:33 +0000 Subject: [PATCH] fixed cat_seq git-svn-id: http://biopieces.googlecode.com/svn/trunk@1462 74ccb610-7750-0410-82ae-013aeee3265d --- bp_bin/cat_seq | 9 +++++++-- bp_test/out/cat_seq.out.1 | 1 + bp_test/out/cat_seq.out.2 | 5 +++++ bp_test/out/cat_seq.out.3 | 17 +++++++++++++++++ bp_test/test/test_cat_seq | 8 ++++++++ 5 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 bp_test/out/cat_seq.out.2 create mode 100644 bp_test/out/cat_seq.out.3 diff --git a/bp_bin/cat_seq b/bp_bin/cat_seq index 060b7d5..88e9d24 100755 --- a/bp_bin/cat_seq +++ b/bp_bin/cat_seq @@ -31,17 +31,22 @@ require 'maasha/biopieces' -options = Biopieces.options_parse(ARGV) +casts = [] +casts << {:long=>'seq_name', :short=>'s', :type=>'string', :mandatory=>true, :default=>"cat_seq", :allowed=>nil, :disallowed=>nil} +casts << {:long=>'no_stream', :short=>'x', :type=>'flag', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil} + +options = Biopieces.options_parse(ARGV, casts) seq = "" Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| input.each_record do |record| seq << record[:SEQ] if record.has_key? :SEQ - output.puts record + output.puts record unless options[:no_stream] end new_record = {} + new_record[:SEQ_NAME] = options[:seq_name] new_record[:SEQ] = seq new_record[:SEQ_LEN] = seq.length new_record[:REC_TYPE] = "CAT" diff --git a/bp_test/out/cat_seq.out.1 b/bp_test/out/cat_seq.out.1 index 45481e8..b616ca7 100644 --- a/bp_test/out/cat_seq.out.1 +++ b/bp_test/out/cat_seq.out.1 @@ -10,6 +10,7 @@ SEQ_NAME: test3 SEQ: TACGATGCTAGCNATCY SEQ_LEN: 17 --- +SEQ_NAME: cat_seq SEQ: TACGATGCTAGCNATCYGACNACTGACTGACNTACGATGCTAGCNATCYGACNACTGTACGATGCTAGCNATCY SEQ_LEN: 74 REC_TYPE: CAT diff --git a/bp_test/out/cat_seq.out.2 b/bp_test/out/cat_seq.out.2 new file mode 100644 index 0000000..36b89c6 --- /dev/null +++ b/bp_test/out/cat_seq.out.2 @@ -0,0 +1,5 @@ +SEQ_NAME: cat_seq +SEQ: TACGATGCTAGCNATCYGACNACTGACTGACNTACGATGCTAGCNATCYGACNACTGTACGATGCTAGCNATCY +SEQ_LEN: 74 +REC_TYPE: CAT +--- diff --git a/bp_test/out/cat_seq.out.3 b/bp_test/out/cat_seq.out.3 new file mode 100644 index 0000000..56f5610 --- /dev/null +++ b/bp_test/out/cat_seq.out.3 @@ -0,0 +1,17 @@ +SEQ_NAME: test1 +SEQ: TACGATGCTAGCNATCYGACNACTGACTGACN +SEQ_LEN: 32 +--- +SEQ_NAME: test2 +SEQ: TACGATGCTAGCNATCYGACNACTG +SEQ_LEN: 25 +--- +SEQ_NAME: test3 +SEQ: TACGATGCTAGCNATCY +SEQ_LEN: 17 +--- +SEQ_NAME: Foobar +SEQ: TACGATGCTAGCNATCYGACNACTGACTGACNTACGATGCTAGCNATCYGACNACTGTACGATGCTAGCNATCY +SEQ_LEN: 74 +REC_TYPE: CAT +--- diff --git a/bp_test/test/test_cat_seq b/bp_test/test/test_cat_seq index 61c5709..a508434 100755 --- a/bp_test/test/test_cat_seq +++ b/bp_test/test/test_cat_seq @@ -5,3 +5,11 @@ 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 -x -O $tmp" +assert_no_diff $tmp $out.2 +clean + +run "$bp -I $in -s Foobar -O $tmp" +assert_no_diff $tmp $out.3 +clean -- 2.39.2