X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fwrite_fastq_files;h=b475b121eeec6cead74d03a9c767023d640870ef;hb=48bea5c28b89dc5586d0bddb338ccd6ba23aa1f9;hp=0b508426eb27761fc218560f93ac0d932bdfcb7f;hpb=4c74f0aa5b9a572a2552767d4c4c0c15166e092a;p=biopieces.git diff --git a/bp_bin/write_fastq_files b/bp_bin/write_fastq_files index 0b50842..b475b12 100755 --- a/bp_bin/write_fastq_files +++ b/bp_bin/write_fastq_files @@ -35,14 +35,17 @@ 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: 'prefix', short: 'p', type: 'string', mandatory: false, 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 @@ -57,8 +60,15 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| if fh_hash[record[key].to_sym] 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") + if options[:prefix] + fastq_file = File.join(options[:dir], [options[:prefix], record[key]].join("_") + ".fastq") + else + fastq_file = File.join(options[:dir], record[key] + ".fastq") + end + + 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