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: avoid compressing sig files in directory output twice #2752

Merged
merged 2 commits into from
Sep 7, 2023
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
2 changes: 1 addition & 1 deletion src/sourmash/save_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def add(self, ss):
break
i += 1

with gzip.open(outname, "wb") as fp:
with open(outname, "wb") as fp:
sigmod.save_signatures([ss], fp, compression=1)


Expand Down
24 changes: 24 additions & 0 deletions tests/test_sourmash_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import csv
import argparse
import shutil
import json

import sourmash_tst_utils as utils
import sourmash
Expand Down Expand Up @@ -363,6 +364,29 @@ def test_save_signatures_to_location_1_dirout(runtmp):
assert len(saved) == 2


def test_save_signatures_to_location_1_dirout_bug_2751(runtmp):
# check for 2x compressed sig files
sig2 = utils.get_test_data('2.fa.sig')
ss2 = sourmash.load_one_signature(sig2, ksize=31)
sig47 = utils.get_test_data('47.fa.sig')
ss47 = sourmash.load_one_signature(sig47, ksize=31)

outloc = runtmp.output('sigout/')
with sourmash_args.SaveSignaturesToLocation(outloc) as save_sig:
print(save_sig)
save_sig.add(ss2)
save_sig.add(ss47)

assert os.path.isdir(outloc)
print(os.listdir(outloc))

outloc2 = runtmp.output('sigout/09a08691ce52952152f0e866a59f6261.sig.gz')
with gzip.open(outloc2, "r") as fp:
data = fp.read()
print(data)
_ = json.loads(data)


def test_save_signatures_to_location_1_dirout_duplicate(runtmp):
# save to sigout/ (directory)
sig2 = utils.get_test_data('2.fa.sig')
Expand Down