Class: BioDSL::Levenshtein
- Inherits:
-
Object
- Object
- BioDSL::Levenshtein
- Extended by:
- Ambiguity
- Defined in:
- lib/BioDSL/seq/levenshtein.rb
Overview
Class to calculate the Levenshtein distance between two given strings. en.wikipedia.org/wiki/Levenshtein_distance
Constant Summary collapse
- BYTES_IN_INT =
4
Class Method Summary collapse
Methods included from Ambiguity
Class Method Details
.distance(s, t) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/BioDSL/seq/levenshtein.rb', line 37 def self.distance(s, t) return 0 if s == t return t.length if s.length == 0 return s.length if t.length == 0 v0 = "\0" * (t.length + 1) * BYTES_IN_INT v1 = "\0" * (t.length + 1) * BYTES_IN_INT new.levenshtein_distance_C(s, t, s.length, t.length, v0, v1) end |