Skip to main content

ConsensusBaseBuilder

Struct ConsensusBaseBuilder 

Source
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

Source

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 integration
  • error_rate_post_umi - Phred-scaled error rate after UMI integration
Source

pub fn reset(&mut self)

Resets the builder to process a new position

Source

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
Source

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).

Source

pub fn contributions(&self) -> u16

Returns the total number of contributing observations

This is the sum of observations across all four bases

Source

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

Source

pub fn all_observations(&self) -> [u16; 4]

Returns the observations for all bases as [A, C, G, T]

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.