bwa-mem2-rs
Safe Rust API for bwa-mem2 alignment with packed-BAM output and caller-owned parallelism.
What it does
- Aligns read pairs via bwa-mem2, returning packed BAM records per the BAM spec — ready to stream to any BGZF writer.
- Blocking, reentrant, single-threaded per call. The caller drives all parallelism via rayon, tokio
spawn_blocking, or any work-stealing pool. - Phase-split API:
seed_batch→extend_batchlets pools balance seeding and extension independently.align_batchis a thin wrapper over the pair. - Runs on x86_64 (AVX2 default) and aarch64 (Apple Silicon + AWS Graviton).
Quick start
use ;
let idx = load?; // bwa-mem2 index prefix
let mut opts = new?;
opts.set_pe;
let pairs = vec!;
let = align_batch?;
for record in aln.iter
Parallelism
use *;
use *;
use Arc;
let idx = new;
let mut opts = new?;
opts.set_pe;
let results: = batches
.par_iter
.map
.?;
The crate never spawns threads. Every public function blocks its calling thread and is safe to call concurrently on the same BwaIndex.
Index
Build it with the upstream CLI:
bwa-mem2 index <prefix>.fa
Index building is intentionally out of scope here.
See also
- Workspace README — architecture, tests, contribution.
bwa-mem2-rs-cli— thinbwa-rsCLI binary over this crate.bwa-mem2-sys— the unsafe FFI crate this one wraps.
License
MIT.