Previous changeset 17:21d7e700fbd7 (2015-05-21) Next changeset 19:412e708d0172 (2017-02-03) |
Commit message:
v0.0.8 galaxy_sequence_utils dependency etc |
modified:
tools/seq_rename/README.rst tools/seq_rename/seq_rename.py tools/seq_rename/seq_rename.xml tools/seq_rename/tool_dependencies.xml |
b |
diff -r 21d7e700fbd7 -r 54781a26d8f3 tools/seq_rename/README.rst --- a/tools/seq_rename/README.rst Thu May 21 10:49:25 2015 -0400 +++ b/tools/seq_rename/README.rst Wed Feb 01 11:08:41 2017 -0500 |
b |
@@ -1,7 +1,7 @@ Galaxy tool to rename FASTA, QUAL, FASTQ or SFF sequences ========================================================= -This tool is copyright 2011-2015 by Peter Cock, The James Hutton Institute +This tool is copyright 2011-2017 by Peter Cock, The James Hutton Institute (formerly SCRI, Scottish Crop Research Institute), UK. All rights reserved. See the licence text below. @@ -78,6 +78,10 @@ v0.0.7 - Use the ``format_source=...`` tag. - Reorder XML elements (internal change only). - Planemo for Tool Shed upload (``.shed.yml``, internal change only). + - Capture the tool version via Galaxy (bug fix). +v0.0.8 - Updated to point at Biopython 1.67 (latest version in Tool Shed). + - Explicit dependency on ``galaxy_sequence_utils``. + - Python style updates (internal change only). ======= ====================================================================== @@ -94,12 +98,12 @@ 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_update --shed_target testtoolshed --check_diff ~/repositories/pico_galaxy/tools/seq_rename/ + $ planemo shed_update -t testtoolshed --check_diff ~/repositories/pico_galaxy/tools/seq_rename/ ... or:: - $ planemo shed_update --shed_target toolshed --check_diff ~/repositories/pico_galaxy/tools/seq_rename/ + $ planemo shed_update -t toolshed --check_diff ~/repositories/pico_galaxy/tools/seq_rename/ ... To just build and check the tar ball, use:: |
b |
diff -r 21d7e700fbd7 -r 54781a26d8f3 tools/seq_rename/seq_rename.py --- a/tools/seq_rename/seq_rename.py Thu May 21 10:49:25 2015 -0400 +++ b/tools/seq_rename/seq_rename.py Wed Feb 01 11:08:41 2017 -0500 |
[ |
@@ -17,42 +17,39 @@ molecular biology and bioinformatics. Bioinformatics 25(11) 1422-3. http://dx.doi.org/10.1093/bioinformatics/btp163 pmid:19304878. -This script is copyright 2011-2013 by Peter Cock, The James Hutton Institute UK. +This script is copyright 2011-2017 by Peter Cock, The James Hutton Institute UK. All rights reserved. See accompanying text file for licence details (MIT license). """ import sys if "-v" in sys.argv or "--version" in sys.argv: - print "v0.0.6" + print "v0.0.8" sys.exit(0) -def sys_exit(msg, err=1): - sys.stderr.write(msg.rstrip() + "\n") - sys.exit(err) - -#Parse Command Line +# Parse Command Line try: tabular_file, old_col_arg, new_col_arg, in_file, seq_format, out_file = sys.argv[1:] except ValueError: - sys_exit("Expected six arguments (tabular file, old col, new col, input file, format, output file), got %i:\n%s" % (len(sys.argv)-1, " ".join(sys.argv))) + sys.exit("Expected six arguments (tabular file, old col, new col, input file, format, output file), got %i:\n%s" % (len(sys.argv) - 1, " ".join(sys.argv))) try: if old_col_arg.startswith("c"): - old_column = int(old_col_arg[1:])-1 + old_column = int(old_col_arg[1:]) - 1 else: - old_column = int(old_col_arg)-1 + old_column = int(old_col_arg) - 1 except ValueError: - sys_exit("Expected column number, got %s" % old_col_arg) + sys.exit("Expected column number, got %s" % old_col_arg) try: if old_col_arg.startswith("c"): - new_column = int(new_col_arg[1:])-1 + new_column = int(new_col_arg[1:]) - 1 else: - new_column = int(new_col_arg)-1 + new_column = int(new_col_arg) - 1 except ValueError: - sys_exit("Expected column number, got %s" % new_col_arg) + sys.exit("Expected column number, got %s" % new_col_arg) if old_column == new_column: - sys_exit("Old and new column arguments are the same!") + sys.exit("Old and new column arguments are the same!") + def parse_ids(tabular_file, old_col, new_col): """Read tabular file and record all specified ID mappings. @@ -88,16 +85,17 @@ sys.stderr.write(new_warn) -#Load the rename mappings +# Load the rename mappings rename = dict(parse_ids(tabular_file, old_column, new_column)) print "Loaded %i ID mappings" % len(rename) - -#Rewrite the sequence file -if seq_format.lower()=="sff": - #Use Biopython for this format + +# Rewrite the sequence file +if seq_format.lower() == "sff": + # Use Biopython for this format renamed = 0 + def rename_seqrecords(records, mapping): - global renamed #nasty, but practical! + global renamed # nasty, but practical! for record in records: try: record.id = mapping[record.id] @@ -105,33 +103,33 @@ except KeyError: pass yield record - + try: from Bio.SeqIO.SffIO import SffIterator, SffWriter except ImportError: - sys_exit("Requires Biopython 1.54 or later") + sys.exit("Requires Biopython 1.54 or later") try: from Bio.SeqIO.SffIO import ReadRocheXmlManifest except ImportError: - #Prior to Biopython 1.56 this was a private function + # Prior to Biopython 1.56 this was a private function from Bio.SeqIO.SffIO import _sff_read_roche_index_xml as ReadRocheXmlManifest - in_handle = open(in_file, "rb") #must be binary mode! + in_handle = open(in_file, "rb") # must be binary mode! try: manifest = ReadRocheXmlManifest(in_handle) except ValueError: manifest = None out_handle = open(out_file, "wb") writer = SffWriter(out_handle, xml=manifest) - in_handle.seek(0) #start again after getting manifest + in_handle.seek(0) # start again after getting manifest count = writer.write_file(rename_seqrecords(SffIterator(in_handle), rename)) out_handle.close() in_handle.close() else: - #Use Galaxy for FASTA, QUAL or FASTQ + # Use Galaxy for FASTA, QUAL or FASTQ if seq_format.lower() in ["fasta", "csfasta"] \ - or seq_format.lower().startswith("qual"): + or seq_format.lower().startswith("qual"): from galaxy_utils.sequence.fasta import fastaReader, fastaWriter reader = fastaReader(open(in_file, "rU")) writer = fastaWriter(open(out_file, "w")) @@ -142,13 +140,13 @@ writer = fastqWriter(open(out_file, "w")) marker = "@" else: - sys_exit("Unsupported file type %r" % seq_format) - #Now do the renaming + sys.exit("Unsupported file type %r" % seq_format) + # Now do the renaming count = 0 renamed = 0 for record in reader: - #The [1:] is because the fastaReader leaves the > on the identifier, - #likewise the fastqReader leaves the @ on the identifier + # The [1:] is because the fastaReader leaves the > on the identifier, + # likewise the fastqReader leaves the @ on the identifier try: idn, descr = record.identifier[1:].split(None, 1) except ValueError: |
b |
diff -r 21d7e700fbd7 -r 54781a26d8f3 tools/seq_rename/seq_rename.xml --- a/tools/seq_rename/seq_rename.xml Thu May 21 10:49:25 2015 -0400 +++ b/tools/seq_rename/seq_rename.xml Wed Feb 01 11:08:41 2017 -0500 |
b |
@@ -1,7 +1,8 @@ -<tool id="seq_rename" name="Rename sequences" version="0.0.7"> +<tool id="seq_rename" name="Rename sequences" version="0.0.8"> <description>with ID mapping from a tabular file</description> <requirements> - <requirement type="package" version="1.62">biopython</requirement> + <requirement type="package" version="1.0.1">galaxy_sequence_utils</requirement> + <requirement type="package" version="1.67">biopython</requirement> <requirement type="python-module">Bio</requirement> </requirements> <stdio> @@ -9,7 +10,7 @@ <exit_code range="1:" /> <exit_code range=":-1" /> </stdio> - <version_commmand interpreter="python">seq_rename.py --version</version_commmand> + <version_command interpreter="python">seq_rename.py --version</version_command> <command interpreter="python"> seq_rename.py $input_tabular $old_column $new_column $input_file $input_file.ext $output_file </command> |
b |
diff -r 21d7e700fbd7 -r 54781a26d8f3 tools/seq_rename/tool_dependencies.xml --- a/tools/seq_rename/tool_dependencies.xml Thu May 21 10:49:25 2015 -0400 +++ b/tools/seq_rename/tool_dependencies.xml Wed Feb 01 11:08:41 2017 -0500 |
b |
@@ -1,6 +1,9 @@ <?xml version="1.0"?> <tool_dependency> - <package name="biopython" version="1.62"> - <repository changeset_revision="ac9cc2992b69" name="package_biopython_1_62" owner="biopython" toolshed="https://testtoolshed.g2.bx.psu.edu" /> + <package name="biopython" version="1.67"> + <repository changeset_revision="fc45a61abc2f" name="package_biopython_1_67" owner="biopython" toolshed="https://testtoolshed.g2.bx.psu.edu" /> + </package> + <package name="galaxy_sequence_utils" version="1.0.1"> + <repository changeset_revision="c38bd3fe9da6" name="package_galaxy_sequence_utils_1_0_1" owner="iuc" toolshed="https://testtoolshed.g2.bx.psu.edu" /> </package> </tool_dependency> |