--- /dev/null
+DEBUG = false
+
+module PatFind
+ @@pos = 0
+
+ def scan(pattern, max_mis = 0, max_ins = 0, max_del = 0)
+ if block_given?
+ while m = match(pattern, @@pos, max_mis, max_ins, max_del)
+ @@pos += m.pos + 1
+
+ yield m
+ end
+ else
+ matches = []
+
+ while m = match(pattern, @@pos, max_mis, max_ins, max_del)
+ matches << m
+
+ @@pos += m.pos + 1
+ end
+
+ return matches
+ end
+ end
+
+ def match(pattern, pos = 0, max_mis = 0, max_ins = 0, max_del = 0)
+ if pattern[0] == self.seq[pos]
+ puts self.seq[pos]
+ end
+
+ block_given? ? (yield m) : (return m)
+ end
+end
+
+# Class containing match information for use with PatFind.
+class Match
+ attr_accessor :pattern, :pos, :length, :mismatches, :insertions, :deletions
+
+ def initialize(pattern, pos, mismatches, insertions, deletions)
+ @pattern = pattern
+ @pos = pos
+ @length = pattern.length
+ @mismatches = mismatches
+ @insertions = insertions
+ @deletions = deletions
+ end
+end
+