changeset 4:c8469274d136 draft

v0.0.8 Using Biopython 1.67 from Tool Shed or Conda package
author peterjc
date Wed, 10 May 2017 12:05:28 -0400
parents de803005027f
children 2c32e8a8990f
files tools/align_back_trans/README.rst tools/align_back_trans/align_back_trans.py tools/align_back_trans/align_back_trans.xml tools/align_back_trans/tool_dependencies.xml
diffstat 4 files changed, 51 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/tools/align_back_trans/README.rst	Wed Feb 01 06:55:27 2017 -0500
+++ b/tools/align_back_trans/README.rst	Wed May 10 12:05:28 2017 -0400
@@ -1,7 +1,7 @@
 Galaxy tool to back-translate a protein alignment to nucleotides
 ================================================================
 
-This tool is copyright 2012-2015 by Peter Cock, The James Hutton Institute
+This tool is copyright 2012-2017 by Peter Cock, The James Hutton Institute
 (formerly SCRI, Scottish Crop Research Institute), UK. All rights reserved.
 See the licence text below (MIT licence).
 
@@ -70,6 +70,15 @@
         - Use ``format_source=...`` tag.
         - Planemo for Tool Shed upload (``.shed.yml``, internal change only).
 v0.0.7  - Minor Python code style improvements (internal change only).
+v0.0.8  - Python coding style change to avoid lamba (internal change only).
+        - Depends on Biopython 1.67 via legacy Tool Shed package or bioconda.
+        - Added two recent NCBI genetic code tables,
+
+          - Table 24, *Pterobranchia* Mitochondrial Code,
+          - Table 25, Candidate Division SR1 and *Gracilibacteria*.
+
+        - Use ``<command detect_errors="aggressive">`` (internal change only).
+        - Single quote command line arguments (internal change only).
 ======= ======================================================================
 
 
@@ -86,17 +95,17 @@
 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 -t testtoolshed --check_diff ~/repositories/pico_galaxy/tools/align_back_trans/
+    $ planemo shed_update -t testtoolshed --check_diff tools/align_back_trans/
     ...
 
 or::
 
-    $ planemo shed_update -t toolshed --check_diff ~/repositories/pico_galaxy/tools/align_back_trans/
+    $ planemo shed_update -t toolshed --check_diff tools/align_back_trans/
     ...
 
 To just build and check the tar ball, use::
 
-    $ planemo shed_upload --tar_only  ~/repositories/pico_galaxy/tools/align_back_trans/
+    $ planemo shed_upload --tar_only tools/align_back_trans/
     ...
     $ tar -tzf shed_upload.tar.gz 
     test-data/demo_nucs.fasta
--- a/tools/align_back_trans/align_back_trans.py	Wed Feb 01 06:55:27 2017 -0500
+++ b/tools/align_back_trans/align_back_trans.py	Wed May 10 12:05:28 2017 -0400
@@ -18,12 +18,14 @@
 """
 
 import sys
-from Bio.Seq import Seq
-from Bio.Alphabet import generic_protein
+
+from Bio import AlignIO
+from Bio import SeqIO
+
 from Bio.Align import MultipleSeqAlignment
-from Bio import SeqIO
-from Bio import AlignIO
+from Bio.Alphabet import generic_protein
 from Bio.Data.CodonTable import ambiguous_generic_by_id
+from Bio.Seq import Seq
 
 if "-v" in sys.argv or "--version" in sys.argv:
     print "v0.0.7"
@@ -130,19 +132,23 @@
 def alignment_back_translate(protein_alignment, nucleotide_records, key_function=None, gap=None, table=0):
     """Thread nucleotide sequences onto a protein alignment."""
     # TODO - Separate arguments for protein and nucleotide gap characters?
-    if key_function is None:
-        key_function = lambda x: x
     if gap is None:
         gap = "-"
 
     aligned = []
-    for protein in protein_alignment:
-        try:
-            nucleotide = nucleotide_records[key_function(protein.id)]
-        except KeyError:
-            raise ValueError("Could not find nucleotide sequence for protein %r"
-                             % protein.id)
-        aligned.append(sequence_back_translate(protein, nucleotide, gap, table))
+    try:
+        if key_function is None:
+            for protein in protein_alignment:
+                nucleotide = nucleotide_records[protein.id]
+                aligned.append(sequence_back_translate(protein, nucleotide, gap, table))
+        else:
+            for protein in protein_alignment:
+                nucleotide = nucleotide_records[key_function(protein.id)]
+                aligned.append(sequence_back_translate(protein, nucleotide, gap, table))
+    except KeyError:
+        raise ValueError("Could not find nucleotide sequence for protein %r"
+                         % protein.id)
+
     return MultipleSeqAlignment(aligned)
 
 
--- a/tools/align_back_trans/align_back_trans.xml	Wed Feb 01 06:55:27 2017 -0500
+++ b/tools/align_back_trans/align_back_trans.xml	Wed May 10 12:05:28 2017 -0400
@@ -1,17 +1,13 @@
-<tool id="align_back_trans" name="Thread nucleotides onto a protein alignment (back-translation)" version="0.0.7">
+<tool id="align_back_trans" name="Thread nucleotides onto a protein alignment (back-translation)" version="0.0.8">
     <description>Gives a codon aware alignment</description>
     <requirements>
-        <requirement type="package" version="1.63">biopython</requirement>
-        <requirement type="python-module">Bio</requirement>
+        <requirement type="package" version="1.67">biopython</requirement>
     </requirements>
-    <stdio>
-        <!-- Anything other than zero is an error -->
-        <exit_code range="1:" />
-        <exit_code range=":-1" />
-    </stdio>
-    <version_command interpreter="python">align_back_trans.py --version</version_command>
-    <command interpreter="python">
-align_back_trans.py $prot_align.ext "$prot_align" "$nuc_file" "$out_nuc_align" "$table"
+    <version_command>
+python $__tool_directory__/align_back_trans.py --version
+</version_command>
+    <command detect_errors="aggressive">
+python $__tool_directory__/align_back_trans.py $prot_align.ext '$prot_align' '$nuc_file' '$out_nuc_align' '$table'
     </command>
     <inputs>
         <param name="prot_align" type="data" format="fasta,muscle,clustal" label="Aligned protein file" help="Mutliple sequence file in FASTA, ClustalW or PHYLIP format." />
@@ -33,6 +29,16 @@
             <option value="21">21. Trematode Mitochondrial</option>
             <option value="22">22. Scenedesmus obliquus</option>
             <option value="23">23. Thraustochytrium Mitochondrial</option>
+            <option value="24">24. Pterobranchia Mitochondrial</option>
+            <option value="25">25. Candidate Division SR1 and Gracilibacteria</option>
+            <!-- TODO, these are not in Biopython 1.67
+            <option value="26">26. Pachysolen tannophilus Nuclear</option>
+            <option value="26">27. Karyorelict Nuclear</option>
+            <option value="26">28. Condylostoma Nuclear</option>
+            <option value="26">29. Mesodinium Nuclear</option>
+            <option value="26">30. Peritrich Nuclear</option>
+            <option value="26">31. Blastocrithidia Nuclear</option>
+            -->
             <option value="0">Don't check the translation</option>
         </param>
         <param name="nuc_file" type="data" format="fasta" label="Unaligned nucleotide sequences" help="FASTA format, using same identifiers as your protein alignment" />
--- a/tools/align_back_trans/tool_dependencies.xml	Wed Feb 01 06:55:27 2017 -0500
+++ b/tools/align_back_trans/tool_dependencies.xml	Wed May 10 12:05:28 2017 -0400
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <tool_dependency>
-    <package name="biopython" version="1.63">
-        <repository changeset_revision="ec55b787a0e1" name="package_biopython_1_63" owner="biopython" toolshed="https://toolshed.g2.bx.psu.edu" />
+    <package name="biopython" version="1.67">
+        <repository changeset_revision="a42f244cce44" name="package_biopython_1_67" owner="biopython" toolshed="https://toolshed.g2.bx.psu.edu" />
     </package>
 </tool_dependency>