Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch genome name lookup to hashmap #40

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/skani.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use skani::params::*;
use skani::screen;

use concurrent_queue::ConcurrentQueue;
use std::collections::HashMap;

pub struct SkaniPreclusterer {
pub threshold: f32,
Expand Down Expand Up @@ -44,6 +45,7 @@ fn precluster_skani(
.collect::<Vec<String>>();
// Note that sketches is now shuffled!
let sketches = &file_io::fastx_to_sketches(&fasta_strings, &sketch_params, true);
let genome_indices: HashMap<_, _> = genome_fasta_paths.into_iter().enumerate().map(|(index, element)| (element, index)).collect();

// Right now implemented by parallel collection into a queue, and then
// reprocessed into a BTreeMap. Could potentially be made more efficient by
Expand Down Expand Up @@ -78,14 +80,8 @@ fn precluster_skani(
let query_name = sketches[j].file_name.clone();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wwood I tried using String::from(ref_sketch.file_name) and String::from(ref_sketch.file_name.clone()) but get the same error. Did you mean somewhere else?


debug!("Pushing ANI result for {} and {}", ref_name, query_name);
let ref_index = genome_fasta_paths
.iter()
.position(|&r| r == ref_name)
.unwrap();
let query_index = genome_fasta_paths
.iter()
.position(|&r| r == query_name)
.unwrap();
let ref_index = genome_indices.get(&ref_name).unwrap();
let query_index = genome_indices.get(&query_name).unwrap();
if ani >= threshold {
queue
.push((ref_index, query_index, ani))
Expand All @@ -98,7 +94,7 @@ fn precluster_skani(

let mut to_return = SortedPairGenomeDistanceCache::new();
while let Ok((i, j, ani)) = queue.pop() {
to_return.insert((i, j), Some(ani));
to_return.insert((*i, *j), Some(ani));
}
debug!("Finished skani.");

Expand Down
Loading