Skip to main content

Crate minibwa

Crate minibwa 

Source
Expand description

Safe, idiomatic Rust bindings for minibwa — a fast short-read, adaptive, and Hi-C DNA aligner.

§Workflow

  1. Build an index once from a FASTA with Index::build_from_fasta.
  2. Load the index with Index::load; the loaded index is Send + Sync and can be shared across threads.
  3. Create an Aligner from &Index and &Opts — cheap, no allocation.
  4. Create one ThreadBuf per worker thread — holds the per-thread scratch arena; it is Send but not Sync.
  5. 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(),
    );
}

Structs§

Aligner
An aligner binding an index and options. Cheap to create; the index is shared.
CigarOp
A single CIGAR operation: a kind and a length.
Hit
A fully-owned alignment record converted from minibwa’s mb_hit_t.
Index
A loaded minibwa index. Immutable after load; safe to share across threads.
Opts
Alignment options, wrapping minibwa’s mb_opt_t.
ThreadBuf
Per-thread scratch buffer for alignment. One per worker thread.

Enums§

CigarKind
A CIGAR operation kind, mirroring minibwa’s MB_CIGAR_*.
Error
Errors returned by the safe minibwa API.
Meth
Methylation conversion type for a read, mapped to minibwa’s mt parameter.
Strand
Alignment strand.

Type Aliases§

Result
Result alias for this crate.