fn seqs_to_weights(seqs: &[Vec<u8>], _pseudos: Option<&[f32]>) -> Result<Array2<f32>> {
        let p1 = vec![DEF_PSEUDO; Self::MONO_CT];
        let pseudos = match _pseudos {
            Some(p2) => p2,
            None => p1.as_slice(),
        };

        if pseudos.len() != Self::MONO_CT {
            return Err(Error::InvalidPseudos {
                expected: Self::MONO_CT as u8,
                received: pseudos.len() as u8,
            });
        }

        if seqs.is_empty() {
            return Err(Error::EmptyMotif);
        }

        let seqlen = seqs[0].len();
        let mut counts = Array2::zeros((seqlen, Self::MONO_CT));
        for i in 0..seqlen {
            for base in 0..Self::MONO_CT {
                counts[[i, base]] = pseudos[base];
            }
        }

        for seq in seqs.iter() {
            if seq.len() != seqlen {
                return Err(Error::InconsistentLen);
            }

            for (idx, base) in seq.iter().enumerate() {
                match Self::lookup(*base) {
                    Err(e) => return Err(e),
                    Ok(pos) => counts[[idx, pos]] += 1.0,
                }
            }
        }
        Ok(counts)
    }
/// Returns a weight matrix representing the sequences provided.
/// This code is shared by implementations of `from_seqs`
/// # Arguments
/// * `seqs` - sequences incorporated into motif
/// * `pseudos` - array slice with a pseudocount for each monomer;
///    defaults to DEF_PSEUDO for all if None is supplied
///
/// FIXME: pseudos should be an array of size MONO_CT, but that
/// is currently unsupported
Returns a weight matrix representing the sequences provided.
This code is shared by implementations of `from_seqs`
Returns a weight matrix representing the sequences provided . This code is shared by implementations of ` from_seqs `
fn seqs_to_weights(seqs: &[Vec<u8>], _pseudos: Option<&[f32]>) -> Result<Array2<f32>> {
        let p1 = vec![DEF_PSEUDO; Self::MONO_CT];
        let pseudos = match _pseudos {
            Some(p2) => p2,
            None => p1.as_slice(),
        };
        if pseudos.len() != Self::MONO_CT {
            return Err(Error::InvalidPseudos {
                expected: Self::MONO_CT as u8,
                received: pseudos.len() as u8,
            });
        }
        if seqs.is_empty() {
            return Err(Error::EmptyMotif);
        }
        let seqlen = seqs[0].len();
        let mut counts = Array2::zeros((seqlen, Self::MONO_CT));
        for i in 0..seqlen {
            for base in 0..Self::MONO_CT {
                counts[[i, base]] = pseudos[base];
            }
        }
        for seq in seqs.iter() {
            if seq.len() != seqlen {
                return Err(Error::InconsistentLen);
            }
            for (idx, base) in seq.iter().enumerate() {
                match Self::lookup(*base) {
                    Err(e) => return Err(e),
                    Ok(pos) => counts[[idx, pos]] += 1.0,
                }
            }
        }
        Ok(counts)
    }
fn seqs_to_weights ( seqs : & [ Vec < u8 > ] , _pseudos : Option < & [ f32 ] > ) -> Result < Array2 < f32 > > { let p1 = vec ! [ DEF_PSEUDO Self MONO_CT ] ; let pseudos = match _pseudos { Some ( p2 ) => p2 , None => p1 . as_slice ( ) , } ; if pseudos . len ( ) != Self :: MONO_CT { return Err ( Error :: InvalidPseudos { expected : Self :: MONO_CT as u8 , received : pseudos . len ( ) as u8 , } ) ; } if seqs . is_empty ( ) { return Err ( Error :: EmptyMotif ) ; } let seqlen = seqs [ 0 ] . len ( ) ; let mut counts = Array2 :: zeros ( ( seqlen , Self :: MONO_CT ) ) ; for i in 0 .. seqlen { for base in 0 .. Self :: MONO_CT { counts [ [ i , base ] ] = pseudos [ base ] ; } } for seq in seqs . iter ( ) { if seq . len ( ) != seqlen { return Err ( Error :: InconsistentLen ) ; } for ( idx , base ) in seq . iter ( ) . enumerate ( ) { match Self :: lookup ( * base ) { Err ( e ) => return Err ( e ) , Ok ( pos ) => counts [ [ idx , pos ] ] += 1.0 , } } } Ok ( counts ) }
Returns a weight matrix representing the sequences provided.
Returns a weight matrix representing the sequences provided .
seqs
&[Vec<u8>]
_pseudos
Option<&[f32]>
seqs
&[Vec<u8>]
_pseudos
Option<&[f32]>