Module bio::alignment::pairwise [] [src]

Calculate alignments with a generalized variant of the Smith Waterman algorithm. Complexity: O(n * m) for strings of length m and n.

For quick computation of alignments and alignment scores there are 6 simple functions.

Example

use bio::alignment::pairwise::*;
use bio::alignment::AlignmentOperation::{Match, Subst};

let x = b"ACCGTGGAT";
let y = b"AAAAACCGTTGAT";
let score = |a: u8, b: u8| if a == b {1i32} else {-1i32};
let mut aligner = Aligner::with_capacity(x.len(), y.len(), -5, -1, &score);
let alignment = aligner.semiglobal(x, y);
assert_eq!(alignment.ystart, 4);
assert_eq!(alignment.xstart, 0);
assert_eq!(alignment.operations, [Match, Match, Match, Match, Match, Subst, Match, Match, Match]);

// If you don't known sizes of future sequences, you could
// use Aligner::new().
// Global alignment:
let mut aligner = Aligner::new(-5, -1, &score);
let x = b"ACCGTGGAT";
let y = b"AAAAACCGTTGAT";
let alignment = aligner.global(x, y);
assert_eq!(alignment.ystart, 0);
assert_eq!(alignment.xstart, 0);
assert_eq!(aligner.local(x, y).score, 7);

Structs

Aligner

A generalized Smith-Waterman aligner.