Mercurial > repos > peterjc > seq_select_by_id
changeset 16:9aa51c1a17cc draft
planemo upload for repository https://github.com/peterjc/pico_galaxy/tools/seq_select_by_id commit 3abdffd9ade48aa2c2b5f52572d0f77b4f3d2c9c
author | peterjc |
---|---|
date | Wed, 13 May 2015 10:53:36 -0400 |
parents | 1fc238a9fa95 |
children | 7e0fe10456c3 |
files | tools/seq_select_by_id/README.rst tools/seq_select_by_id/seq_select_by_id.py tools/seq_select_by_id/seq_select_by_id.xml |
diffstat | 3 files changed, 62 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/seq_select_by_id/README.rst Thu Nov 27 06:38:33 2014 -0500 +++ b/tools/seq_select_by_id/README.rst Wed May 13 10:53:36 2015 -0400 @@ -1,7 +1,7 @@ Galaxy tool to select FASTA, QUAL, FASTQ or SFF sequences by ID =============================================================== -This tool is copyright 2011-2014 by Peter Cock, The James Hutton Institute +This tool is copyright 2011-2015 by Peter Cock, The James Hutton Institute (formerly SCRI, Scottish Crop Research Institute), UK. All rights reserved. See the licence text below. @@ -79,6 +79,11 @@ - Include input dataset name in output dataset names. - If white space is found in the requested tabular field then only the first word is used as the identifier (with a warning to stderr). +v0.0.10 - Includes testing of stdout messages. + - Includes testing of failure modes. +v0.0.11 - Use the ``format_source=...`` tag. + - Reorder XML elements (internal change only). + - Planemo for Tool Shed upload (``.shed.yml``, internal change only). ======= ====================================================================== @@ -91,22 +96,31 @@ Development has now moved to a dedicated GitHub repository: https://github.com/peterjc/pico_galaxy/tree/master/tools -For making the "Galaxy Tool Shed" http://toolshed.g2.bx.psu.edu/ tarball use -the following command from the Galaxy root folder:: +For pushing a release to the test or main "Galaxy Tool Shed", use the following +Planemo commands (which requires you have set your Tool Shed access details in +``~/.planemo.yml`` and that you have access rights on the Tool Shed):: + + $ planemo shed_upload --shed_target testtoolshed --check_diff ~/repositories/pico_galaxy/tools/seq_select_by_id/ + ... + +or:: - $ tar -czf seq_select_by_id.tar.gz tools/seq_select_by_id/README.rst tools/seq_select_by_id/seq_select_by_id.* tools/seq_select_by_id/tool_dependencies.xml test-data/k12_ten_proteins.fasta test-data/k12_hypothetical.fasta test-data/k12_hypothetical.tabular test-data/k12_hypothetical_alt.tabular + $ planemo shed_upload --shed_target toolshed --check_diff ~/repositories/pico_galaxy/tools/seq_select_by_id/ + ... + +To just build and check the tar ball, use:: -Check this worked:: - - $ tar -tzf seq_select_by_id.tar.gz + $ planemo shed_upload --tar_only ~/repositories/pico_galaxy/tools/seq_select_by_id/ + ... + $ tar -tzf shed_upload.tar.gz + test-data/k12_hypothetical.fasta + test-data/k12_hypothetical.tabular + test-data/k12_hypothetical_alt.tabular + test-data/k12_ten_proteins.fasta tools/seq_select_by_id/README.rst tools/seq_select_by_id/seq_select_by_id.py tools/seq_select_by_id/seq_select_by_id.xml tools/seq_select_by_id/tool_dependencies.xml - test-data/k12_ten_proteins.fasta - test-data/k12_hypothetical.fasta - test-data/k12_hypothetical.tabular - test-data/k12_hypothetical_alt.tabular Licence (MIT)
--- a/tools/seq_select_by_id/seq_select_by_id.py Thu Nov 27 06:38:33 2014 -0500 +++ b/tools/seq_select_by_id/seq_select_by_id.py Wed May 13 10:53:36 2015 -0400 @@ -22,7 +22,7 @@ """ import sys -def stop_err(msg, err=1): +def sys_exit(msg, err=1): sys.stderr.write(msg.rstrip() + "\n") sys.exit(err) @@ -34,17 +34,17 @@ try: tabular_file, col_arg, in_file, seq_format, out_file = sys.argv[1:] except ValueError: - stop_err("Expected five arguments, got %i:\n%s" % (len(sys.argv)-1, " ".join(sys.argv))) + sys_exit("Expected five arguments, got %i:\n%s" % (len(sys.argv)-1, " ".join(sys.argv))) try: if col_arg.startswith("c"): column = int(col_arg[1:])-1 else: column = int(col_arg)-1 except ValueError: - stop_err("Expected column number, got %s" % col_arg) + sys_exit("Expected column number, got %s" % col_arg) if seq_format == "fastqcssanger": - stop_err("Colorspace FASTQ not supported.") + sys_exit("Colorspace FASTQ not supported.") elif seq_format.lower() in ["sff", "fastq", "qual", "fasta"]: seq_format = seq_format.lower() elif seq_format.lower().startswith("fastq"): @@ -54,13 +54,13 @@ #We don't care what the scores are seq_format = "qual" else: - stop_err("Unrecognised file format %r" % seq_format) + sys_exit("Unrecognised file format %r" % seq_format) try: from Bio import SeqIO except ImportError: - stop_err("Biopython 1.54 or later is required") + sys_exit("Biopython 1.54 or later is required") def parse_ids(tabular_file, col): @@ -94,7 +94,7 @@ try: from Bio.SeqIO.SffIO import SffIterator, SffWriter except ImportError: - stop_err("Requires Biopython 1.54 or later") + sys_exit("Requires Biopython 1.54 or later") try: from Bio.SeqIO.SffIO import ReadRocheXmlManifest @@ -120,7 +120,7 @@ except KeyError, err: out_handle.close() if name not in records: - stop_err("Identifier %r not found in sequence file" % name) + sys_exit("Identifier %r not found in sequence file" % name) else: raise err out_handle.close() @@ -134,7 +134,7 @@ out_handle.write(records.get_raw(name)) except KeyError: out_handle.close() - stop_err("Identifier %r not found in sequence file" % name) + sys_exit("Identifier %r not found in sequence file" % name) count += 1 out_handle.close()
--- a/tools/seq_select_by_id/seq_select_by_id.xml Thu Nov 27 06:38:33 2014 -0500 +++ b/tools/seq_select_by_id/seq_select_by_id.xml Wed May 13 10:53:36 2015 -0400 @@ -1,25 +1,25 @@ -<tool id="seq_select_by_id" name="Select sequences by ID" version="0.0.9"> +<tool id="seq_select_by_id" name="Select sequences by ID" version="0.0.11"> <description>from a tabular file</description> <requirements> <requirement type="package" version="1.62">biopython</requirement> <requirement type="python-module">Bio</requirement> </requirements> - <version_command interpreter="python">seq_select_by_id.py --version</version_command> - <command interpreter="python"> -seq_select_by_id.py $input_tabular $column $input_file $input_file.ext $output_file - </command> <stdio> <!-- Anything other than zero is an error --> <exit_code range="1:" /> <exit_code range=":-1" /> </stdio> + <version_command interpreter="python">seq_select_by_id.py --version</version_command> + <command interpreter="python"> +seq_select_by_id.py $input_tabular $column $input_file $input_file.ext $output_file + </command> <inputs> <param name="input_file" type="data" format="fasta,qual,fastq,sff" label="Sequence file to select from" help="FASTA, QUAL, FASTQ, or SFF format." /> <param name="input_tabular" type="data" format="tabular" label="Tabular file containing sequence identifiers"/> <param name="column" type="data_column" data_ref="input_tabular" multiple="False" numerical="False" label="Column containing sequence identifiers"/> </inputs> <outputs> - <data name="output_file" format="input" metadata_source="input_file" label="Selected sequences from $input_file.name"/> + <data name="output_file" format_source="input_file" metadata_source="input_file" label="Selected sequences from $input_file.name"/> </outputs> <tests> <test> @@ -27,6 +27,10 @@ <param name="input_tabular" value="k12_hypothetical.tabular" ftype="tabular" /> <param name="column" value="1" /> <output name="output_file" file="k12_hypothetical.fasta" ftype="fasta" /> + <assert_stdout> + <has_line line="Indexed 10 sequences" /> + <has_line line="Selected 1 sequences by ID" /> + </assert_stdout> </test> <!-- this version has white space in the identifier column (id and description) --> <test> @@ -34,6 +38,24 @@ <param name="input_tabular" value="k12_hypothetical_alt.tabular" ftype="tabular" /> <param name="column" value="1" /> <output name="output_file" file="k12_hypothetical.fasta" ftype="fasta" /> + <assert_stdout> + <has_line line="Indexed 10 sequences" /> + <has_line line="Selected 1 sequences by ID" /> + </assert_stdout> + <assert_stderr> + <has_line line="WARNING: Some of your identifiers had white space in them, using first word only. e.g.:" /> + </assert_stderr> + </test> + <test expect_failure="true" expect_exit_code="1"> + <param name="input_file" value="empty.fasta" ftype="fasta" /> + <param name="input_tabular" value="k12_hypothetical.tabular" ftype="tabular" /> + <param name="column" value="1" /> + <assert_stdout> + <has_line line="Indexed 0 sequences" /> + </assert_stdout> + <assert_stderr> + <has_line line="Identifier 'gi|16127999|ref|NP_414546.1|' not found in sequence file" /> + </assert_stderr> </test> </tests> <help>