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] Fix sourmash prefetch for multiple ksizes in database #1866

Merged
merged 4 commits into from
Mar 7, 2022

Conversation

ctb
Copy link
Contributor

@ctb ctb commented Mar 5, 2022

When poking around with MAGsearch, I found a problem where sourmash prefetch did not properly apply the ksize learned from an input query to a database via select, which resulted in an incompatible MinHash objects error (see below).

This PR fixes this by selecting the database using the ksize from the query, and adds a test for same.

error message

% sourmash prefetch tests/test-data/GCF_000005845.2_ASM584v2_genomic.fna.gz.sig tests/test-data/GCF_000005845.2_ASM584v2_genomic.fna.gz.sig

== This is sourmash version 4.2.5.dev19+g3a6028fb.d20220217. ==
== Please cite Brown and Irber (2016), doi:10.21105/joss.00027. ==

WARNING: no output(s) specified! Nothing will be saved from this prefetch!
selecting default query k=31.
loaded query: GCF_000005845... (k=31, DNA)
all sketches will be downsampled to scaled=1000
loading signatures from 'tests/test-data/GCF_000005845.2_ASM584v2_genomic.fna.gz.sig'
Traceback (most recent call last):
  File "/Users/t/miniconda3/envs/py37/bin/sourmash", line 33, in <module>
    sys.exit(load_entry_point('sourmash', 'console_scripts', 'sourmash')())
  File "/Users/t/dev/sourmash/src/sourmash/__main__.py", line 13, in main
    return mainmethod(args)
  File "/Users/t/dev/sourmash/src/sourmash/cli/prefetch.py", line 69, in main
    return sourmash.commands.prefetch(args)
  File "/Users/t/dev/sourmash/src/sourmash/commands.py", line 1222, in prefetch
    for result in prefetch_database(query, db, args.threshold_bp):
  File "/Users/t/dev/sourmash/src/sourmash/search.py", line 523, in prefetch_database
    for result in database.prefetch(query, threshold_bp):
  File "/Users/t/dev/sourmash/src/sourmash/index/__init__.py", line 255, in prefetch
    for sr in self.find(search_fn, query, **kwargs):
  File "/Users/t/dev/sourmash/src/sourmash/index/__init__.py", line 172, in find
    shared_size, total_size = query_mh.intersection_and_union_size(subj_mh)
  File "/Users/t/dev/sourmash/src/sourmash/minhash.py", line 571, in intersection_and_union_size
    raise TypeError("incompatible MinHash objects")
TypeError: incompatible MinHash objects

@codecov
Copy link

codecov bot commented Mar 5, 2022

Codecov Report

Merging #1866 (882f080) into latest (186fc1f) will increase coverage by 7.97%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           latest    #1866      +/-   ##
==========================================
+ Coverage   82.37%   90.34%   +7.97%     
==========================================
  Files         119       89      -30     
  Lines       12934     8733    -4201     
  Branches     1727     1727              
==========================================
- Hits        10654     7890    -2764     
+ Misses       2016      579    -1437     
  Partials      264      264              
Flag Coverage Δ
python 90.34% <100.00%> (+<0.01%) ⬆️
rust ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/sourmash/commands.py 88.33% <100.00%> (+0.01%) ⬆️
src/core/src/lib.rs
src/core/src/ffi/minhash.rs
src/core/src/ffi/hyperloglog.rs
src/core/src/ffi/index/revindex.rs
src/core/src/storage.rs
src/core/src/sketch/hyperloglog/mod.rs
src/core/src/sketch/hyperloglog/estimators.rs
src/core/src/index/sbt/mod.rs
src/core/src/encodings.rs
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 186fc1f...882f080. Read the comment docs.

@ctb
Copy link
Contributor Author

ctb commented Mar 5, 2022

@sourmash-bio/devs ready for review and merge!

Copy link
Contributor

@bluegenes bluegenes left a comment

Choose a reason for hiding this comment

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

lgtm

@ctb ctb merged commit 234df70 into latest Mar 7, 2022
@ctb ctb deleted the fix/prefetch_ksize branch March 7, 2022 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants