Struct TfmPvalue

Source
pub struct TfmPvalue<A: Alphabet, M: AsRef<ScoringMatrix<A>>> { /* private fields */ }
Expand description

The TFM-PVALUE algorithm.

Implementations§

Source§

impl<A: Alphabet, M: AsRef<ScoringMatrix<A>>> TfmPvalue<A, M>

Source

pub fn new(matrix: M) -> Self

Initialize the TFM-PVALUE algorithm for the given scoring matrix.

Source

pub fn as_inner(&self) -> &M

Return a reference to the wrapped matrix reference.

Source

pub fn into_inner(self) -> M

Extract the wrapped matrix reference.

Source

pub fn pvalue(&mut self, score: f64) -> f64

Compute the exact P-value for the given score.

§Caution

This method internally calls approximate_pvalue without bounds on the granularity, which may require a very large amount of memory for some scoring matrices. Use approximate_pvalue directly to add limits on the number of iterations or on the granularity.

Source

pub fn approximate_pvalue(&mut self, score: f64) -> PvaluesIterator<'_, A, M>

Iterate with decreasing granularity to compute an approximate p-value for a score.

§Example

Approximate a p-value for a score of 10.0 with a granularity of 0.001:

// Initialize the TFM-PVALUE algorithm for a lightmotif PSSM
let mut tfmp = lightmotif_tfmpvalue::TfmPvalue::new(&pssm);

// Compute the p-value for a score by iterating
// until granularity or convergence are reached.
let p_value = tfmp.approximate_pvalue(10.0)
    .find(|it| it.converged || it.granularity <= 0.001)
    .map(|it| *it.range.start())
    .unwrap();
Source

pub fn score(&mut self, pvalue: f64) -> f64

Compute the exact score associated with a given p-value.

§Caution

This method internally calls approximate_score without bounds on the granularity, which may require a very large amount of memory for some scoring matrices. Use approximate_score directly to add limits on the number of iterations or on the granularity.

Source

pub fn approximate_score(&mut self, pvalue: f64) -> ScoresIterator<'_, A, M>

Iterate with decreasing granularity to compute an approximate score for a p-value.

Trait Implementations§

Source§

impl<A: Debug + Alphabet, M: Debug + AsRef<ScoringMatrix<A>>> Debug for TfmPvalue<A, M>
where A::K: Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<A: Alphabet, M: AsRef<ScoringMatrix<A>>> From<M> for TfmPvalue<A, M>

Source§

fn from(matrix: M) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<A, M> Freeze for TfmPvalue<A, M>
where M: Freeze,

§

impl<A, M> RefUnwindSafe for TfmPvalue<A, M>

§

impl<A, M> Send for TfmPvalue<A, M>
where M: Send,

§

impl<A, M> Sync for TfmPvalue<A, M>
where M: Sync,

§

impl<A, M> Unpin for TfmPvalue<A, M>
where M: Unpin, <<A as Alphabet>::K as ArrayLength>::ArrayType<i64>: Unpin,

§

impl<A, M> UnwindSafe for TfmPvalue<A, M>

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> Same for T

Source§

type Output = T

Should always be Self
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.