]> git.donarmstrong.com Git - biopieces.git/commitdiff
added gzip/bzip2 output option to write_fastq_files
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 25 Sep 2013 19:50:03 +0000 (19:50 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 25 Sep 2013 19:50:03 +0000 (19:50 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@2214 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/write_fastq_files
bp_test/test/test_write_fastq_files

index 0b508426eb27761fc218560f93ac0d932bdfcb7f..5e36a38eb44134c1d024c5d1467e0cb212aaf91a 100755 (executable)
@@ -35,14 +35,16 @@ require 'pp'
 allowed_enc = 'base_33,base_64'
 
 casts = []
-casts << {:long=>'key',       :short=>'k', :type=>'string', :mandatory=>true,  :default=>nil,       :allowed=>nil, :disallowed=>nil}
-casts << {:long=>'dir',       :short=>'d', :type=>'dir!',   :mandatory=>true,  :default=>nil,       :allowed=>nil, :disallowed=>nil}
-casts << {:long=>'no_stream', :short=>'x', :type=>'flag',   :mandatory=>false, :default=>nil,       :allowed=>nil, :disallowed=>nil}
-casts << {:long=>'encoding',  :short=>'e', :type=>'string', :mandatory=>false, :default=>'base_33', :allowed=>allowed_enc, :disallowed=>nil}
+casts << {long: 'key',       short: 'k', type: 'string', mandatory: true,  default: nil,       allowed: nil,               disallowed: nil}
+casts << {long: 'dir',       short: 'd', type: 'dir!',   mandatory: true,  default: nil,       allowed: nil,               disallowed: nil}
+casts << {long: 'no_stream', short: 'x', type: 'flag',   mandatory: false, default: nil,       allowed: nil,               disallowed: nil}
+casts << {long: 'compress',  short: 'Z', type: 'string', mandatory: false, default: nil,       allowed: "gzip,bzip,bzip2", disallowed: nil}
+casts << {long: 'encoding',  short: 'e', type: 'string', mandatory: false, default: 'base_33', allowed: allowed_enc,       disallowed: nil}
 
 options = Biopieces.options_parse(ARGV, casts)
 
 encoding = options[:encoding].to_sym
+compress = options[:compress] ? options[:compress].to_sym : nil
 
 key = options[:key].to_sym
 
@@ -58,7 +60,9 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
         fastq_io = fh_hash[record[key].to_sym]
       else
         fastq_file = File.join(options[:dir], record[key] + ".fastq")
-        fastq_io   = Fastq.open(fastq_file, "w")
+        fastq_file << ".gz"  if compress == :gzip
+        fastq_file << ".bz2" if compress == :bzip or compress == :bzip2
+        fastq_io   = Fastq.open(fastq_file, "w", compress: compress)
         fh_hash[record[key].to_sym] = fastq_io
       end
 
index 89442b640f32ef86e7f4ee05f9f0c24cca7aa99c..7babe73dccbeda5bb338317055595ab927f637bd 100755 (executable)
@@ -3,25 +3,33 @@
 source "$BP_DIR/bp_test/lib/test.sh"
 
 mkdir $tmp_dir
-
 run "$bp -I $in -d $tmp_dir -k SEQ_NAME -x"
 assert_no_diff_dir $tmp_dir $out.1
 clean
-
 rm -rf $tmp_dir
 
 mkdir $tmp_dir
-
 run "$bp -I $in -e base_33 -d $tmp_dir -k SEQ_NAME -x"
 assert_no_diff_dir $tmp_dir $out.1
 clean
-
 rm -rf $tmp_dir
 
 mkdir $tmp_dir
-
 run "$bp -I $in -e base_64 -d $tmp_dir -k SEQ_NAME -x"
 assert_no_diff_dir $tmp_dir $out.2
 clean
+rm -rf $tmp_dir
+
+mkdir $tmp_dir
+run "$bp -I $in -e base_64 -d $tmp_dir -k SEQ_NAME -Z gzip -x"
+gunzip $tmp_dir/*.gz
+assert_no_diff_dir $tmp_dir $out.2
+clean
+rm -rf $tmp_dir
 
+mkdir $tmp_dir
+run "$bp -I $in -e base_64 -d $tmp_dir -k SEQ_NAME -Z bzip2 -x"
+bunzip2 $tmp_dir/*.bz2
+assert_no_diff_dir $tmp_dir $out.2
+clean
 rm -rf $tmp_dir