Skip to content

Commit

Permalink
fix tests to only use characters of peptide alphabet
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonVandeVyver committed Sep 11, 2024
1 parent fb6e77a commit b0a804d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions sa-index/src/sa_searcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ mod tests {
}

fn get_example_proteins() -> Proteins {
let input_string = "AI-BLACVAA-AC-KCRLZ$";
let input_string = "AI-CLACVAA-AC-KCRLY$";
let text = ProteinText::from_string(input_string);

Proteins {
Expand Down Expand Up @@ -561,7 +561,7 @@ mod tests {
assert_eq!(bounds_res, BoundSearchResult::SearchResult((13, 16)));

// search bounds 'RIZ' with equal I and L
let bounds_res = searcher.search_bounds(&[b'R', b'I', b'Z']);
let bounds_res = searcher.search_bounds(&[b'R', b'I', b'Y']);
assert_eq!(bounds_res, BoundSearchResult::SearchResult((17, 18)));
}

Expand All @@ -574,18 +574,18 @@ mod tests {
let searcher = Searcher::new(sa, proteins, Box::new(suffix_index_to_protein));

// search bounds 'RIZ' with equal I and L
let found_suffixes = searcher.search_matching_suffixes(&[b'R', b'I', b'Z'], usize::MAX, true);
let found_suffixes = searcher.search_matching_suffixes(&[b'R', b'I', b'Y'], usize::MAX, true);
assert_eq!(found_suffixes, SearchAllSuffixesResult::SearchResult(vec![16]));

// search bounds 'RIZ' without equal I and L
let found_suffixes = searcher.search_matching_suffixes(&[b'R', b'I', b'Z'], usize::MAX, false);
let found_suffixes = searcher.search_matching_suffixes(&[b'R', b'I', b'Y'], usize::MAX, false);
assert_eq!(found_suffixes, SearchAllSuffixesResult::NoMatches);
}

// test edge case where an I or L is the first index in the sparse SA.
#[test]
fn test_l_first_index_in_sa() {
let input_string = "LMOXZ$";
let input_string = "LMPYY$";
let text = ProteinText::from_string(input_string);

let proteins = Proteins {
Expand Down
4 changes: 2 additions & 2 deletions text-compression/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl ProteinText {

fn create_char_to_5bit_hashmap() -> HashMap<u8, u8> {
let mut hashmap = HashMap::<u8, u8>::new();
for (i, c) in "ACDEFGHIKLMNPQRSTVWY-".chars().enumerate() {
for (i, c) in "ACDEFGHIKLMNPQRSTVWY-$".chars().enumerate() {
hashmap.insert(c as u8, i as u8);
}

Expand All @@ -25,7 +25,7 @@ impl ProteinText {

fn create_bit5_to_char() -> Vec<u8> {
let mut vec = Vec::<u8>::new();
for c in "ACDEFGHIKLMNPQRSTVWY-".chars() {
for c in "ACDEFGHIKLMNPQRSTVWY-$".chars() {
vec.push(c as u8);
}
vec
Expand Down

0 comments on commit b0a804d

Please sign in to comment.