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

MRG: update sourmash to r0.17.0 #500

Merged
merged 3 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
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
31 changes: 21 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ crate-type = ["cdylib"]
pyo3 = { version = "0.22.5", features = ["extension-module", "anyhow"] }
rayon = "1.10.0"
serde = { version = "1.0.213", features = ["derive"] }
sourmash = { version = "0.16.0", features = ["branchwater"] }
sourmash = { version = "0.17.0", features = ["branchwater"] }
serde_json = "1.0.132"
niffler = "2.4.0"
log = "0.4.22"
Expand Down
2 changes: 1 addition & 1 deletion src/fastgather.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub fn fastgather(
query_name,
query_filename,
query_mh,
scaled as u64,
scaled as u32,
matchlist,
threshold_hashes,
gather_output,
Expand Down
13 changes: 6 additions & 7 deletions src/fastmultigather.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::utils::{
pub fn fastmultigather(
query_filepath: String,
against_filepath: String,
threshold_bp: usize,
threshold_bp: u32,
scaled: Option<usize>,
selection: Selection,
allow_failed_sigpaths: bool,
Expand All @@ -47,9 +47,9 @@ pub fn fastmultigather(
)?;

let scaled = match scaled {
Some(s) => s,
Some(s) => s as u32,
None => {
let scaled = *query_collection.max_scaled().expect("no records!?") as usize;
let scaled = *query_collection.max_scaled().expect("no records!?");
eprintln!(
"Setting scaled={} based on max scaled in query collection",
scaled
Expand All @@ -64,12 +64,11 @@ pub fn fastmultigather(
let threshold_hashes: u64 = {
let x = threshold_bp / scaled;
if x > 0 {
x
x as u64
} else {
1
}
}
.try_into()?;
};

println!("threshold overlap: {} {}", threshold_hashes, threshold_bp);

Expand Down Expand Up @@ -164,7 +163,7 @@ pub fn fastmultigather(
query_name,
query_filename,
query_mh,
scaled as u64,
scaled,
matchlist,
threshold_hashes,
Some(gather_output),
Expand Down
10 changes: 5 additions & 5 deletions src/fastmultigather_rocksdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn fastmultigather_rocksdb(
queries_file: String,
index: PathBuf,
selection: Selection,
threshold_bp: usize,
threshold_bp: u32,
output: Option<String>,
allow_failed_sigpaths: bool,
) -> Result<(), Box<dyn std::error::Error>> {
Expand Down Expand Up @@ -55,7 +55,7 @@ pub fn fastmultigather_rocksdb(
let send = query_collection
.par_iter()
.filter_map(|(coll, _idx, record)| {
let threshold = threshold_bp / selection.scaled()? as usize;
let threshold = threshold_bp / selection.scaled()?;
let ksize = selection.ksize()?;

// query downsampling happens here
Expand All @@ -76,7 +76,7 @@ pub fn fastmultigather_rocksdb(
counter,
query_colors,
hash_to_color,
threshold,
threshold as usize,
&query_mh,
Some(selection.clone()),
);
Expand Down Expand Up @@ -104,8 +104,8 @@ pub fn fastmultigather_rocksdb(
query_bp: query_mh.n_unique_kmers() as usize,
ksize: ksize as usize,
moltype: query_mh.hash_function().to_string(),
scaled: query_mh.scaled() as usize,
query_n_hashes: query_mh.size(),
scaled: query_mh.scaled(),
query_n_hashes: query_mh.size() as u64,
query_abundance: query_mh.track_abundance(),
query_containment_ani: match_.query_containment_ani(),
match_containment_ani: match_.match_containment_ani(),
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fn do_fastmultigather(
query_filenames,
againstfile_path,
selection.clone(),
threshold_bp,
threshold_bp as u32,
output_path,
allow_failed_sigpaths,
) {
Expand All @@ -157,7 +157,7 @@ fn do_fastmultigather(
match fastmultigather::fastmultigather(
query_filenames,
siglist_path,
threshold_bp,
threshold_bp as u32,
scaled,
selection,
allow_failed_sigpaths,
Expand Down
12 changes: 6 additions & 6 deletions src/manysearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ fn downsample_and_inflate_abundances(
against: &KmerMinHash,
) -> Result<
(
Option<usize>,
Option<usize>,
Option<u64>,
Option<u64>,
Option<f64>,
Option<f64>,
Option<f64>,
Expand All @@ -218,7 +218,7 @@ fn downsample_and_inflate_abundances(

let abunds: Vec<u64>;
let sum_weighted: u64;
let sum_all_abunds: usize;
let sum_all_abunds: u64;

// avoid downsampling if we can
if against_scaled != query_scaled {
Expand All @@ -227,10 +227,10 @@ fn downsample_and_inflate_abundances(
.downsample_scaled(query.scaled())
.expect("cannot downsample sketch");
(abunds, sum_weighted) = query.inflated_abundances(&against_ds)?;
sum_all_abunds = against_ds.sum_abunds() as usize;
sum_all_abunds = against_ds.sum_abunds();
} else {
(abunds, sum_weighted) = query.inflated_abundances(against)?;
sum_all_abunds = against.sum_abunds() as usize;
sum_all_abunds = against.sum_abunds();
}

let average_abund = sum_weighted as f64 / abunds.len() as f64;
Expand All @@ -239,7 +239,7 @@ fn downsample_and_inflate_abundances(

Ok((
Some(sum_all_abunds),
Some(sum_weighted as usize),
Some(sum_weighted),
Some(average_abund),
Some(median_abund),
Some(std_abund),
Expand Down
Loading
Loading