Module bio::alignment::distance
[−]
[src]
Various subroutines for computing a distance between sequences. Complexity: O(n) for strings of length n for the Hamming distance; O(n * m) for strings of length n and m for the Levenshtein (or edit) distance.
Example
use bio::alignment::distance::*; let x = b"GTCTGCATGCG"; let y = b"TTTAGCTAGCG"; // GTCTGCATGCG // | || ||| // TTTAGCTAGCG match hamming(x, y) { Ok(s) => println!("Score is: {}", s), // Score is 5 Err(e) => println!("Error: {}", e), // No error in this example } let x = b"ACCGTGGAT"; let y = b"AAAAACCGTTGAT"; // ----ACCGTGGAT // ||||| ||| // AAAAACCGTTGAT let l_score = levenshtein(x, y); // Score is 5 assert_eq!(l_score, 5);
Functions
hamming |
Compute the Hamming distance between two strings with |
levenshtein |
Compute the Levenshtein (or Edit) distance between two strings with |