pub fn four_fold_site_stats(codons: Vec<&[u8]>) -> FourFoldStats {
        let codon_vec = codons
            .into_iter()
            .map(str::from_utf8)
            .collect::<Result<Vec<&str>, _>>()
            .unwrap_or(vec![]);

        let mut g_counts = 0;
        let mut c_counts = 0;
        let mut a_counts = 0;
        let mut t_counts = 0;

        for codon in codon_vec.iter() {
            let split_tuple = codon.split_at(2);

            match split_tuple.1 {
                "G" => g_counts += 1,
                "g" => g_counts += 1,
                "C" => c_counts += 1,
                "c" => c_counts += 1,
                "A" => a_counts += 1,
                "a" => a_counts += 1,
                "T" => t_counts += 1,
                "t" => t_counts += 1,
                _ => (),
            }
        }
        FourFoldStats {
            gc_percent: (g_counts + c_counts) as f64 / codon_vec.len() as f64,
            at_percent: (a_counts + t_counts) as f64 / codon_vec.len() as f64,
            gc_skew: (g_counts - c_counts) as f64 / (g_counts + c_counts) as f64,
            at_skew: (a_counts - t_counts) as f64 / (a_counts + t_counts) as f64,
        }
    }
// take the vector of degenerate codons and calculate stats.
take the vector of degenerate codons and calculate stats.
take the vector of degenerate codons and calculate stats .
pub fn four_fold_site_stats(codons: Vec<&[u8]>) -> FourFoldStats {
        let codon_vec = codons
            .into_iter()
            .map(str::from_utf8)
            .collect::<Result<Vec<&str>, _>>()
            .unwrap_or(vec![]);
        let mut g_counts = 0;
        let mut c_counts = 0;
        let mut a_counts = 0;
        let mut t_counts = 0;
        for codon in codon_vec.iter() {
            let split_tuple = codon.split_at(2);
            match split_tuple.1 {
                "G" => g_counts += 1,
                "g" => g_counts += 1,
                "C" => c_counts += 1,
                "c" => c_counts += 1,
                "A" => a_counts += 1,
                "a" => a_counts += 1,
                "T" => t_counts += 1,
                "t" => t_counts += 1,
                _ => (),
            }
        }
        FourFoldStats {
            gc_percent: (g_counts + c_counts) as f64 / codon_vec.len() as f64,
            at_percent: (a_counts + t_counts) as f64 / codon_vec.len() as f64,
            gc_skew: (g_counts - c_counts) as f64 / (g_counts + c_counts) as f64,
            at_skew: (a_counts - t_counts) as f64 / (a_counts + t_counts) as f64,
        }
    }
pub fn four_fold_site_stats ( codons : Vec < & [ u8 ] > ) -> FourFoldStats { let codon_vec = codons . into_iter ( ) . map ( str :: from_utf8 ) . collect :: < Result < Vec < & str > , _ > > ( ) . unwrap_or ( vec ! [ ] ) ; let mut g_counts = 0 ; let mut c_counts = 0 ; let mut a_counts = 0 ; let mut t_counts = 0 ; for codon in codon_vec . iter ( ) { let split_tuple = codon . split_at ( 2 ) ; match split_tuple . 1 { " " => g_counts += 1 , " " => g_counts += 1 , " " => c_counts += 1 , " " => c_counts += 1 , " " => a_counts += 1 , " " => a_counts += 1 , " " => t_counts += 1 , " " => t_counts += 1 , _ => ( ) , } } FourFoldStats { gc_percent : ( g_counts + c_counts ) as f64 / codon_vec . len ( ) as f64 , at_percent : ( a_counts + t_counts ) as f64 / codon_vec . len ( ) as f64 , gc_skew : ( g_counts - c_counts ) as f64 / ( g_counts + c_counts ) as f64 , at_skew : ( a_counts - t_counts ) as f64 / ( a_counts + t_counts ) as f64 , } }
take the vector of degenerate codons and calculate stats.
take the vector of degenerate codons and calculate stats .
codons
Vec<&[u8]>
codons
Vec<&[u8]>