ProtMotif

Struct ProtMotif 

Source
pub struct ProtMotif {
    pub scores: Array2<f32>,
    pub min_score: f32,
    pub max_score: f32,
}
Expand description

Position-specific scoring matrix for protein sequences

Fields§

§scores: Array2<f32>

matrix holding weights at each position, indexed by [position, base]

§min_score: f32

sum of “worst” base at each position

§max_score: f32

sum of “best” base at each position

Implementations§

Source§

impl ProtMotif

Source

pub fn from_seqs(seqs: &[Vec<u8>], pseudos: Option<&[f32]>) -> Result<Self>

Returns a Motif representing the sequences provided.

§Arguments
  • seqs - sequences incorporated into motif
  • pseudos - array slice with a pseudocount for each monomer; defaults to pssm::DEF_PSEUDO for all if None is supplied

FIXME: pseudos should be an array of size MONO_CT, but that is currently impossible - see https://github.com/rust-lang/rust/issues/42863

Trait Implementations§

Source§

impl Clone for ProtMotif

Source§

fn clone(&self) -> ProtMotif

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 Debug for ProtMotif

Source§

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

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

impl Default for ProtMotif

Source§

fn default() -> ProtMotif

Returns the “default value” for a type. Read more
Source§

impl From<ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>> for ProtMotif

Return a ProtMotif wrapping an Array2 representing amino acid weights at each position. The dimensions and contents of this array are unchecked, and it is incumbent on the user to ensure the correct dimensions are used (ie, SEQ_LEN x 20), and no zeros appear in the array.

Source§

fn from(scores: Array2<f32>) -> Self

Converts to this type from the input type.
Source§

impl Motif for ProtMotif

Source§

const LK: [u8; 127]

Lookup table mapping monomer -> index
Source§

const MONOS: &'static [u8] = b"ARNDCEQGHILKMFPSTWYV"

All monomers, in order corresponding to lookup table
Source§

const MONO_CT: usize = 20usize

Monomer count - equal to length of MONOS
Source§

fn rev_lk(idx: usize) -> u8

Returns the monomer associated with the given index; the reverse of lookup. Returns INVALID_MONO if the index isn’t associated with a monomer. Read more
Source§

fn incr(mono: u8) -> Result<Array1<f32>>

Returns an array of length MONO_CT summing to 1. used to build a PSSM from sequences, potentially including ambiguous monomers (eg, M is either A or C) Read more
Source§

fn len(&self) -> usize

Returns the length of motif
Source§

fn get_scores(&self) -> &Array2<f32>

Accessor - returns scores matrix
Source§

fn get_min_score(&self) -> f32

Return sum of “worst” base at each position
Source§

fn get_max_score(&self) -> f32

Return sum of “best” base at each position
Source§

fn get_bits() -> f32

Returns information content of a single position. Used info_content method. FIXME: this should be replaced with a CTFE … or maybe just a constant
Source§

fn degenerate_consensus(&self) -> Vec<u8>

Returns a representation of the motif using ambiguous codes. Primarily useful for DNA motifs, where ambiguous codes are common (eg, ‘M’ for ‘A or C’); less so for proteins, where we represent any position without a dominant amino acid as an ‘X’
Source§

fn seqs_to_weights( seqs: &[Vec<u8>], _pseudos: Option<&[f32]>, ) -> Result<Array2<f32>>

Returns a weight matrix representing the sequences provided. This code is shared by implementations of from_seqs Read more
Source§

fn lookup(mono: u8) -> Result<usize>

Returns the index of given monomer in the scores matrix using the lookup table LK Read more
Source§

fn is_empty(&self) -> bool

Source§

fn raw_score<C, T>(&self, seq_it: T) -> Result<(usize, f32, Vec<f32>)>
where C: Borrow<u8>, T: IntoIterator<Item = C>,

Returns the un-normalized sum of matching bases, useful for comparing matches from motifs of different lengths Read more
Source§

fn score<C, T>(&self, seq_it: T) -> Result<ScoredPos>
where C: Borrow<u8>, T: IntoIterator<Item = C>,

Returns a ScoredPos struct representing the best match within the query sequence see: MATCHTM: a tool for searching transcription factor binding sites in DNA sequences Nucleic Acids Res. 2003 Jul 1; 31(13): 3576–3579 https://www.ncbi.nlm.nih.gov/pmc/articles/PMC169193/ Read more
Source§

fn info_content(&self) -> f32

Returns a float representing the information content of a motif; roughly the inverse of Shannon Entropy. Adapted from the information content described here: https://en.wikipedia.org/wiki/Sequence_logo#Logo_creation
Source§

impl PartialEq for ProtMotif

Source§

fn eq(&self, other: &ProtMotif) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ProtMotif

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

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,