annotate raxml.py @ 7:b1e68bbe4cef draft default tip

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