From: martinahansen Date: Fri, 29 Nov 2013 20:14:12 +0000 (+0000) Subject: fixed bug in find_orfs X-Git-Url: https://git.donarmstrong.com/?p=biopieces.git;a=commitdiff_plain;h=801e0b96e0ac9ffb02f193e8432c021c92cbf78c fixed bug in find_orfs git-svn-id: http://biopieces.googlecode.com/svn/trunk@2260 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/code_ruby/lib/maasha/seq.rb b/code_ruby/lib/maasha/seq.rb index b291803..5e4d1b5 100644 --- a/code_ruby/lib/maasha/seq.rb +++ b/code_ruby/lib/maasha/seq.rb @@ -669,22 +669,24 @@ class Seq regex_start = Regexp.new(start_codons.join('|'), true) regex_stop = Regexp.new(stop_codons.join('|'), true) - while pos_beg and pos_beg < self.length - size_min - if pos_beg = self.seq.index(regex_start, pos_beg) - if pos_end = self.seq.index(regex_stop, pos_beg) - length = (pos_end - pos_beg) + 3 + while pos_beg = self.seq.index(regex_start, pos_beg) + pos_end = pos_beg + 3 + + while pos_end = self.seq.index(regex_stop, pos_end) + length = (pos_end - pos_beg) + 3 - if (length % 3) == 0 - if size_min <= length and length <= size_max - subseq = self.subseq(pos_beg, length) + if (length % 3) == 0 + if size_min <= length and length <= size_max + subseq = self.subseq(pos_beg, length) - orfs << [subseq, pos_beg, pos_end + 3] - end + orfs << [subseq, pos_beg, pos_end + 3] end end - pos_beg += 1 + pos_end += 1 end + + pos_beg += 1 end if pick_longest