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 to code for forthcoming sourmash release #467

Merged
merged 12 commits into from
Oct 15, 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
1 change: 0 additions & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
auto-update-conda: true
python-version: 3.12
channels: conda-forge,bioconda
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
mamba-version: "*"
Expand Down
32 changes: 16 additions & 16 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.4", features = ["extension-module", "anyhow"] }
rayon = "1.10.0"
serde = { version = "1.0.210", features = ["derive"] }
sourmash = { version = "0.15.2", features = ["branchwater"] }
sourmash = { version = "0.16.0", features = ["branchwater"] }
serde_json = "1.0.128"
niffler = "2.4.0"
log = "0.4.22"
Expand Down
1 change: 1 addition & 0 deletions src/manysearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ fn downsample_and_inflate_abundances(
// avoid downsampling if we can
if against_scaled != query_scaled {
let against_ds = against
.clone()
.downsample_scaled(query.scaled())
.expect("cannot downsample sketch");
(abunds, sum_weighted) = query.inflated_abundances(&against_ds)?;
Expand Down
4 changes: 2 additions & 2 deletions src/python/tests/test_fastmultigather.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,15 +959,15 @@ def test_indexed_full_output(runtmp):
# check a few columns
average_ani = set(df['average_containment_ani'])
avg_ani = set([round(x, 4) for x in average_ani])
assert avg_ani == {0.8502, 0.8584, 0.8602}
assert avg_ani == {0.9221, 0.9306, 0.9316} # @CTB check against py gather

f_unique_weighted = set(df['f_unique_weighted'])
f_unique_weighted = set([round(x, 4) for x in f_unique_weighted])
assert f_unique_weighted == {0.0063, 0.002, 0.0062}

unique_intersect_bp = set(df['unique_intersect_bp'])
unique_intersect_bp = set([round(x,4) for x in unique_intersect_bp])
assert unique_intersect_bp == {44000, 18000, 22000}
assert unique_intersect_bp == {4400000, 1800000, 2200000}


def test_nonindexed_full_vs_sourmash_gather(runtmp):
Expand Down
35 changes: 20 additions & 15 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,25 +476,30 @@ pub fn load_sketches_above_threshold(
let mut results = Vec::new();
// Load against into memory
if let Ok(against_sig) = against_collection.sig_from_record(against_record) {
if let Some(against_mh) = against_sig.minhash() {
// downsample against_mh, but keep original md5sum
let against_mh_ds = against_mh.downsample_scaled(query.scaled()).unwrap();
if let Ok(overlap) = against_mh_ds.count_common(query, false) {
if overlap >= threshold_hashes {
let result = PrefetchResult {
name: against_record.name().to_string(),
md5sum: against_mh.md5sum(),
minhash: against_mh_ds.clone(),
location: against_record.internal_location().to_string(),
overlap,
};
results.push(result);
}
let against_filename = against_sig.filename();
let against_mh: KmerMinHash = against_sig.try_into().expect("cannot get sketch");
let against_md5 = against_mh.md5sum(); // keep original md5sum

let against_mh_ds = against_mh
.downsample_scaled(query.scaled())
.expect("cannot downsample sketch");

// good? ok, store as candidate from prefetch.
if let Ok(overlap) = against_mh_ds.count_common(query, false) {
if overlap >= threshold_hashes {
let result = PrefetchResult {
name: against_record.name().to_string(),
md5sum: against_md5,
minhash: against_mh_ds,
location: against_record.internal_location().to_string(),
overlap,
};
results.push(result);
}
} else {
eprintln!(
"WARNING: no compatible sketches in path '{}'",
against_sig.filename()
against_filename
);
let _i = skipped_paths.fetch_add(1, atomic::Ordering::SeqCst);
}
Expand Down