pub struct ConsensusBaseBuilder { /* private fields */ }Expand description
Builder for calling consensus at a single base position
Accumulates observations (base + quality) and uses a likelihood model to call the consensus base and quality.
Uses Kahan summation algorithm with SIMD vectorization to maintain numeric stability when accumulating log-likelihoods across many observations. The 4 DNA bases map perfectly to f64x4 (256-bit AVX2), enabling parallel computation of all 4 likelihoods.
Implementations§
Source§impl ConsensusBaseBuilder
impl ConsensusBaseBuilder
Sourcepub fn new(
error_rate_pre_umi: u8,
error_rate_post_umi: u8,
) -> ConsensusBaseBuilder
pub fn new( error_rate_pre_umi: u8, error_rate_post_umi: u8, ) -> ConsensusBaseBuilder
Creates a new consensus base builder
§Arguments
error_rate_pre_umi- Phred-scaled error rate prior to UMI integrationerror_rate_post_umi- Phred-scaled error rate after UMI integration
Sourcepub fn add(&mut self, base: u8, qual: u8)
pub fn add(&mut self, base: u8, qual: u8)
Adds an observation (base + quality) to the consensus
Uses SIMD-vectorized Kahan summation for numeric stability when accumulating log-likelihoods. All 4 base likelihoods are updated in parallel using f64x4.
§Arguments
base- The observed base (A, C, G, T, or N)qual- The base quality score
Sourcepub fn call(&self) -> (u8, u8)
pub fn call(&self) -> (u8, u8)
Calls the consensus base and quality
Returns (consensus_base, consensus_quality)
Returns (N, 0) if no observations or multiple equally likely bases
§Panics
Panics if there are observations but no maximum likelihood base is found (should not occur in practice since we check for ties).
Sourcepub fn contributions(&self) -> u16
pub fn contributions(&self) -> u16
Returns the total number of contributing observations
This is the sum of observations across all four bases
Sourcepub fn observations_for_base(&self, base: u8) -> u16
pub fn observations_for_base(&self, base: u8) -> u16
Returns the number of observations for a specific base
§Arguments
base- The base to query (A, C, G, or T)
Returns 0 for invalid bases
Sourcepub fn all_observations(&self) -> [u16; 4]
pub fn all_observations(&self) -> [u16; 4]
Returns the observations for all bases as [A, C, G, T]
Auto Trait Implementations§
impl Freeze for ConsensusBaseBuilder
impl RefUnwindSafe for ConsensusBaseBuilder
impl Send for ConsensusBaseBuilder
impl Sync for ConsensusBaseBuilder
impl Unpin for ConsensusBaseBuilder
impl UnsafeUnpin for ConsensusBaseBuilder
impl UnwindSafe for ConsensusBaseBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more