]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/lib/maasha/align/match.rb
polished pairwise alignment code
[biopieces.git] / code_ruby / lib / maasha / align / match.rb
index d6a800865544267218eb7c4eb5343535f367573c..784a2d12f2a1916adb8a216c821769683697a19a 100644 (file)
@@ -23,6 +23,7 @@
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 require 'inline'
+require 'maasha/math_aux'
 
 # Class for describing a match between two sequences q and s.
 class Match
@@ -57,6 +58,18 @@ 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 << " #{seq[@q_beg .. q_end]}" if seq