Skip to content

fg-labs/minibwa-bindings

Repository files navigation

minibwa

CI crates.io docs.rs PyPI install with bioconda

Rust and Python bindings for minibwa.

  • minibwa-sys — low-level FFI over vendored minibwa C (compiled via build.rs).
  • minibwa — safe Rust wrapper exposing structured alignment Hits.
  • minibwa-py — Python bindings (pyo3 + maturin).

Quick start (Rust)

use minibwa::{Aligner, Index, Meth, Opts, ThreadBuf};

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, b"read1", b"ACGT...", Meth::None)? {
    println!("{:?} {}..{}", hit.contig, hit.ref_start, hit.ref_end);
}
# Ok::<(), minibwa::Error>(())

Quick start (Python)

import minibwa

# Build a BWA index from a FASTA file (one-time)
minibwa.Index.build("ref.fa", "ref")

# Load the index
idx = minibwa.Index.load("ref")

# Configure alignment options
opts = minibwa.Opts()

# Map a single read
hits = minibwa.map(idx, opts, "read1", "ACGT...")
for h in hits:
    print(h)

Licensing

MIT. The default build uses only Apache-2.0 libsais for indexing. The GPL bwtgen path is available behind the opt-in gpl-bwtgen feature, which changes the effective license to GPL.

Updating the vendored source

scripts/refresh-minibwa.sh <clean-commit> [local-source-path]

About

Rust and Python bindings for minibwa — Heng Li's lightweight bwa

Topics

Resources

License

Code of conduct

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors