hirschberg 0.1.0

Generic implementation of Hirschberg's algorithm in Rust
Documentation
  • Coverage
  • 58.33%
    7 out of 12 items documented0 out of 8 items with examples
  • Size
  • Source code size: 12.56 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 605.87 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • nicksenger/hirschberg
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • nicksenger

Hirschberg

Hirschberg provides a generic implementation of Hirschberg's algorithm for finding the optimal global alignment of two sequences.

Example usage:

let a = "ACCCGGTCGTCAATTA".chars().collect::<Vec<_>>();
let b = "ACCACCGGTTGGTCCAATAA".chars().collect::<Vec<_>>();

let output = hirschberg::Config::default().compute(&a, &b);

let (aligned_a, aligned_b): (String, String) = output
    .alignment()
    .iter()
    .map(|(a, b)| (a.copied().unwrap_or('_'), b.copied().unwrap_or('_')))
    .unzip();

assert_eq!(output.score(), 8);
assert_eq!(
    [aligned_a, aligned_b],
    [
        "A_C_CCGG_TCGT_CAATTA".to_string(),
        "ACCACCGGTTGGTCCAATAA".to_string()
    ]
);

The match, mismatch and gap contribution to the score may be configured:

let a = "ACCCGGTCGTCAATTA".chars().collect::<Vec<_>>();
let b = "ACCACCGGTTGGTCCAATAA".chars().collect::<Vec<_>>();

let output = hirschberg::Config::default().mismatch_score(-4).compute(&a, &b);

let (aligned_a, aligned_b): (String, String) = output
    .alignment()
    .iter()
    .map(|(a, b)| (a.copied().unwrap_or('_'), b.copied().unwrap_or('_')))
    .unzip();

assert_eq!(output.score(), 6);
assert_eq!(
    [aligned_a, aligned_b],
    [
        "A_C_CCGG_T_CGT_CAAT_TA".to_string(),
        "ACCACCGGTTG_GTCCAATA_A".to_string()
    ]
);