# HG changeset patch # User peterjc # Date 1494432328 14400 # Node ID c8469274d136581fe423757bf45b50a0b2122e32 # Parent de803005027ffc8506a52277663a7c5b4111233e v0.0.8 Using Biopython 1.67 from Tool Shed or Conda package diff -r de803005027f -r c8469274d136 tools/align_back_trans/README.rst --- 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 ```` (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 diff -r de803005027f -r c8469274d136 tools/align_back_trans/align_back_trans.py --- 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) diff -r de803005027f -r c8469274d136 tools/align_back_trans/align_back_trans.xml --- 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 @@ - + Gives a codon aware alignment - biopython - Bio + biopython - - - - - - align_back_trans.py --version - -align_back_trans.py $prot_align.ext "$prot_align" "$nuc_file" "$out_nuc_align" "$table" + +python $__tool_directory__/align_back_trans.py --version + + +python $__tool_directory__/align_back_trans.py $prot_align.ext '$prot_align' '$nuc_file' '$out_nuc_align' '$table' @@ -33,6 +29,16 @@ + + + diff -r de803005027f -r c8469274d136 tools/align_back_trans/tool_dependencies.xml --- 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 @@ - - + +