Package Bio :: Package Align :: Package Applications :: Module _Prank
[hide private]
[frames] | no frames]

Source Code for Module Bio.Align.Applications._Prank

  1  # Copyright 2009 by Cymon J. Cox.  All rights reserved. 
  2  # This code is part of the Biopython distribution and governed by its 
  3  # license.  Please see the LICENSE file that should have been included 
  4  # as part of this package. 
  5  """Command line wrapper for the multiple alignment program PRANK. 
  6  """ 
  7   
  8  from __future__ import print_function 
  9   
 10  __docformat__ = "epytext en"  # Don't just use plain text in epydoc API pages! 
 11   
 12  from Bio.Application import _Option, _Switch, AbstractCommandline 
 13   
 14   
15 -class PrankCommandline(AbstractCommandline):
16 """Command line wrapper for the multiple alignment program PRANK. 17 18 http://www.ebi.ac.uk/goldman-srv/prank/prank/ 19 20 Example: 21 22 To align a FASTA file (unaligned.fasta) with the output in aligned 23 FASTA format with the output filename starting with "aligned" (you 24 can't pick the filename explicitly), no tree output and no XML output, 25 use: 26 27 >>> from Bio.Align.Applications import PrankCommandline 28 >>> prank_cline = PrankCommandline(d="unaligned.fasta", 29 ... o="aligned", #prefix only! 30 ... f=8, #FASTA output 31 ... notree=True, noxml=True) 32 >>> print(prank_cline) 33 prank -d=unaligned.fasta -o=aligned -f=8 -noxml -notree 34 35 You would typically run the command line with prank_cline() or via 36 the Python subprocess module, as described in the Biopython tutorial. 37 38 Citations: 39 40 Loytynoja, A. and Goldman, N. 2005. An algorithm for progressive 41 multiple alignment of sequences with insertions. Proceedings of 42 the National Academy of Sciences, 102: 10557--10562. 43 44 Loytynoja, A. and Goldman, N. 2008. Phylogeny-aware gap placement 45 prevents errors in sequence alignment and evolutionary analysis. 46 Science, 320: 1632. 47 48 Last checked against version: 081202 49 """
50 - def __init__(self, cmd="prank", **kwargs):
51 OUTPUT_FORMAT_VALUES = list(range(1, 18)) 52 self.parameters = [ 53 ################## input/output parameters: ################## 54 #-d=sequence_file 55 _Option(["-d", "d"], 56 "Input filename", 57 filename=True, 58 is_required=True), 59 #-t=tree_file [default: no tree, generate approximate NJ tree] 60 _Option(["-t", "t"], "Input guide tree filename", 61 filename=True), 62 #-tree="tree_string" [tree in newick format; in double quotes] 63 _Option(["-tree", "tree"], 64 "Input guide tree as Newick string"), 65 #-m=model_file [default: HKY2/WAG] 66 _Option(["-m", "m"], 67 "User-defined alignment model filename. Default: " 68 "HKY2/WAG"), 69 #-o=output_file [default: 'output'] 70 _Option(["-o", "o"], 71 "Output filenames prefix. Default: 'output'\n " 72 "Will write: output.?.fas (depending on requested " 73 "format), output.?.xml and output.?.dnd", 74 filename=True), 75 #-f=output_format [default: 8] 76 _Option(["-f", "f"], 77 "Output alignment format. Default: 8 FASTA\n" 78 "Option are:\n" 79 "1. IG/Stanford 8. Pearson/Fasta\n" 80 "2. GenBank/GB 11. Phylip3.2\n" 81 "3. NBRF 12. Phylip\n" 82 "4. EMBL 14. PIR/CODATA\n" 83 "6. DNAStrider 15. MSF\n" 84 "7. Fitch 17. PAUP/NEXUS", 85 checker_function=lambda x: x in OUTPUT_FORMAT_VALUES), 86 _Switch(["-noxml", "noxml"], 87 "Do not output XML files " 88 "(PRANK versions earlier than v.120626)"), 89 _Switch(["-notree", "notree"], 90 "Do not output dnd tree files " 91 "(PRANK versions earlier than v.120626)"), 92 _Switch(["-showxml", "showxml"], 93 "Output XML files (PRANK v.120626 and later)"), 94 _Switch(["-showtree", "showtree"], 95 "Output dnd tree files (PRANK v.120626 and later)"), 96 _Switch(["-shortnames", "shortnames"], 97 "Truncate names at first space"), 98 _Switch(["-quiet", "quiet"], 99 "Reduce verbosity"), 100 ####################### model parameters: ###################### 101 #+F [force insertions to be always skipped] 102 #-F [equivalent] 103 _Switch(["-F", "+F", "F"], 104 "Force insertions to be always skipped: same as +F"), 105 #-dots [show insertion gaps as dots] 106 _Switch(["-dots", "dots"], 107 "Show insertion gaps as dots"), 108 #-gaprate=# [gap opening rate; default: dna 0.025 / prot 0.0025] 109 _Option(["-gaprate", "gaprate"], 110 "Gap opening rate. Default: dna 0.025 prot 0.0025", 111 checker_function=lambda x: isinstance(x, float)), 112 #-gapext=# [gap extension probability; default: dna 0.5 / prot 0.5] 113 _Option(["-gapext", "gapext"], 114 "Gap extension probability. Default: dna 0.5 " 115 "/ prot 0.5", 116 checker_function=lambda x: isinstance(x, float)), 117 #-dnafreqs=#,#,#,# [ACGT; default: empirical] 118 _Option(["-dnafreqs", "dnafreqs"], 119 "DNA frequencies - 'A,C,G,T'. eg '25,25,25,25' as a quote " 120 "surrounded string value. Default: empirical", 121 checker_function=lambda x: isinstance(x, bytes)), 122 #-kappa=# [ts/tv rate ratio; default:2] 123 _Option(["-kappa", "kappa"], 124 "Transition/transversion ratio. Default: 2", 125 checker_function=lambda x: isinstance(x, int)), 126 #-rho=# [pur/pyr rate ratio; default:1] 127 _Option(["-rho", "rho"], 128 "Purine/pyrimidine ratio. Default: 1", 129 checker_function=lambda x: isinstance(x, int)), 130 #-codon [for DNA: use empirical codon model] 131 #Assuming this is an input file as in -m 132 _Option(["-codon", "codon"], 133 "Codon model filename. Default: empirical codon model"), 134 #-termgap [penalise terminal gaps normally] 135 _Switch(["-termgap", "termgap"], 136 "Penalise terminal gaps normally"), 137 ################ other parameters: ################################ 138 #-nopost [do not compute posterior support; default: compute] 139 _Switch(["-nopost", "nopost"], 140 "Do not compute posterior support. Default: compute"), 141 #-pwdist=# [expected pairwise distance for computing guidetree; 142 #default: dna 0.25 / prot 0.5] 143 _Option(["-pwdist", "pwdist"], 144 "Expected pairwise distance for computing guidetree. " 145 "Default: dna 0.25 / prot 0.5", 146 checker_function=lambda x: isinstance(x, float)), 147 _Switch(["-once", "once"], 148 "Run only once. Default: twice if no guidetree given"), 149 _Switch(["-twice", "twice"], 150 "Always run twice"), 151 _Switch(["-skipins", "skipins"], 152 "Skip insertions in posterior support"), 153 _Switch(["-uselogs", "uselogs"], 154 "Slower but should work for a greater number of sequences"), 155 _Switch(["-writeanc", "writeanc"], 156 "Output ancestral sequences"), 157 _Switch(["-printnodes", "printnodes"], 158 "Output each node; mostly for debugging"), 159 #-matresize=# [matrix resizing multiplier] 160 # Doesnt specify type but Float and Int work 161 _Option(["-matresize", "matresize"], 162 "Matrix resizing multiplier", 163 checker_function=lambda x: isinstance(x, float) or 164 isinstance(x, int)), 165 #-matinitsize=# [matrix initial size multiplier] 166 # Doesnt specify type but Float and Int work 167 _Option(["-matinitsize", "matinitsize"], 168 "Matrix initial size multiplier", 169 checker_function=lambda x: isinstance(x, float) or 170 isinstance(x, int)), 171 _Switch(["-longseq", "longseq"], 172 "Save space in pairwise alignments"), 173 _Switch(["-pwgenomic", "pwgenomic"], 174 "Do pairwise alignment, no guidetree"), 175 #-pwgenomicdist=# [distance for pairwise alignment; default: 0.3] 176 _Option(["-pwgenomicdist", "pwgenomicdist"], 177 "Distance for pairwise alignment. Default: 0.3", 178 checker_function=lambda x: isinstance(x, float)), 179 #-scalebranches=# [scale branch lengths; default: dna 1 / prot 2] 180 _Option(["-scalebranches", "scalebranches"], 181 "Scale branch lengths. Default: dna 1 / prot 2", 182 checker_function=lambda x: isinstance(x, int)), 183 #-fixedbranches=# [use fixed branch lengths] 184 #Assume looking for a float 185 _Option(["-fixedbranches", "fixedbranches"], 186 "Use fixed branch lengths of input value", 187 checker_function=lambda x: isinstance(x, float)), 188 #-maxbranches=# [set maximum branch length] 189 #Assume looking for a float 190 _Option(["-maxbranches", "maxbranches"], 191 "Use maximum branch lengths of input value", 192 checker_function=lambda x: isinstance(x, float)), 193 #-realbranches [disable branch length truncation] 194 _Switch(["-realbranches", "realbranches"], 195 "Disable branch length truncation"), 196 _Switch(["-translate", "translate"], 197 "Translate to protein"), 198 _Switch(["-mttranslate", "mttranslate"], 199 "Translate to protein using mt table"), 200 ###################### other: #################### 201 _Switch(["-convert", "convert"], 202 "Convert input alignment to new format. Do " 203 "not perform alignment") 204 ] 205 AbstractCommandline.__init__(self, cmd, **kwargs)
206 207
208 -def _test():
209 """Run the module's doctests (PRIVATE).""" 210 print("Running modules doctests...") 211 import doctest 212 doctest.testmod() 213 print("Done")
214 215 if __name__ == "__main__": 216 _test() 217