#bioinformatics #alignment #wfa

libwfa2

Bindings to the C implementation of WFA2-lib

1 unstable release

0.1.1 Sep 19, 2024
0.1.0 Sep 18, 2024

#120 in Biology

Download history 95/week @ 2024-09-12 175/week @ 2024-09-19 17/week @ 2024-09-26 3/week @ 2024-10-03

290 downloads per month

MIT license

4MB
14K SLoC

C 12K SLoC // 0.3% comments Python 540 SLoC // 0.2% comments Rust 403 SLoC // 0.1% comments C++ 400 SLoC // 0.3% comments Shell 195 SLoC // 0.3% comments Scheme 43 SLoC // 0.4% comments

libwfa2

Rust bindings for the wavefront algorithm (WFA2-lib, https://github.com/smarco/WFA2-lib). This is inspired by the rust crate libwfa (crate, github).

Example

Basic usage of the library.

use libwfa2::affine_wavefront::AffineWavefronts;

pub fn main() {
    let aligner = AffineWavefronts::default();

    // pattern means query
    let pattern = b"TCTTTACTCGCGCGTTGGAGAAATACAATAGT";

    // Text means reference
    let text = b"TCTATACTGCGCGTTTGGAGAAATAAAATAGT";

    aligner.align(pattern, text);

    println!("Pattern: {}", String::from_utf8_lossy(pattern));
    println!("Text:    {}\n", String::from_utf8_lossy(text));

    println!("Score: {}", aligner.score());
    println!("Cigar: {}", String::from_utf8_lossy(aligner.cigar()));
}

Setting heuristics

use libwfa2::affine_wavefront::{AffineWavefronts, HeuristicStrategy};

pub fn main() {
    println!("Example2\n");

    let mut aligner = AffineWavefronts::default();

    aligner.set_heuristic(&HeuristicStrategy::BandedStatic { band_min_k: -1, band_max_k: 1 });

    // pattern means query
    let pattern = b"TCTTTACTCGCGCGTTGGAGAAATACAATAGT";

    // Text means reference
    let text = b"TCTATACTGCGCGTTTGGAGAAATAAAATAGT";

    let _status = aligner.align(pattern, text);

    println!("Pattern: {}", String::from_utf8_lossy(pattern));
    println!("Text:    {}\n", String::from_utf8_lossy(text));

    println!("Score: {}", aligner.score());
    println!("Cigar: {}", String::from_utf8_lossy(aligner.cigar()));
}

No runtime deps