require 'biopieces'
require 'seq'
+VERBOSE = true
+
def disambiguate(adaptor)
adaptor_disamb = adaptor.dup
adaptor_disamb.gsub!('U', 'T')
raise SeqError, "Edit distance percent out of range #{ed_percent}" unless (0 .. 100).include? ed_percent
if pos < 0
- pos = self.length - pos # pos offset from the right end
+ pos = self.length + pos # pos offset from the right end
end
- if match = adaptor_find_simple(adaptor_disamb, pos)
- return match
- elsif match = adaptor_find_complex(adaptor, pos, ed_percent)
- return match
- elsif match = adaptor_partial_find_complex(adaptor, ed_percent)
- return match
+ if pos < self.length
+ if match = adaptor_find_simple(adaptor_disamb, pos)
+ return match
+ elsif match = adaptor_find_complex(adaptor, pos, ed_percent)
+ return match
+ elsif match = adaptor_partial_find_complex(adaptor, pos, ed_percent)
+ return match
+ end
end
end
# Method to find part of an adaptor at the right end of a sequence taking
# into account ambiguity codes, mismatches, insertions, and deletions.
- def adaptor_partial_find_complex(adaptor, ed_percent)
- adaptor = adaptor[0 ... -1]
+ def adaptor_partial_find_complex(adaptor, pos, ed_percent)
+ if pos > self.length - adaptor.length
+ adaptor = adaptor[0 ... self.length - pos]
+ else
+ adaptor = adaptor[0 ... adaptor.length - 1]
- pos = self.len - adaptor.length
+ pos = self.length - adaptor.length
+ end
+
+ #puts self.seq if VERBOSE
while adaptor.length > 0
+ #puts (" " * pos) + adaptor if VERBOSE
+
ed_max = (adaptor.length * ed_percent * 0.01).round
if ed_max == 0
adaptor = adaptor[0 ... -1]
- pos = self.len - adaptor.length
+ pos += 1
end
end
end