X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fscores_to_dec;h=56381a5522b023ecbde2ae9a7d3fece2aef7088c;hb=846f7af09551a46b046d25ed01429f7c88ef6982;hp=9c94454be65b7028b20f1f2113fb086b37db1e2a;hpb=4f11b77e8927625e3d5c8ae4f968412d5f44a534;p=biopieces.git diff --git a/bp_bin/scores_to_dec b/bp_bin/scores_to_dec index 9c94454..56381a5 100755 --- a/bp_bin/scores_to_dec +++ b/bp_bin/scores_to_dec @@ -29,16 +29,18 @@ # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -require 'biopieces' +require 'maasha/biopieces' + +ILLUMINA_BASE = 64 # Expading class Hash with possibly evil monkey patch. class Hash # Method to convert scores from ASCII encode string to # a semi-colon seperated string of decimal values. - def scores2dec!(base) + def scores2dec! if self.has_key? :SCORES self[:SCORES].gsub! /./ do |score| - score = (score.ord - base).to_s + ";" + score = (score.ord - ILLUMINA_BASE).to_s + ";" end self[:SCORES].chomp! ";" @@ -48,15 +50,12 @@ class Hash end end -casts = [] -casts << {:long=>'base', :short=>'b', :type=>'uint', :mandatory=>false, :default=>64, :allowed=>"33,59,64", :disallowed=>nil} - -bp = Biopieces.new +options = Biopieces.options_parse(ARGV) -options = bp.parse(ARGV, casts) - -bp.each_record do |record| - bp.puts record.scores2dec!(options[:base]) +Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| + input.each_record do |record| + output.puts record.scores2dec! + end end