annotate raxml.py @ 10:655428a2e1e1 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit 59a382f3d13b38074f5778ebd403a4c6d7976eb2
author iuc
date Sat, 05 Nov 2022 17:41:35 +0000
parents d38fcf1b83c5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
1 #!/usr/bin/env python
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
2 """
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
3 Runs RAxML on a sequence file.
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
4 For use with RAxML version 8.2.4
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
5 """
1
b0d6eb76ad87 planemo upload for repository https://github.com/stamatak/standard-RAxML commit 80c5ab90ac30fe083328ef7ad507d2e578daea90
iuc
parents: 0
diff changeset
6 import fnmatch
b0d6eb76ad87 planemo upload for repository https://github.com/stamatak/standard-RAxML commit 80c5ab90ac30fe083328ef7ad507d2e578daea90
iuc
parents: 0
diff changeset
7 import glob
b0d6eb76ad87 planemo upload for repository https://github.com/stamatak/standard-RAxML commit 80c5ab90ac30fe083328ef7ad507d2e578daea90
iuc
parents: 0
diff changeset
8 import optparse
0
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
9
1
b0d6eb76ad87 planemo upload for repository https://github.com/stamatak/standard-RAxML commit 80c5ab90ac30fe083328ef7ad507d2e578daea90
iuc
parents: 0
diff changeset
10
0
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
11 def getint(name):
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
12 basename = name.partition('RUN.')
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
13 if basename[2] != '':
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
14 num = basename[2]
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
15 return int(num)
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
16
1
b0d6eb76ad87 planemo upload for repository https://github.com/stamatak/standard-RAxML commit 80c5ab90ac30fe083328ef7ad507d2e578daea90
iuc
parents: 0
diff changeset
17
0
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
18 def __main__():
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
19 # Parse the primary wrapper's command line options
4
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
20 parser = optparse.OptionParser()
0
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
21 # (-b)
4
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
22 parser.add_option("--bootseed", action="store", type="int", dest="bootseed", help="Random number for non-parametric bootstrapping")
0
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
23 # (-N/#)
4
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
24 parser.add_option("--number_of_runs", action="store", type="int", dest="number_of_runs", default=1, help="Number of alternative runs")
0
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
25 # (-q)
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
26 parser.add_option("--multiple_model", action="store", type="string", dest="multiple_model", help="Multiple Model File")
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
27 # (-x)
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
28 parser.add_option("--rapid_bootstrap_random_seed", action="store", type="int", dest="rapid_bootstrap_random_seed", help="Rapid Boostrap Random Seed")
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
29
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
30 (options, args) = parser.parse_args()
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
31
1
b0d6eb76ad87 planemo upload for repository https://github.com/stamatak/standard-RAxML commit 80c5ab90ac30fe083328ef7ad507d2e578daea90
iuc
parents: 0
diff changeset
32 # Multiple runs - concatenate
4
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
33 if options.number_of_runs > 1:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
34 if options.bootseed is None and options.rapid_bootstrap_random_seed is None:
0
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
35 runfiles = glob.glob('RAxML*RUN*')
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
36 runfiles.sort(key=getint)
4
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
37 # Logs
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
38 with open('RAxML_log.galaxy', 'w') as outfile:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
39 for filename in runfiles:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
40 if fnmatch.fnmatch(filename, 'RAxML_log.galaxy.RUN.*'):
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
41 with open(filename, 'r') as infile:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
42 for line in infile:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
43 outfile.write(line)
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
44 # Parsimony Trees
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
45 with open('RAxML_parsimonyTree.galaxy', 'w') as outfile:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
46 for filename in runfiles:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
47 if fnmatch.fnmatch(filename, 'RAxML_parsimonyTree.galaxy.RUN.*'):
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
48 with open(filename, 'r') as infile:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
49 for line in infile:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
50 outfile.write(line)
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
51 # Results
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
52 with open('RAxML_result.galaxy', 'w') as outfile:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
53 for filename in runfiles:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
54 if fnmatch.fnmatch(filename, 'RAxML_result.galaxy.RUN.*'):
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
55 with open(filename, 'r') as infile:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
56 for line in infile:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
57 outfile.write(line)
0
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
58 # Multiple Model Partition Files
4
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
59 if options.multiple_model:
0
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
60 files = glob.glob('RAxML_bestTree.galaxy.PARTITION.*')
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
61 if len(files) > 0:
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
62 files.sort(key=getint)
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
63 # Best Tree Partitions
4
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
64 with open('RAxML_bestTreePartitions.galaxy', 'w') as outfile:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
65 for filename in files:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
66 if fnmatch.fnmatch(filename, 'RAxML_bestTree.galaxy.PARTITION.*'):
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
67 with open(filename, 'r') as infile:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
68 for line in infile:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
69 outfile.write(line)
0
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
70 else:
4
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
71 with open('RAxML_bestTreePartitions.galaxy', 'w') as outfile:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
72 outfile.write("No partition files were produced.\n")
0
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
73
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
74 # Result Partitions
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
75 files = glob.glob('RAxML_result.galaxy.PARTITION.*')
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
76 if len(files) > 0:
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
77 files.sort(key=getint)
4
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
78 with open('RAxML_resultPartitions.galaxy', 'w') as outfile:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
79 for filename in files:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
80 if fnmatch.fnmatch(filename, 'RAxML_result.galaxy.PARTITION.*'):
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
81 with open(filename, 'r') as infile:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
82 for line in infile:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
83 outfile.write(line)
0
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
84 else:
4
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
85 with open('RAxML_resultPartitions.galaxy', 'w') as outfile:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
86 outfile.write("No partition files were produced.\n")
0
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
87
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
88 # DEBUG options
4
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
89 with open('RAxML_info.galaxy', 'a') as infof:
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
90 infof.write('\nOM: CLI options DEBUG START:\n')
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
91 infof.write(options.__repr__())
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
92 infof.write('\nOM: CLI options DEBUG END\n')
58a0f16c950c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raxml commit b23553a3d29d50e05d8b37a5c5780e3ffc937069
iuc
parents: 3
diff changeset
93
0
934206441123 planemo upload for repository https://github.com/stamatak/standard-RAxML commit baa6a1ec8b3c440cdf73409ccaafcd303e9f4e72
iuc
parents:
diff changeset
94
1
b0d6eb76ad87 planemo upload for repository https://github.com/stamatak/standard-RAxML commit 80c5ab90ac30fe083328ef7ad507d2e578daea90
iuc
parents: 0
diff changeset
95 if __name__ == "__main__":
b0d6eb76ad87 planemo upload for repository https://github.com/stamatak/standard-RAxML commit 80c5ab90ac30fe083328ef7ad507d2e578daea90
iuc
parents: 0
diff changeset
96 __main__()