require 'maasha/biopieces'
require 'maasha/seq'
-
-# 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!
- if self[:SCORES]
- self[:SCORES].gsub! /./ do |score|
- score = (score.ord - Seq::SCORE_BASE).to_s + ";"
- end
-
- self[:SCORES].chomp! ";"
- end
-
- self
- end
-end
+require 'narray'
options = Biopieces.options_parse(ARGV)
Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
input.each_record do |record|
- output.puts record.scores2dec!
+ if record[:SCORES]
+ na = NArray.to_na(record[:SCORES], "byte")
+ na -= Seq::SCORE_BASE
+ record[:SCORES] = na.to_a.join("; ")
+ end
+
+ output.puts record
end
end