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] adjust output of gather to indicate weighted/unweighted results #1819

Merged
merged 2 commits into from
Feb 2, 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
5 changes: 4 additions & 1 deletion src/sourmash/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,10 @@ def gather(args):
print_results(f'(truncated gather because --num-results={args.num_results})')

p_covered = (1 - weighted_missed) * 100
print_results(f'the recovered matches hit {p_covered:.1f}% of the query')
if is_abundance:
print_results(f'the recovered matches hit {p_covered:.1f}% of the abundance-weighted query')
else:
print_results(f'the recovered matches hit {p_covered:.1f}% of the query (unweighted)')
print_results('')
if gather_iter.scaled != query.minhash.scaled:
print_results(f'WARNING: final scaled was {gather_iter.scaled}, vs query scaled of {query.minhash.scaled}')
Expand Down
4 changes: 4 additions & 0 deletions tests/test_sourmash.py
Original file line number Diff line number Diff line change
Expand Up @@ -4034,6 +4034,8 @@ def test_gather_abund_1_1(runtmp, linear_gather, prefetch_gather):
assert '50.4% 80.0% 1.9 tests/test-data/genome-s11.fa.gz' in out
assert 'genome-s12.fa.gz' not in out

assert "the recovered matches hit 100.0% of the abundance-weighted query" in out


def test_gather_abund_10_1(runtmp, prefetch_gather, linear_gather):
c = runtmp
Expand Down Expand Up @@ -4069,6 +4071,7 @@ def test_gather_abund_10_1(runtmp, prefetch_gather, linear_gather):
assert '91.0% 100.0% 14.5 tests/test-data/genome-s10.fa.gz' in out
assert '9.0% 80.0% 1.9 tests/test-data/genome-s11.fa.gz' in out
assert 'genome-s12.fa.gz' not in out
assert "the recovered matches hit 100.0% of the abundance-weighted query" in out

# check the calculations behind the above output by looking into
# the CSV.
Expand Down Expand Up @@ -4136,6 +4139,7 @@ def test_gather_abund_10_1_ignore_abundance(runtmp, linear_gather, prefetch_gath

print(out)
print(err)
assert "the recovered matches hit 100.0% of the query (unweighted)" in out

# when we project s10x10-s11 (r2+r3), 10:1 abundance,
# onto s10 and s11 genomes with gather --ignore-abundance, we get:
Expand Down