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] catch TypeError in search w/abund vs flat at the command line #1928

Merged
merged 6 commits into from
Apr 15, 2022
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
16 changes: 10 additions & 6 deletions src/sourmash/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,16 @@ def search(args):

# do the actual search
if query.minhash.track_abundance:
results = search_databases_with_abund_query(query, databases,
threshold=args.threshold,
do_containment=args.containment,
do_max_containment=args.max_containment,
best_only=args.best_only,
unload_data=True)
try:
results = search_databases_with_abund_query(query, databases,
threshold=args.threshold,
do_containment=args.containment,
do_max_containment=args.max_containment,
best_only=args.best_only,
unload_data=True)
except TypeError as exc:
error(f"ERROR: {str(exc)}")
sys.exit(-1)
else:
results = search_databases_with_flat_query(query, databases,
threshold=args.threshold,
Expand Down
11 changes: 11 additions & 0 deletions tests/test_sourmash.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,17 @@ def test_search_ignore_abundance(runtmp):
assert out1 != out2


def test_search_abund_subj_flat(runtmp):
# test Index.search_abund requires an abund subj
sig47 = utils.get_test_data('track_abund/47.fa.sig')
sig63 = utils.get_test_data('63.fa.sig')

with pytest.raises(SourmashCommandFailed) as exc:
runtmp.sourmash('search', sig47, sig63)

assert "'search_abund' requires subject signatures with abundance information" in str(exc.value)


def test_search_abund_csv(runtmp):
# test search with abundance signatures, look at CSV output
testdata1 = utils.get_test_data('short.fa')
Expand Down