require 'seq'
casts = []
+casts << {:long=>'min', :short=>'m', :type=>'uint', :mandatory=>false, :default=>0, :allowed=>nil, :disallowed=>nil}
casts << {:long=>'right_adaptor', :short=>'r', :type=>'string', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
casts << {:long=>'left_adaptor', :short=>'l', :type=>'string', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
casts << {:long=>'right_hamming_dist', :short=>'R', :type=>'uint', :mandatory=>false, :default=>25, :allowed=>nil, :disallowed=>nil}
if options[:right_adaptor]
pos_right = entry.adaptor_locate_right(options[:right_adaptor], options[:right_hamming_dist])
- entry.subseq!(0, pos_right) if pos_right >= 0
+ entry.subseq!(0, pos_right) if pos_right >= 0 and entry.length - pos_right >= options[:min]
record[:CLIP_ADAPTOR_RIGHT] = pos_right
else
record[:CLIP_ADAPTOR_RIGHT] = -1
if options[:left_adaptor]
pos_left = entry.adaptor_locate_left(options[:left_adaptor], options[:left_hamming_dist])
- entry.subseq!(pos_left + 1) if pos_left >= 0
+ entry.subseq!(pos_left + 1) if pos_left >= options[:min]
record[:CLIP_ADAPTOR_LEFT] = pos_left
else
record[:CLIP_ADAPTOR_LEFT] = -1
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-require 'bits'
+require 'amatch'
# Residue alphabets
DNA = %w[a t c g]
class SeqError < StandardError; end
class Seq
+ include Amatch
+
attr_accessor :seq_name, :seq, :type, :qual
# Method that generates all possible oligos of a specifed length and type.
len = self.length - pos
subseq = self.seq[pos ... pos + len].upcase
subadaptor = adaptor[0 ... len].upcase
+ m = Hamming.new(subseq)
+ hamming_dist = m.match(subadaptor)
hamming_max = (len * hd_percent * 0.01).round
- hamming_dist = String.hamming_dist(subseq, subadaptor)
return pos if hamming_dist <= hamming_max
pos += 1
len = pos
subseq = self.seq[0 ... len].upcase
subadaptor = adaptor[adaptor.length - len ... adaptor.length].upcase
+ m = Hamming.new(subseq)
+ hamming_dist = m.match(subadaptor)
hamming_max = (len * hd_percent * 0.01).round
- hamming_dist = String.hamming_dist(subseq, subadaptor)
pos -= 1