Skip to content

Commit

Permalink
set L to I
Browse files Browse the repository at this point in the history
  • Loading branch information
tibvdm committed Aug 27, 2024
1 parent cdb434d commit 031a609
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sa-index/src/bounds_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ impl BoundsCache {
for (i, byte) in alphabet.iter().enumerate() {
ascii_array[*byte as usize] = i;
}
ascii_array[b'L' as usize] = ascii_array[b'I' as usize]; // I and L are treated as the same amino acid

let mut powers_array = [0; 10];
for i in 0..10 {
Expand Down Expand Up @@ -97,12 +98,18 @@ impl BoundsCache {

#[cfg(test)]
mod tests {
use std::str::from_utf8;
use super::*;

#[test]
fn test_bounds_cache() {
let kmer_cache = BoundsCache::new("ACDEFGHIKLMNPQRSTVWY".to_string(), 5);

for i in 0..40 {
let kmer = kmer_cache.index_to_kmer(i);
eprintln!("{} -> {:?} -> {:?}", i, from_utf8(&kmer).unwrap(), kmer_cache.kmer_to_index(&kmer));
}

for i in 0..20_usize.pow(5) {
let kmer = kmer_cache.index_to_kmer(i);
assert_eq!(kmer_cache.kmer_to_index(&kmer), i);
Expand Down

0 comments on commit 031a609

Please sign in to comment.