Skip to main content

Crate rsomics_bam_consensus

Crate rsomics_bam_consensus 

Source
Expand description

FASTA consensus from a coordinate-sorted BAM — simple-mode port of samtools consensus -m simple.

Algorithm: bam_consensus.c calculate_consensus_simple + basic_fasta. Per reference position the engine accumulates a weighted score for each of A, C, G, T, and * (deletion); the weight per read is qual (or 1 when use_qual = false) times a compatibility factor from the seqi2A/C/G/T tables. The highest-scoring allele is the call; if the second-highest scores ≥ het_fract × score1 and ambig is on, the two are OR-ed into an IUPAC code. If total depth < min_depth or the call’s fraction of total score < call_fract, the call is N (or * for a gap).

Reference source: samtools/bam_consensus.c (MIT), tag 1.23.1.

Pileup engine: custom lightweight walker over coordinate-sorted BAM records, modelled on samtools/bam_plbuf.c / consensus_pileup.c. Avoids the per-column Vec allocations and HashMap overlap tracking of the generic rsomics-pileup crate, which adds enough overhead to lose the perf gate on a 150x WGS fixture. Single-threaded decode + CIGAR walk; all I/O is on the calling thread (readers are passed in from the caller).

Structs§

ConsensusOpts
ConsensusStats

Constants§

DEFAULT_EXCL_FLAGS
Default exclude-flags matching samtools consensus (UNMAP|SECONDARY|QCFAIL|DUP).

Functions§

consensus
Compute simple-mode FASTA consensus for every covered contig.
simple_call
bam_consensus.c::calculate_consensus_simple — returns ASCII base call and quality (0–100 as a percentage of total score).