pub fn whole_seq_stats(dna: &str) -> Stats {
        // chars uses quite a bit more memory here
        // but sequences should never be super long...
        let map = dna.chars().fold(HashMap::new(), |mut map, c| {
            *map.entry(c).or_insert(0) += 1;
            map
        });
        let g_counts = map.get(&'G').unwrap_or(&0);
        let c_counts = map.get(&'C').unwrap_or(&0);
        let a_counts = map.get(&'A').unwrap_or(&0);
        let t_counts = map.get(&'T').unwrap_or(&0);

        Stats {
            gc_percent: (g_counts + c_counts) as f64 / dna.len() as f64,
            at_percent: (a_counts + t_counts) as f64 / dna.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,
        }
    }
// simply calculate basic statistics on &str dna
simply calculate basic statistics on &str dna
simply calculate basic statistics on &str dna
pub fn whole_seq_stats(dna: &str) -> Stats {
        // chars uses quite a bit more memory here
        // but sequences should never be super long...
        let map = dna.chars().fold(HashMap::new(), |mut map, c| {
            *map.entry(c).or_insert(0) += 1;
            map
        });
        let g_counts = map.get(&'G').unwrap_or(&0);
        let c_counts = map.get(&'C').unwrap_or(&0);
        let a_counts = map.get(&'A').unwrap_or(&0);
        let t_counts = map.get(&'T').unwrap_or(&0);
        Stats {
            gc_percent: (g_counts + c_counts) as f64 / dna.len() as f64,
            at_percent: (a_counts + t_counts) as f64 / dna.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 whole_seq_stats ( dna : & str ) -> Stats { // chars uses quite a bit more memory here // but sequences should never be super long... let map = dna . chars ( ) . fold ( HashMap :: new ( ) , | mut map , c | { * map . entry ( c ) . or_insert ( 0 ) += 1 ; map } ) ; let g_counts = map . get ( & 'G' ) . unwrap_or ( & 0 ) ; let c_counts = map . get ( & 'C' ) . unwrap_or ( & 0 ) ; let a_counts = map . get ( & 'A' ) . unwrap_or ( & 0 ) ; let t_counts = map . get ( & 'T' ) . unwrap_or ( & 0 ) ; Stats { gc_percent : ( g_counts + c_counts ) as f64 / dna . len ( ) as f64 , at_percent : ( a_counts + t_counts ) as f64 / dna . 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 , } }
simply calculate basic statistics on &str dna
simply calculate basic statistics on &str dna
dna
&str
dna
&str