Safe, idiomatic Rust bindings for minibwa — a fast short-read, adaptive, and Hi-C DNA aligner.
Workflow
- Build an index once from a FASTA with [
Index::build_from_fasta]. - Load the index with [
Index::load]; the loaded index isSend + Syncand can be shared across threads. - Create an [
Aligner] from&Indexand&Opts— cheap, no allocation. - Create one [
ThreadBuf] per worker thread — holds the per-thread scratch arena; it isSendbut notSync. - Call [
Aligner::map] or [Aligner::map_pair] to align reads and get owned [Hit] vectors.
Methylation support
Pass [Meth::C2T] or [Meth::G2A] to [Aligner::map] for single-read
bisulfite alignment, or enable [Opts::set_methylation] together with
[Aligner::map_pair] for paired-end bisulfite alignment.
Paired-end support
Use [Aligner::map_pair] for paired-end alignment. Insert-size parameters
can be tuned with [Opts::set_pe_insert_size].
Parallelism
Thread-level parallelism is caller-owned: create one [ThreadBuf] per thread
and call [Aligner::map] / [Aligner::map_pair] concurrently. The shared
[Index] is read-only during mapping.
Example
use minibwa::{Index, Opts, Aligner, ThreadBuf, Meth};
Index::build_from_fasta("ref.fa", "ref", false, 4)?;
let idx = Index::load("ref", false)?;
let opts = Opts::new();
let aligner = Aligner::new(&idx, &opts);
let mut buf = ThreadBuf::new();
for hit in aligner.map(&mut buf, "read1", b"ACGT...", Meth::None)? {
println!(
"{} {}..{} {}",
hit.contig.as_deref().unwrap_or("*"),
hit.ref_start,
hit.ref_end,
hit.cigar_string(),
);
}
# Ok::<(), minibwa::Error>(())