Class: BioDSL::Hamming
- Inherits:
-
Object
- Object
- BioDSL::Hamming
- Extended by:
- Ambiguity
- Defined in:
- lib/BioDSL/hamming.rb
Overview
Class for calculating Hamming distance.
Class Method Summary collapse
-
.check_strings(str1, str2) ⇒ Object
Check that string lengths are equal.
-
.distance(str1, str2, options = {}) ⇒ Object
Class method for calculating the Hamming distance between two given strings optionally allowing for IUPAC ambiguity codes.
Methods included from Ambiguity
Class Method Details
.check_strings(str1, str2) ⇒ Object
Check that string lengths are equal.
62 63 64 65 66 |
# File 'lib/BioDSL/hamming.rb', line 62 def self.check_strings(str1, str2) return if str1.length == str2.length fail HammingError, "bad string lengths: #{str1.length} != #{str2.length}" end |
.distance(str1, str2, options = {}) ⇒ Object
Class method for calculating the Hamming distance between two given strings optionally allowing for IUPAC ambiguity codes.
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/BioDSL/hamming.rb', line 44 def self.distance(str1, str2, = {}) check_strings(str1, str2) hd = new if [:ambiguity] hd.hamming_distance_ambiguity_C(str1, str2, str1.length) else hd.hamming_distance_C(str1, str2, str1.length) end end |