# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
require 'inline'
-require 'maasha/math_aux'
# Class for describing a match between two sequences q and s.
class Match
self
end
- def redundant?(matches)
- # Speed-up with binary search
-
- matches.each do |m|
- if Math.dist_point2line(self.q_beg, self.s_beg, m.q_beg, m.s_beg, m.q_end, m.s_end) == 0
- return true
- end
- end
-
- false
- end
-
def to_s(seq = nil)
- s = "q: #{@q_beg}, s: #{@s_beg}, l: #{@length}, s: #{@score}"
+ s = "q: #{@q_beg} #{self.q_end} s: #{@s_beg} #{self.s_end} l: #{@length} s: #{@score}"
s << " #{seq[@q_beg .. q_end]}" if seq
s
end
def test_Match_to_s_returns_correctly
- assert_equal("q: 1, s: 1, l: 3, s: 0.0", @match.to_s)
- assert_equal("q: 1, s: 1, l: 3, s: 0.0 tcg", @match.to_s("atcg"))
+ assert_equal("q: 1 3 s: 1 3 l: 3 s: 0.0", @match.to_s)
+ assert_equal("q: 1 3 s: 1 3 l: 3 s: 0.0 tcg", @match.to_s("atcg"))
end
def test_Match_expand_to_left_end_returns_correctly
- assert_equal("q: 0, s: 0, l: 4, s: 0.0", @match.expand("atcg", "atcg", 0, 0, 3, 3).to_s)
+ assert_equal("q: 0 3 s: 0 3 l: 4 s: 0.0", @match.expand("atcg", "atcg", 0, 0, 3, 3).to_s)
end
def test_Match_expand_to_left_mismatch_returns_correctly
- assert_equal("q: 1, s: 1, l: 3, s: 0.0", @match.expand("gtcg", "atcg", 0, 0, 3, 3).to_s)
+ assert_equal("q: 1 3 s: 1 3 l: 3 s: 0.0", @match.expand("gtcg", "atcg", 0, 0, 3, 3).to_s)
end
def test_Match_expand_to_left_space_beg_returns_correctly
- assert_equal("q: 1, s: 1, l: 3, s: 0.0", @match.expand("atcg", "atcg", 1, 1, 3, 3).to_s)
+ assert_equal("q: 1 3 s: 1 3 l: 3 s: 0.0", @match.expand("atcg", "atcg", 1, 1, 3, 3).to_s)
end
def test_Match_expand_to_right_end_returns_correctly
- assert_equal("q: 0, s: 0, l: 5, s: 0.0", @match.expand("atcga", "atcga", 0, 0, 4, 4).to_s)
+ assert_equal("q: 0 4 s: 0 4 l: 5 s: 0.0", @match.expand("atcga", "atcga", 0, 0, 4, 4).to_s)
end
def test_Match_expand_to_right_mismatch_returns_correctly
- assert_equal("q: 1, s: 1, l: 3, s: 0.0", @match.expand("gtcga", "atcgg", 0, 0, 4, 4).to_s)
+ assert_equal("q: 1 3 s: 1 3 l: 3 s: 0.0", @match.expand("gtcga", "atcgg", 0, 0, 4, 4).to_s)
end
def test_Match_expand_to_right_space_end_returns_correctly
- assert_equal("q: 1, s: 1, l: 3, s: 0.0", @match.expand("atcga", "atcga", 1, 1, 3, 3).to_s)
+ assert_equal("q: 1 3 s: 1 3 l: 3 s: 0.0", @match.expand("atcga", "atcga", 1, 1, 3, 3).to_s)
end
end