From 234df70530db680bf0134e3e3f06fbf2896f0e80 Mon Sep 17 00:00:00 2001 From: "C. Titus Brown" Date: Mon, 7 Mar 2022 14:10:23 -0800 Subject: [PATCH] [MRG] Fix `sourmash prefetch` for multiple ksizes in database (#1866) * add test that breaks prefetch b/c of multiple ksizes * fix prefetch --- src/sourmash/commands.py | 1 + tests/test_prefetch.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/sourmash/commands.py b/src/sourmash/commands.py index 16bd1e9672..c29ad99b3a 100644 --- a/src/sourmash/commands.py +++ b/src/sourmash/commands.py @@ -1176,6 +1176,7 @@ def prefetch(args): sys.exit(-1) query.minhash = query_mh + ksize = query_mh.ksize # set up CSV output, write headers, etc. csvout_fp = None diff --git a/tests/test_prefetch.py b/tests/test_prefetch.py index 84ec48a12c..9de8363d06 100644 --- a/tests/test_prefetch.py +++ b/tests/test_prefetch.py @@ -37,6 +37,21 @@ def test_prefetch_basic(runtmp, linear_gather): assert "a total of 0 query hashes remain unmatched." in c.last_result.err +def test_prefetch_select_query_ksize(runtmp, linear_gather): + # test prefetch where query and subject db both have multiple ksizes + c = runtmp + + ss = utils.get_test_data('GCF_000005845.2_ASM584v2_genomic.fna.gz.sig') + + c.run_sourmash('prefetch', ss, ss, linear_gather) + print(c.last_result.status) + print(c.last_result.out) + print(c.last_result.err) + + assert c.last_result.status == 0 + assert 'of 4476 distinct query hashes, 4476 were found in matches above threshold.' in c.last_result.err + + def test_prefetch_query_abund(runtmp, linear_gather): c = runtmp