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: add support for -E/--extension to sig split #2712

Merged
merged 1 commit into from
Aug 12, 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
4 changes: 4 additions & 0 deletions src/sourmash/cli/sig/split.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
'--from-file',
help='a text file containing a list of files to load signatures from'
)
subparser.add_argument(

Check warning on line 62 in src/sourmash/cli/sig/split.py

View check run for this annotation

Codecov / codecov/patch

src/sourmash/cli/sig/split.py#L62

Added line #L62 was not covered by tests
'-E', '--extension', type=str, default='.sig',
help="write files with this extension ('.sig' by default)"
)
add_ksize_arg(subparser)
add_moltype_args(subparser)
add_picklist_args(subparser)
Expand Down
4 changes: 2 additions & 2 deletions src/sourmash/sig/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@
_extend_signatures_with_from_file(args)

output_names = set()
output_scaled_template = '{md5sum}.k={ksize}.scaled={scaled}.{moltype}.dup={dup}.{basename}.sig'
output_num_template = '{md5sum}.k={ksize}.num={num}.{moltype}.dup={dup}.{basename}.sig'
output_scaled_template = '{md5sum}.k={ksize}.scaled={scaled}.{moltype}.dup={dup}.{basename}' + args.extension
output_num_template = '{md5sum}.k={ksize}.num={num}.{moltype}.dup={dup}.{basename}' + args.extension

Check warning on line 143 in src/sourmash/sig/__main__.py

View check run for this annotation

Codecov / codecov/patch

src/sourmash/sig/__main__.py#L142-L143

Added lines #L142 - L143 were not covered by tests

if args.output_dir:
if not os.path.exists(args.output_dir):
Expand Down
36 changes: 36 additions & 0 deletions tests/test_cmd_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,42 @@ def test_sig_split_3_multisig(c):
assert os.path.exists(c.output(filename))


def test_sig_split_3_multisig_sig_gz(runtmp):
# split 47 and 47+63-multisig.sig with a .sig.gz extension
c = runtmp

sig47 = utils.get_test_data('47.fa.sig')
multisig = utils.get_test_data('47+63-multisig.sig')
c.run_sourmash('sig', 'split', sig47, multisig, '-E', '.sig.gz')

outlist = ['57e2b22f.k=31.scaled=1000.DNA.dup=0.none.sig.gz',
'bde81a41.k=31.scaled=1000.DNA.dup=0.none.sig.gz',
'f033bbd8.k=31.scaled=1000.DNA.dup=0.none.sig.gz',
'87a9aec4.k=31.scaled=1000.DNA.dup=0.none.sig.gz',
'837bf2a7.k=31.scaled=1000.DNA.dup=0.none.sig.gz',
'485c3377.k=31.scaled=1000.DNA.dup=0.none.sig.gz']
for filename in outlist:
assert os.path.exists(c.output(filename))


def test_sig_split_3_multisig_zip(runtmp):
# split 47 and 47+63-multisig.sig with a .zip extension
c = runtmp

sig47 = utils.get_test_data('47.fa.sig')
multisig = utils.get_test_data('47+63-multisig.sig')
c.run_sourmash('sig', 'split', sig47, multisig, '-E', '.zip')

outlist = ['57e2b22f.k=31.scaled=1000.DNA.dup=0.none.zip',
'bde81a41.k=31.scaled=1000.DNA.dup=0.none.zip',
'f033bbd8.k=31.scaled=1000.DNA.dup=0.none.zip',
'87a9aec4.k=31.scaled=1000.DNA.dup=0.none.zip',
'837bf2a7.k=31.scaled=1000.DNA.dup=0.none.zip',
'485c3377.k=31.scaled=1000.DNA.dup=0.none.zip']
for filename in outlist:
assert os.path.exists(c.output(filename))


@utils.in_tempdir
def test_sig_split_4_sbt_prot(c):
# split sbt
Expand Down
Loading