Crate parasail_rs

source ·
Expand description

§Introduction

This crate provides safe Rust bindings to Parasail, a SIMD pairwise sequence alignment library.

For unsafe bindings, see the libparasail-sys crate.

§Usage

§Examples

§Basic usage

use parasail_rs::{Aligner};

fn align() -> Result<(), Box<dyn std::error::Error>> {
    let query = b"ACGT";
    let reference = b"ACGT";
    let aligner = Aligner::new().build();
    let result = aligner.align(Some(query), reference)?;
    println!("Alignment Score: {}", result.get_score());

    Ok(())
}

§Using query profile

When using striped or scan vectorization strategies, some performance may be gained by reusing the query sequence. This can be done by creating a query profile and reusing it for multiple alignments.

use parasail_rs::{Matrix, Aligner, Profile};

fn align() -> Result<(), Box<dyn std::error::Error>> {

    let query = b"ACGT";
    let ref_1 = b"ACGTAACGTACA";
    let ref_2 = b"TGGCAAGGTAGA";

    let use_stats = true;
    let query_profile = Profile::new(query, use_stats, &Matrix::default())?;
    let aligner = Aligner::new()
        .profile(query_profile)
        .build();

    let result_1 = aligner.align(None, ref_1)?;
    let result_2 = aligner.align(None, ref_2)?;

    println!("Score 1: {}", result_1.get_score());
    println!("Score 2: {}", result_2.get_score());
    Ok(())
}

Structs§

Enums§