Skip to content

Commit

Permalink
improve checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tibvdm committed Aug 23, 2024
1 parent 26bca34 commit 681bfbd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sa-index/src/sa_searcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ impl Searcher {
search_string: &[u8],
max_matches: usize,
equate_il: bool,
tryptic: bool
tryptic_search: bool
) -> SearchAllSuffixesResult {
// If we perform a tryptic search, the last character of the search string should be R or K
if tryptic && search_string[search_string.len() - 1] != b'R' && search_string[search_string.len() - 1] != b'K' {
if tryptic_search && search_string[search_string.len() - 1] != b'R' && search_string[search_string.len() - 1] != b'K' {
return SearchAllSuffixesResult::NoMatches;
}

Expand Down Expand Up @@ -345,13 +345,14 @@ impl Searcher {
let checkable_suffix = suffix >= skip;

// Check for trypticity if a tryptic search is performed
let is_tryptic = tryptic && (
let is_tryptic = tryptic_search && (
self.proteins.input_string[suffix - skip - 1] == b'R' ||
self.proteins.input_string[suffix - skip - 1] == b'K' ||
self.proteins.input_string[suffix - skip - 1] == SEPARATION_CHARACTER
) && self.proteins.input_string[suffix - skip + search_string.len()] != b'P';

if !is_tryptic {
// If a tryptic search is performed and the suffix is not tryptic, we can skip
if tryptic_search && !is_tryptic {
sa_index += 1;
continue;
}
Expand Down

0 comments on commit 681bfbd

Please sign in to comment.