1
2
3
4
5 """Command-line wrapper for the tree inference program RAxML.
6
7 Derived from the help page for RAxML version 7.3 by Alexandros Stamatakis, but
8 should work for any version 7.X (and probably earlier for most options).
9 """
10 from __future__ import print_function
11 from Bio._py3k import basestring
12
13 __docformat__ = "restructuredtext en"
14
15 from Bio.Application import _Option, _Switch, AbstractCommandline
16
17
19 """Command-line wrapper for the tree inference program RAxML.
20
21 The required parameters are 'sequences' (-s), 'model' (-m) and 'name' (-n).
22 The parameter 'parsimony_seed' (-p) must also be set for RAxML, but if you
23 do not specify it, this wrapper will set the seed to 10000 for you.
24
25 Example:
26
27 >>> from Bio.Phylo.Applications import RaxmlCommandline
28 >>> raxml_cline = RaxmlCommandline(sequences="Tests/Phylip/interlaced2.phy",
29 ... model="PROTCATWAG", name="interlaced2")
30 >>> print(raxml_cline)
31 raxmlHPC -m PROTCATWAG -n interlaced2 -p 10000 -s Tests/Phylip/interlaced2.phy
32
33 You would typically run the command line with raxml_cline() or via
34 the Python subprocess module, as described in the Biopython tutorial.
35
36 Citation:
37
38 Stamatakis A.
39 RAxML-VI-HPC: Maximum Likelihood-based Phylogenetic Analyses with
40 Thousands of Taxa and Mixed Models.
41 Bioinformatics 2006, 22(21):2688-2690.
42
43 Homepage: http://sco.h-its.org/exelixis/software.html
44 """
45
46 - def __init__(self, cmd='raxmlHPC', **kwargs):
47 self.parameters = [
48 _Option(['-a', 'weight_filename'],
49 "Name of a column weight file to assign individual weights "
50 "to each column of the alignment. Those weights must be "
51 "integers separated by any type and number of whitespaces "
52 "within a separate file.",
53 filename=True,
54 equate=False,
55 ),
56
57 _Option(['-b', 'bootstrap_seed'],
58 "Random seed for bootstrapping.",
59 equate=False,
60 ),
61
62 _Option(['-c', 'num_categories'],
63 "Number of distinct rate categories for RAxML when "
64 "evolution model is set to GTRCAT or GTRMIX."
65 "Individual per-site rates are categorized into this "
66 "many rate categories to accelerate computations. "
67 "Default: 25.",
68 equate=False,
69 ),
70
71 _Switch(['-d', 'random_starting_tree'],
72 "Start ML optimization from random starting tree."
73 ),
74
75 _Option(['-e', 'epsilon'],
76 "Set model optimization precision in log likelihood units "
77 "for final optimization of tree topology under MIX/MIXI "
78 "or GAMMA/GAMMAI."
79 "Default: 0.1 for models not using proportion of "
80 "invariant sites estimate; 0.001 for models using "
81 "proportion of invariant sites estimate.",
82 equate=False,
83 ),
84
85 _Option(['-E', 'exclude_filename'],
86 "An exclude file name, containing a specification of "
87 "alignment positions you wish to exclude. Format is "
88 "similar to Nexus, the file shall contain entries like "
89 "'100-200 300-400'; to exclude a single column write, "
90 "e.g., '100-100'. If you use a mixed model, an "
91 "appropriately adapted model file will be written.",
92 filename=True,
93 equate=False,
94 ),
95
96 _Option(['-f', 'algorithm'],
97 """Select algorithm:
98 a: Rapid Bootstrap analysis and search for best-scoring ML
99 tree in one program run.
100 b: Draw bipartition information on a tree provided with '-t'
101 based on multiple trees (e.g. form a bootstrap) in a file
102 specifed by '-z'.
103 c: Check if the alignment can be properly read by RAxML.
104 d: New rapid hill-climbing (DEFAULT).
105 e: Optimize model+branch lengths for given input tree under
106 GAMMA/GAMMAI only.
107 g: Compute per site log Likelihoods for one ore more trees
108 passed via '-z' and write them to a file that can be read
109 by CONSEL.
110 h: Compute log likelihood test (SH-test) between best tree
111 passed via '-t' and a bunch of other trees passed via '-z'.
112 i: Perform a really thorough bootstrap, refinement of final
113 bootstrap tree under GAMMA and a more exhaustive algorithm.
114 j: Generate a bunch of bootstrapped alignment files from an
115 original alignemnt file.
116 m: Compare bipartitions between two bunches of trees passed
117 via '-t' and '-z' respectively. This will return the
118 Pearson correlation between all bipartitions found in the
119 two tree files. A file called
120 RAxML_bipartitionFrequencies.outputFileName will be
121 printed that contains the pair-wise bipartition
122 frequencies of the two sets.
123 n: Compute the log likelihood score of all trees contained
124 in a tree file provided by '-z' under GAMMA or
125 GAMMA+P-Invar.
126 o: Old and slower rapid hill-climbing.
127 p: Perform pure stepwise MP addition of new sequences to an
128 incomplete starting tree.
129 s: Split up a multi-gene partitioned alignment into the
130 respective subalignments.
131 t: Do randomized tree searches on one fixed starting tree.
132 w: Compute ELW test on a bunch of trees passed via '-z'.
133 x: Compute pair-wise ML distances, ML model parameters will
134 be estimated on an MP starting tree or a user-defined
135 tree passed via '-t', only allowed for GAMMA-based models
136 of rate heterogeneity.""",
137 checker_function=(lambda x:
138 isinstance(x, basestring) and len(x) == 1),
139 equate=False,
140 ),
141
142 _Option(['-g', 'grouping_constraint'],
143 "File name of a multifurcating constraint tree. "
144 "this tree does not need to be comprehensive, i.e. "
145 "contain all taxa.",
146 filename=True,
147 equate=False,
148 ),
149
150 _Option(['-i', 'rearrangements'],
151 "Initial rearrangement setting for the subsequent "
152 "application of topological changes phase.",
153 equate=False,
154 ),
155
156 _Switch(['-j', 'checkpoints'],
157 "Write checkpoints (intermediate tree topologies)."
158 ),
159
160 _Switch(['-k', 'bootstrap_branch_lengths'],
161 "Print bootstrapped trees with branch lengths. "
162 "The bootstraps will run a bit longer, because model "
163 "parameters will be optimized at the end of each run. "
164 "Use with CATMIX/PROTMIX or GAMMA/GAMMAI."
165 ),
166
167 _Option(['-l', 'cluster_threshold'],
168 "Threshold for sequence similarity clustering. "
169 "RAxML will then print out an alignment to a file "
170 "called sequenceFileName.reducedBy.threshold that "
171 "only contains sequences <= the specified threshold "
172 "that must be between 0.0 and 1.0. RAxML uses the "
173 "QT-clustering algorithm to perform this task. "
174 "In addition, a file called "
175 "RAxML_reducedList.outputFileName will be written "
176 "that contains clustering information.",
177 equate=False,
178 ),
179
180 _Option(['-L', 'cluster_threshold_fast'],
181 "Same functionality as '-l', but uses a less "
182 "exhaustive and thus faster clustering algorithm. "
183 "This is intended for very large datasets with more "
184 "than 20,000-30,000 sequences.",
185 equate=False,
186 ),
187
188 _Option(['-m', 'model'],
189 """Model of Nucleotide or Amino Acid Substitution:
190
191 NUCLEOTIDES:
192
193 GTRCAT : GTR + Optimization of substitution rates + Optimization of site-specific
194 evolutionary rates which are categorized into numberOfCategories distinct
195 rate categories for greater computational efficiency
196 if you do a multiple analysis with '-#' or '-N' but without bootstrapping the program
197 will use GTRMIX instead
198 GTRGAMMA : GTR + Optimization of substitution rates + GAMMA model of rate
199 heterogeneity (alpha parameter will be estimated)
200 GTRMIX : Inference of the tree under GTRCAT
201 and thereafter evaluation of the final tree topology under GTRGAMMA
202 GTRCAT_GAMMA : Inference of the tree with site-specific evolutionary rates.
203 However, here rates are categorized using the 4 discrete GAMMA rates.
204 Evaluation of the final tree topology under GTRGAMMA
205 GTRGAMMAI : Same as GTRGAMMA, but with estimate of proportion of invariable sites
206 GTRMIXI : Same as GTRMIX, but with estimate of proportion of invariable sites
207 GTRCAT_GAMMAI : Same as GTRCAT_GAMMA, but with estimate of proportion of invariable sites
208
209 AMINO ACIDS:
210
211 PROTCATmatrixName[F] : specified AA matrix + Optimization of substitution rates + Optimization of site-specific
212 evolutionary rates which are categorized into numberOfCategories distinct
213 rate categories for greater computational efficiency
214 if you do a multiple analysis with '-#' or '-N' but without bootstrapping the program
215 will use PROTMIX... instead
216 PROTGAMMAmatrixName[F] : specified AA matrix + Optimization of substitution rates + GAMMA model of rate
217 heterogeneity (alpha parameter will be estimated)
218 PROTMIXmatrixName[F] : Inference of the tree under specified AA matrix + CAT
219 and thereafter evaluation of the final tree topology under specified AA matrix + GAMMA
220 PROTCAT_GAMMAmatrixName[F] : Inference of the tree under specified AA matrix and site-specific evolutionary rates.
221 However, here rates are categorized using the 4 discrete GAMMA rates.
222 Evaluation of the final tree topology under specified AA matrix + GAMMA
223 PROTGAMMAImatrixName[F] : Same as PROTGAMMAmatrixName[F], but with estimate of proportion of invariable sites
224 PROTMIXImatrixName[F] : Same as PROTMIXmatrixName[F], but with estimate of proportion of invariable sites
225 PROTCAT_GAMMAImatrixName[F] : Same as PROTCAT_GAMMAmatrixName[F], but with estimate of proportion of invariable sites
226
227 Available AA substitution models: DAYHOFF, DCMUT, JTT, MTREV, WAG, RTREV, CPREV, VT, BLOSUM62, MTMAM, GTR
228 With the optional 'F' appendix you can specify if you want to use empirical base frequencies
229 Please not that for mixed models you can in addition specify the per-gene AA model in
230 the mixed model file (see manual for details)
231 """,
232 equate=False,
233 ),
234
235 _Switch(['-M', 'partition_branch_lengths'],
236 "Switch on estimation of individual per-partition "
237 "branch lengths. Only has effect when used in "
238 "combination with 'partition_filename' ('-q'). "
239 "Branch lengths for individual partitions will be "
240 "printed to separate files. A weighted average of the "
241 "branch lengths is computed by using the respective "
242 "partition lengths. "
243 ),
244
245 _Option(['-n', 'name'],
246 "Name used in the output files.",
247 filename=True,
248 equate=False,
249 ),
250
251 _Option(['-o', 'outgroup'],
252 "Name of a single outgroup or a comma-separated list "
253 "of outgroups, eg '-o Rat' or '-o Rat,Mouse'. In case "
254 "that multiple outgroups are not monophyletic the "
255 "first name in the list will be selected as outgroup. "
256 "Don't leave spaces between taxon names!",
257 checker_function=lambda x: len(x.split()) == 1,
258 equate=False,
259 ),
260
261 _Option(['-q', 'partition_filename'],
262 "File name containing the assignment of models to "
263 "alignment partitions for multiple models of "
264 "substitution. For the syntax of this file please "
265 "consult the RAxML manual.",
266 filename=True,
267 equate=False,
268 ),
269
270 _Option(['-p', 'parsimony_seed'],
271 "Random number seed for the parsimony inferences. "
272 "This allows you to reproduce your results and will "
273 "help developers debug the program. This option HAS "
274 "NO EFFECT in the parallel MPI version.",
275 equate=False,
276 ),
277
278 _Option(['-P', 'protein_model'],
279 "File name of a user-defined AA (Protein) substitution "
280 "model. This file must contain 420 entries, the first "
281 "400 being the AA substitution rates (this must be a "
282 "symmetric matrix) and the last 20 are the empirical "
283 "base frequencies.",
284 filename=True,
285 equate=False,
286 ),
287
288 _Option(['-r', 'binary_constraint'],
289 "File name of a binary constraint tree. "
290 "This tree does not need to be comprehensive, i.e. "
291 "contain all taxa.",
292 filename=True,
293 equate=False,
294 ),
295
296 _Option(['-s', 'sequences'],
297 "Name of the alignment data file, in PHYLIP format.",
298 filename=True,
299 equate=False,
300 ),
301
302 _Option(['-t', 'starting_tree'],
303 "File name of a user starting tree, in Newick format.",
304 filename=True,
305 equate=False,
306 ),
307
308 _Option(['-T', 'threads'],
309 "Number of threads to run. "
310 "PTHREADS VERSION ONLY! "
311 "Make sure to set this at most the number of CPUs "
312 "you have on your machine, otherwise, there will be "
313 "a huge performance decrease!",
314 equate=False,
315 ),
316
317 _Option(['-u', 'num_bootstrap_searches'],
318 "Number of multiple bootstrap searches per replicate. "
319 "Use this to obtain better ML trees for each "
320 "replicate. Default: 1 ML search per bootstrap "
321 "replicate.",
322 equate=False,
323 ),
324
325 _Switch(['-v', 'version'],
326 "Display version information."
327 ),
328
329 _Option(['-w', 'working_dir'],
330 "Name of the working directory where RAxML will "
331 "write its output files. Default: current directory.",
332 filename=True,
333 equate=False,
334 ),
335
336 _Option(['-x', 'rapid_bootstrap_seed'],
337 "Random seed for rapid bootstrapping.",
338 equate=False,
339 ),
340
341 _Switch(['-y', 'parsimony'],
342 "Only compute a parsimony starting tree, then exit."
343 ),
344
345 _Option(['-z', 'bipartition_filename'],
346 "Name of a file containing multiple trees, e.g. from "
347 "a bootstrap run, that shall be used to draw "
348 "bipartition values onto a tree provided with '-t'. "
349 "It can also be used to compute per-site log "
350 "likelihoods in combination with '-f g', and to read "
351 "a bunch of trees for a couple of other options "
352 "('-f h', '-f m', '-f n').",
353 filename=True,
354 equate=False,
355 ),
356
357 _Option(['-N', '-#', 'num_replicates'],
358 "Number of alternative runs on distinct starting trees. "
359 "In combination with the '-b' option, this will invoke a "
360 "multiple bootstrap analysis. "
361 "DEFAULT: 1 single analysis."
362 "Note that '-N' has been added as an alternative since "
363 "'-#' sometimes caused problems with certain MPI job "
364 "submission systems, since '-#' is often used to start "
365 "comments. ",
366 equate=False,
367 ),
368 ]
369 AbstractCommandline.__init__(self, cmd, **kwargs)
370
371 if not self.parsimony_seed:
372 self.parsimony_seed = 10000
373