]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/scores_to_dec
fixed minor bug in grab for exact_in where no key would give undef warning
[biopieces.git] / bp_bin / scores_to_dec
index 9c94454be65b7028b20f1f2113fb086b37db1e2a..56381a5522b023ecbde2ae9a7d3fece2aef7088c 100755 (executable)
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
-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