X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fwrite_fastq_files;h=0b508426eb27761fc218560f93ac0d932bdfcb7f;hb=2f0fd91b461033529a4a72e161bd133252a22eb6;hp=a116040b78b5a497b3c0165db8b920bd21d74b28;hpb=5a9b7c80e4e4428e404575ed3c0290cde15a7402;p=biopieces.git diff --git a/bp_bin/write_fastq_files b/bp_bin/write_fastq_files index a116040..0b50842 100755 --- a/bp_bin/write_fastq_files +++ b/bp_bin/write_fastq_files @@ -32,13 +32,18 @@ require 'maasha/biopieces' require 'maasha/fastq' 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=>'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} options = Biopieces.options_parse(ARGV, casts) +encoding = options[:encoding].to_sym + key = options[:key].to_sym fh_hash = {} @@ -46,7 +51,8 @@ fh_hash = {} Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| input.each_record do |record| if record[:SEQ_NAME] and record[:SEQ] and record[:SCORES] and record[key] - seq = Seq.new_bp(record) + entry = Seq.new_bp(record) + entry.qual_convert!(:base_33, encoding) if fh_hash[record[key].to_sym] fastq_io = fh_hash[record[key].to_sym] @@ -56,7 +62,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| fh_hash[record[key].to_sym] = fastq_io end - fastq_io.puts seq.to_fastq + fastq_io.puts entry.to_fastq end output.puts record unless options[:no_stream]