Skip to content

Commit

Permalink
MRG: fix output for sketch ... --singleton (#3066)
Browse files Browse the repository at this point in the history
Fixes #2819

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
ctb and pre-commit-ci[bot] committed Mar 9, 2024
1 parent 9d60354 commit 60833b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/sourmash/command_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def _compute_individual(args, signatures_factory):

# make a new signature for each sequence?
if args.singleton:
n_calculated = 0
for n, record in enumerate(screed_iter):
sigs = signatures_factory()
try:
Expand All @@ -218,12 +219,13 @@ def _compute_individual(args, signatures_factory):
error(str(exc))
sys.exit(-1)

n_calculated += len(sigs)
set_sig_name(sigs, filename, name=record.name)
save_sigs_to_location(sigs, save_sigs)

notify(
"calculated {} signatures for {} sequences in {}",
len(save_sigs),
n_calculated,
n + 1,
filename,
)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_sourmash_sketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,7 @@ def test_do_sourmash_singleton_multiple_files_no_out_specified(runtmp):
"saved 2 signature(s) to 'shewanella.faa.sig'. Note: signature license is CC0."
in runtmp.last_result.err
)
assert "calculated 2 signatures for 2 sequences in" in runtmp.last_result.err

sig1 = runtmp.output("ecoli.faa.sig")
assert os.path.exists(sig1)
Expand Down Expand Up @@ -1441,6 +1442,8 @@ def test_do_sourmash_singleton_multiple_files_output(runtmp):
"saved 4 signature(s) to 'output.sig'. Note: signature license is CC0."
in runtmp.last_result.err
)
assert "calculated 2 signatures for 2 sequences in" in runtmp.last_result.err
assert "calculated 4 signatures for 2 sequences in" not in runtmp.last_result.err

sig1 = runtmp.output("output.sig")
assert os.path.exists(sig1)
Expand Down

0 comments on commit 60833b4

Please sign in to comment.