Skip to main content

Pssm

Struct Pssm 

Source
pub struct Pssm<const N: usize> { /* private fields */ }
Expand description

A Position-Specific Scoring Matrix (PSSM) with a fixed alphabet size.

Scores are stored as log-odds ratios relative to background frequencies.

Implementations§

Source§

impl<const N: usize> Pssm<N>

Source

pub fn from_counts( counts: &[[f64; N]], pseudocount: f64, background: [f64; N], ) -> Result<Self>

Build a PSSM from a count matrix.

Each row of counts represents one position; each column is a symbol. A pseudocount is added to every cell before converting to frequencies. Scores are computed as ln(freq / background).

§Errors

Returns an error if counts is empty or any background entry is zero.

Source

pub fn len(&self) -> usize

Number of positions in the motif.

Source

pub fn is_empty(&self) -> bool

Returns true if the PSSM has zero positions.

Source

pub fn score( &self, seq: &[u8], mapping: &dyn Fn(u8) -> Option<usize>, ) -> Result<f64>

Score a sequence window against this PSSM.

seq must be exactly [self.len()] bytes. The mapping function converts each byte to an alphabet index in 0..N.

§Errors

Returns an error if seq.len() != self.len() or if mapping returns None for any byte.

Source

pub fn scan( &self, seq: &[u8], threshold: f64, mapping: &dyn Fn(u8) -> Option<usize>, ) -> Vec<(usize, f64)>

Slide the PSSM across seq and return all hits at or above threshold.

Returns (position, score) pairs. Positions with unmapped characters are silently skipped.

Source

pub fn information_content(&self) -> Vec<f64>

Information content (bits) at each position.

IC_j = sum_c freq_c * log2(freq_c / bg_c) where frequencies are recovered from the stored log-odds scores.

Source

pub fn max_score(&self) -> f64

Maximum possible score (sum of the best symbol at each position).

Source

pub fn min_score(&self) -> f64

Minimum possible score (sum of the worst symbol at each position).

Trait Implementations§

Source§

impl<const N: usize> Clone for Pssm<N>

Source§

fn clone(&self) -> Pssm<N>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize> Debug for Pssm<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<const N: usize> Freeze for Pssm<N>

§

impl<const N: usize> RefUnwindSafe for Pssm<N>

§

impl<const N: usize> Send for Pssm<N>

§

impl<const N: usize> Sync for Pssm<N>

§

impl<const N: usize> Unpin for Pssm<N>

§

impl<const N: usize> UnsafeUnpin for Pssm<N>

§

impl<const N: usize> UnwindSafe for Pssm<N>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.