fn fasta_to_count_table(fasta: &str) -> HashMap<String, u32> {
    let mut counter: Vec<u32> = vec![0; 1048576];
    'outer: for subsection in fasta.split("\n>") {
        let subbytes = subsection.as_bytes();
        let it = subbytes.iter();
        let mut it = it.skip_while(|&&x| x != b'\n');
        it.next(); //eat \n after >header
        let mut it = it.filter(|&&x| x != b'\n');
        let mut dicodon: u32 = 0;
        for (basea,baseb,basec) in it.tuples() {
            counter[dicodon as usize] += 1; // don't worry about the start, we don't count N dicodons
            let eba = encode_base(*basea);
            let ebb = encode_base(*baseb);
            let ebc = encode_base(*basec);
            dicodon = (dicodon << 3 | eba) & 0b111111111111111111;
            dicodon = (dicodon << 3 | ebb) & 0b111111111111111111;
            dicodon = (dicodon << 3 | ebc) & 0b111111111111111111;
            // 6 bases..
        }
        counter[dicodon as usize] += 1;

    }
    let mut dicodon_counter = HashMap::<String, u32>::new();
    for (enc_dicodon, count) in counter.into_iter().enumerate() {
        if count > 0 {
            let sdicodon = decode_dicodon(enc_dicodon as u32);
            if !sdicodon.contains('N') {
                dicodon_counter.insert(sdicodon, count);
            }
        }
    }
    dicodon_counter
}
/// count dicodons, in 6*3 bit encoding,
/// internally using a 1MB vector
/// convert to lower case string for output
count dicodons, in 6*3 bit encoding,
internally using a 1MB vector
convert to lower case string for output
count dicodons in 6 * 3 bit encoding internally using a 1MB vector convert to lower case string for output
fn fasta_to_count_table(fasta: &str) -> HashMap<String, u32> {
    let mut counter: Vec<u32> = vec![0; 1048576];
    'outer: for subsection in fasta.split("\n>") {
        let subbytes = subsection.as_bytes();
        let it = subbytes.iter();
        let mut it = it.skip_while(|&&x| x != b'\n');
        it.next(); //eat \n after >header
        let mut it = it.filter(|&&x| x != b'\n');
        let mut dicodon: u32 = 0;
        for (basea,baseb,basec) in it.tuples() {
            counter[dicodon as usize] += 1; // don't worry about the start, we don't count N dicodons
            let eba = encode_base(*basea);
            let ebb = encode_base(*baseb);
            let ebc = encode_base(*basec);
            dicodon = (dicodon << 3 | eba) & 0b111111111111111111;
            dicodon = (dicodon << 3 | ebb) & 0b111111111111111111;
            dicodon = (dicodon << 3 | ebc) & 0b111111111111111111;
            // 6 bases..
        }
        counter[dicodon as usize] += 1;
    }
    let mut dicodon_counter = HashMap::<String, u32>::new();
    for (enc_dicodon, count) in counter.into_iter().enumerate() {
        if count > 0 {
            let sdicodon = decode_dicodon(enc_dicodon as u32);
            if !sdicodon.contains('N') {
                dicodon_counter.insert(sdicodon, count);
            }
        }
    }
    dicodon_counter
}
fn fasta_to_count_table ( fasta : & str ) -> HashMap < String , u32 > { let mut counter : Vec < u32 > = vec ! [ 0 1048576 ] ; ' outer : for subsection in fasta . split ( " \n " ) { let subbytes = subsection . as_bytes ( ) ; let it = subbytes . iter ( ) ; let mut it = it . skip_while ( | & & x | x != b'\n' ) ; it . next ( ) ; //eat \n after >header let mut it = it . filter ( | & & x | x != b'\n' ) ; let mut dicodon : u32 = 0 ; for ( basea , baseb , basec ) in it . tuples ( ) { counter [ dicodon as usize ] += 1 ; // don't worry about the start, we don't count N dicodons let eba = encode_base ( * basea ) ; let ebb = encode_base ( * baseb ) ; let ebc = encode_base ( * basec ) ; dicodon = ( dicodon << 3 | eba ) & 0b111111111111111111 ; dicodon = ( dicodon << 3 | ebb ) & 0b111111111111111111 ; dicodon = ( dicodon << 3 | ebc ) & 0b111111111111111111 ; // 6 bases.. } counter [ dicodon as usize ] += 1 ; } let mut dicodon_counter = HashMap :: < String , u32 > :: new ( ) ; for ( enc_dicodon , count ) in counter . into_iter ( ) . enumerate ( ) { if count > 0 { let sdicodon = decode_dicodon ( enc_dicodon as u32 ) ; if ! sdicodon . contains ( 'N' ) { dicodon_counter . insert ( sdicodon , count ) ; } } } dicodon_counter }
count dicodons, in 6*3 bit encoding,
internally using a 1MB vector
convert to lower case string for output
count dicodons in 6 * 3 bit encoding internally using a 1MB vector convert to lower case string for output
fasta
&str