Skip to content

Commit

Permalink
pass lcp
Browse files Browse the repository at this point in the history
  • Loading branch information
tibvdm committed Aug 27, 2024
1 parent b6ff10d commit c0f9b72
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions sa-index/src/sa_searcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl Searcher {

// Calculate stricter starting bounds for the 3-mers
// TODO: IL equality
let bounds = searcher.search_bounds_no_cache(&kmer, (0, searcher.sa.len()));
let bounds = searcher.search_bounds_no_cache(&kmer, (0, searcher.sa.len()), 0);

if let BoundSearchResult::SearchResult((min_bound, max_bound)) = bounds {
let min_bound = if min_bound == 0 { 0 } else { min_bound - 1 };
Expand Down Expand Up @@ -245,10 +245,10 @@ impl Searcher {
/// The first argument is true if a match was found
/// The second argument indicates the index of the minimum or maximum bound for the match
/// (depending on `bound`)
fn binary_search_bound(&self, bound: BoundSearch, search_string: &[u8], start_bounds: (usize, usize)) -> (bool, usize) {
fn binary_search_bound(&self, bound: BoundSearch, search_string: &[u8], start_bounds: (usize, usize), start_lcp: usize) -> (bool, usize) {
let (mut left, mut right) = start_bounds;
let mut lcp_left: usize = 0;
let mut lcp_right: usize = 0;
let mut lcp_left: usize = start_lcp;
let mut lcp_right: usize = start_lcp;
let mut found = false;

// repeat until search window is minimum size OR we matched the whole search string last
Expand Down Expand Up @@ -309,7 +309,7 @@ impl Searcher {
// to find the bounds of the entire string
let max_mer_length = min(self.kmer_cache.k, search_string.len());
if let Some(bounds) = self.kmer_cache.get_kmer(&search_string[..max_mer_length]) {
return self.search_bounds_no_cache(search_string, bounds);
return self.search_bounds_no_cache(search_string, bounds, max_mer_length);
}

// TODO: following code might be better on Trembl
Expand All @@ -323,14 +323,14 @@ impl Searcher {
BoundSearchResult::NoMatches
}

pub fn search_bounds_no_cache(&self, search_string: &[u8], start_bounds: (usize, usize)) -> BoundSearchResult {
let (found_min, min_bound) = self.binary_search_bound(Minimum, search_string, start_bounds);
pub fn search_bounds_no_cache(&self, search_string: &[u8], start_bounds: (usize, usize), start_lcp: usize) -> BoundSearchResult {
let (found_min, min_bound) = self.binary_search_bound(Minimum, search_string, start_bounds, start_lcp);

if !found_min {
return BoundSearchResult::NoMatches;
}

let (_, max_bound) = self.binary_search_bound(Maximum, search_string, start_bounds);
let (_, max_bound) = self.binary_search_bound(Maximum, search_string, start_bounds, start_lcp);

BoundSearchResult::SearchResult((min_bound, max_bound + 1))
}
Expand Down
2 changes: 1 addition & 1 deletion sa-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ async fn start_server(args: Arguments) -> Result<(), Box<dyn Error>> {
let proteins = Proteins::try_from_database_file(&database_file)?;
eprintln!("✅ Successfully loaded the proteins!");

let searcher = Arc::new(SparseSearcher::new(suffix_array, proteins));
let searcher = Arc::new(SparseSearcher::new(suffix_array, proteins, 5));

// build our application with a route
let app = Router::new()
Expand Down

0 comments on commit c0f9b72

Please sign in to comment.