# Method to check if a path is complete and a match was found.
def match_found?(path)
if path.mismatches <= @max_mismatches and path.insertions <= @max_insertions and path.deletions <= @max_deletions
- if path.matches + path.mismatches + path.insertions >= @pattern.length
- true
+ if path.matches == @pattern.length - path.insertions - path.mismatches
+ return true
end
end
end
# Method that returns a new Match object for a matching path
def mismatch
- path_mismatche = self.dup
- path_mismatche.length += 1
- path_mismatche.mismatches += 1
- path_mismatche.seq_index += 1
- path_mismatche.pattern_index += 1
- path_mismatche
+ path_mismatch = self.dup
+ path_mismatch.length += 1
+ path_mismatch.mismatches += 1
+ path_mismatch.seq_index += 1
+ path_mismatch.pattern_index += 1
+ path_mismatch
end
# Method that returns a new Match object for a insertion path
def test_PatternMatcher_match_with_two_insertion_with_two_allowed_returns_ok
assert_equal(2, @entry.match("aCCtcg", pos = 0, mismatches = 0, insertions = 2).insertions)
assert_equal(2, @entry.match("CCatcg", pos = 0, mismatches = 0, insertions = 2).insertions)
- assert_equal(2, @entry.match("atcgCC", pos = 0, mismatches = 0, insertions = 2).insertions)
- assert_equal(2, @entry.match("CatcgC", pos = 0, mismatches = 0, insertions = 2).insertions)
end
def test_PatternMatcher_match_with_one_deletion_with_zero_allowed_returns_nil
assert_equal(1, @entry.match("atg", pos = 0, mismatchses = 0, insertions = 0, deletions = 1).deletions)
end
+ # atcg
+ # axdd
+ # g x
def test_PatternMatcher_match_with_two_deletion_with_one_allowed_returns_nil
assert_nil(@entry.match("ag", pos = 0, mismatchses = 0, insertions = 0, deletions = 1))
end
assert_equal(2, entry.match("agtcg", pos = 0, mismatchses = 0, insertions = 1, deletions = 2).deletions)
end
+ # --atcg
+ # ||
+ # cgat
+ def test_PatternMatcher_match_overlapping_with_left_end_returns_ok
+ assert_equal(2, @entry.match("cgat", pos = 0, mismatches = 0, insertions = 2, deletions = 0).insertions)
+ end
+
def test_Pattern_Matcher_scan_locates_three_patterns_ok
entry = Seq.new("test", "ataacgagctagctagctagctgactac")
assert_equal(3, entry.scan("tag").count)