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] added --name to merge #1480

Merged
merged 6 commits into from
Apr 30, 2021
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/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def subparser(subparsers):
'--flatten', action='store_true',
help='remove abundances from all signatures'
)
subparser.add_argument(
'--name',
help='rename merged signature'
)
add_ksize_arg(subparser, 31)
add_moltype_args(subparser)

Expand Down
2 changes: 1 addition & 1 deletion src/sourmash/sig/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def merge(args):
error("no signatures to merge!?")
sys.exit(-1)

merged_sigobj = sourmash.SourmashSignature(mh)
merged_sigobj = sourmash.SourmashSignature(mh, name=args.name)

with FileOutput(args.output, 'wt') as fp:
sourmash.save_signatures([merged_sigobj], fp=fp)
Expand Down
19 changes: 19 additions & 0 deletions tests/test_cmd_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,25 @@ def test_sig_merge_1_multisig(c):
assert actual_merge_sig.minhash == test_merge_sig.minhash


@utils.in_tempdir
def test_sig_merge_1_name(c):
# check name arg
sig2 = utils.get_test_data('2.fa.sig')
sig63 = utils.get_test_data('63.fa.sig')

assignedSigName = 'SIG_NAME'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for future reference, we typically use non-CamelCase variables for things that aren't class names. So it's MinHash and SourmashSignature but load_signature. In this case, I would suggest assigned_sig_name. As this is a test, however, there's no need to change it, this is just an FYI!

outsig = c.output('merged2and63.sig')

c.run_sourmash('sig', 'merge', sig2, sig63, '--dna', '-k', '31', '-o', "merged2and63.sig", '--name', assignedSigName )

test_merge_sig = sourmash.load_one_signature(outsig)

print("outsig", outsig)
print("xx_test_merge_sig.name", test_merge_sig.name)

assert assignedSigName == test_merge_sig.name


@utils.in_tempdir
def test_sig_merge_1_ksize_moltype(c):
# check ksize, moltype args
Expand Down