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

sourmash sig merge needs --name #1213

Closed
ctb opened this issue Oct 16, 2020 · 3 comments · Fixed by #1480
Closed

sourmash sig merge needs --name #1213

ctb opened this issue Oct 16, 2020 · 3 comments · Fixed by #1480

Comments

@ctb
Copy link
Contributor

ctb commented Oct 16, 2020

sourmash sig merge should support --name to rename the output signature.

feature suggested by @olgabot as per below.

To get started on this,

  • add a --name parameter to argument parsing for sig merge in src/sourmash/cli/sig/merge.py
  • in src/sourmash/sig/__main__.py, function merge(...), adjust the SourmashSignature object creation to use name=args.name
  • add a test in tests/test_test_cmd_signature.py, perhaps starting from a renamed copy of test_sig_merge_1, that uses --name on the command line and checks the .name attribute on the output signature
@olgabot
Copy link
Collaborator

olgabot commented Oct 16, 2020

Yes because piping doesn't work!

(base)
 Fri 16 Oct - 15:16  ~/data_sm/tabula-microcebus/analyses/kmermaid/tenx-tgz--hlca-v2--normal-lung-remove-riborna/sketches_peptide_handmade_merged 
 olga@ndnd  sourmash sig merge --quiet -k 27 --dayhoff /home/olga/data_sm/tabula-microcebus/analyses/kmermaid/tenx-tgz--hlca-v2--normal-lung-remove-riborna/sketches_peptide_handmade/HUMAN_HCA_LUNG_LUNG_CD45_OR_CD31__aligned__aligned__ACACCCTTCAAACCAC__coding_reads_peptides.sig /home/olga/data_sm/tabula-microcebus/analyses/kmermaid/tenx-tgz--hlca-v2--normal-lung-remove-riborna/sketches_peptide_handmade/HUMAN_HCA_LUNG_LUNG_CD45_OR_CD31__unaligned__unaligned__ACACCCTTCAAACCAC__coding_reads_peptides.sig | sourmash sig rename --quiet --output /home/olga/data_sm/tabula-microcebus/analyses/kmermaid/tenx-tgz--hlca-v2--normal-lung-remove-riborna/sketches_peptide_handmade_merged/alphabet-dayhoff__ksize-27__scaled-5/HUMAN_HCA_LUNG_LUNG_CD45_OR_CD31__ACACCCTTCAAACCAC.sig - HUMAN_HCA_LUNG_LUNG_CD45_OR_CD31__ACACCCTTCAAACCAC
Traceback (most recent call last):
  File "/home/olga/anaconda/bin/sourmash", line 11, in <module>
    sys.exit(main())
  File "/home/olga/miniconda3/lib/python3.6/site-packages/sourmash/__main__.py", line 14, in main
    return mainmethod(args)
  File "/home/olga/miniconda3/lib/python3.6/site-packages/sourmash/cli/sig/merge.py", line 29, in main
    return sourmash.sig.__main__.merge(args)
  File "/home/olga/miniconda3/lib/python3.6/site-packages/sourmash/sig/__main__.py", line 269, in merge
    sourmash.save_signatures([merged_sigobj], fp=fp)
  File "/home/olga/miniconda3/lib/python3.6/site-packages/sourmash/signature.py", line 336, in save_signatures
    fp.write(result)
BrokenPipeError: [Errno 32] Broken pipe
(base)
 Fri 16 Oct - 15:16  ~/data_sm/tabula-microcebus/analyses/kmermaid/tenx-tgz--hlca-v2--normal-lung-remove-riborna/sketches_peptide_handmade_merged 
 olga@ndnd  sourmash sig merge --quiet -k 27 --dayhoff /home/olga/data_sm/tabula-microcebus/analyses/kmermaid/tenx-tgz--hlca-v2--normal-lung-remove-riborna/sketches_peptide_handmade/HUMAN_HCA_LUNG_LUNG_CD45_OR_CD31__aligned__aligned__ACACCCTTCAAACCAC__coding_reads_peptides.sig /home/olga/data_sm/tabula-microcebus/analyses/kmermaid/tenx-tgz--hlca-v2--normal-lung-remove-riborna/sketches_peptide_handmade/HUMAN_HCA_LUNG_LUNG_CD45_OR_CD31__unaligned__unaligned__ACACCCTTCAAACCAC__coding_reads_peptides.sig | sourmash sig rename --quiet --output /home/olga/data_sm/tabula-microcebus/analyses/kmermaid/tenx-tgz--hlca-v2--normal-lung-remove-riborna/sketches_peptide_handmade_merged/alphabet-dayhoff__ksize-27__scaled-5/HUMAN_HCA_LUNG_LUNG_CD45_OR_CD31__ACACCCTTCAAACCAC.sig HUMAN_HCA_LUNG_LUNG_CD45_OR_CD31__ACACCCTTCAAACCAC
usage:  rename [-h] [-q] [-d] [-o FILE] [-k K] [--protein] [--no-protein]
               [--dayhoff] [--no-dayhoff] [--hp] [--no-hp] [--dna] [--no-dna]
               sigfiles [sigfiles ...] name
 rename: error: the following arguments are required: name
(base)
 ✘  Fri 16 Oct - 15:16  ~/data_sm/tabula-microcebus/analyses/kmermaid/tenx-tgz--hlca-v2--normal-lung-remove-riborna/sketches_peptide_handmade_merged 
 olga@ndnd  sourmash sig merge --quiet -k 27 --dayhoff /home/olga/data_sm/tabula-microcebus/analyses/kmermaid/tenx-tgz--hlca-v2--normal-lung-remove-riborna/sketches_peptide_handmade/HUMAN_HCA_LUNG_LUNG_CD45_OR_CD31__aligned__aligned__ACACCCTTCAAACCAC__coding_reads_peptides.sig /home/olga/data_sm/tabula-microcebus/analyses/kmermaid/tenx-tgz--hlca-v2--normal-lung-remove-riborna/sketches_peptide_handmade/HUMAN_HCA_LUNG_LUNG_CD45_OR_CD31__unaligned__unaligned__ACACCCTTCAAACCAC__coding_reads_peptides.sig | sourmash sig rename --quiet --name HUMAN_HCA_LUNG_LUNG_CD45_OR_CD31__ACACCCTTCAAACCAC --output /home/olga/data_sm/tabula-microcebus/analyses/kmermaid/tenx-tgz--hlca-v2--normal-lung-remove-riborna/sketches_peptide_handmade_merged/alphabet-dayhoff__ksize-27__scaled-5/HUMAN_HCA_LUNG_LUNG_CD45_OR_CD31__ACACCCTTCAAACCAC.sig
usage:  rename [-h] [-q] [-d] [-o FILE] [-k K] [--protein] [--no-protein]
               [--dayhoff] [--no-dayhoff] [--hp] [--no-hp] [--dna] [--no-dna]
               sigfiles [sigfiles ...] name
 rename: error: the following arguments are required: name
Traceback (most recent call last):
  File "/home/olga/anaconda/bin/sourmash", line 11, in <module>
    sys.exit(main())
  File "/home/olga/miniconda3/lib/python3.6/site-packages/sourmash/__main__.py", line 14, in main
    return mainmethod(args)
  File "/home/olga/miniconda3/lib/python3.6/site-packages/sourmash/cli/sig/merge.py", line 29, in main
    return sourmash.sig.__main__.merge(args)
  File "/home/olga/miniconda3/lib/python3.6/site-packages/sourmash/sig/__main__.py", line 269, in merge
    sourmash.save_signatures([merged_sigobj], fp=fp)
  File "/home/olga/miniconda3/lib/python3.6/site-packages/sourmash/signature.py", line 336, in save_signatures
    fp.write(result)
BrokenPipeError: [Errno 32] Broken pipe
(base)
 ✘  Fri 16 Oct - 15:17  ~/data_sm/tabula-microcebus/analyses/kmermaid/tenx-tgz--hlca-v2--normal-lung-remove-riborna/sketches_peptide_handmade_merged 
 olga@ndnd  sourmash sig merge --quiet -k 27 --dayhoff /home/olga/data_sm/tabula-microcebus/analyses/kmermaid/tenx-tgz--hlca-v2--normal-lung-remove-riborna/sketches_peptide_handmade/HUMAN_HCA_LUNG_LUNG_CD45_OR_CD31__aligned__aligned__ACACCCTTCAAACCAC__coding_reads_peptides.sig /home/olga/data_sm/tabula-microcebus/analyses/kmermaid/tenx-tgz--hlca-v2--normal-lung-remove-riborna/sketches_peptide_handmade/HUMAN_HCA_LUNG_LUNG_CD45_OR_CD31__unaligned__unaligned__ACACCCTTCAAACCAC__coding_reads_peptides.sig | sourmash sig rename --quiet --name HUMAN_HCA_LUNG_LUNG_CD45_OR_CD31__ACACCCTTCAAACCAC --output /home/olga/data_sm/tabula-microcebus/analyses/kmermaid/tenx-tgz--hlca-v2--normal-lung-remove-riborna/sketches_peptide_handmade_merged/alphabet-dayhoff__ksize-27__scaled-5/HUMAN_HCA_LUNG_LUNG_CD45_OR_CD31__ACACCCTTCAAACCAC.sig  -
sourmash: error: unrecognized arguments: --name

@ctb
Copy link
Contributor Author

ctb commented Mar 12, 2021

hi @olgabot ok, figured this out - the correct syntax for renaming signatures via pipe is:

sourmash sig merge 47.fa.sig 63.fa.sig  | \
     sourmash sig rename - newname

To be fair, I don't really like the syntax for sourmash sig rename, but that's what it is ;).

I do like the idea of adding a --name parameter to sourmash sig merge, though!

@hehouts

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants