# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-# Soft mask sequences in the stream based on Solexa/Illumina/Phred type quality scores.
+# Soft mask sequences in the stream based on quality scores.
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
require 'biopieces'
+ILLUMINA_BASE = 64
+
# Expading class Hash with possibly evil monkey patch.
class Hash
# Soft masks sequence residues where the corresponding quality score
# is below a given cutoff.
- def mask_seq!(cutoff, base)
+ def mask_seq!(cutoff)
if self.has_key? :SEQ and self.has_key? :SCORES
seq = self[:SEQ].upcase
scores = self[:SCORES]
i = 0
scores.each_char do |score|
- seq[i] = seq[i].downcase if score.ord - base < cutoff
+ seq[i] = seq[i].downcase if score.ord - ILLUMINA_BASE < cutoff
i += 1
end
end
casts = []
-casts << {:long=>'cutoff', :short=>'c', :type=>'int', :mandatory=>false, :default=>20, :allowed=>nil, :disallowed=>nil}
-casts << {:long=>'base', :short=>'b', :type=>'uint', :mandatory=>false, :default=>64, :allowed=>"33,59,64", :disallowed=>nil}
+casts << {:long=>'cutoff', :short=>'c', :type=>'int', :mandatory=>false, :default=>20, :allowed=>nil, :disallowed=>nil}
bp = Biopieces.new
options = bp.parse(ARGV, casts)
bp.each_record do |record|
- bp.puts record.mask_seq!(options[:cutoff], options[:base])
+ bp.puts record.mask_seq!(options[:cutoff])
end