Mercurial > repos > iuc > raxml
view 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 |
line wrap: on
line source
#!/usr/bin/env python """ Runs RAxML on a sequence file. For use with RAxML version 8.2.4 """ import fnmatch import glob import optparse def getint(name): basename = name.partition('RUN.') if basename[2] != '': num = basename[2] return int(num) def __main__(): # Parse the primary wrapper's command line options parser = optparse.OptionParser() # (-b) parser.add_option("--bootseed", action="store", type="int", dest="bootseed", help="Random number for non-parametric bootstrapping") # (-N/#) parser.add_option("--number_of_runs", action="store", type="int", dest="number_of_runs", default=1, help="Number of alternative runs") # (-q) parser.add_option("--multiple_model", action="store", type="string", dest="multiple_model", help="Multiple Model File") # (-x) parser.add_option("--rapid_bootstrap_random_seed", action="store", type="int", dest="rapid_bootstrap_random_seed", help="Rapid Boostrap Random Seed") (options, args) = parser.parse_args() # Multiple runs - concatenate if options.number_of_runs > 1: if options.bootseed is None and options.rapid_bootstrap_random_seed is None: runfiles = glob.glob('RAxML*RUN*') runfiles.sort(key=getint) # Logs with open('RAxML_log.galaxy', 'w') as outfile: for filename in runfiles: if fnmatch.fnmatch(filename, 'RAxML_log.galaxy.RUN.*'): with open(filename, 'r') as infile: for line in infile: outfile.write(line) # Parsimony Trees with open('RAxML_parsimonyTree.galaxy', 'w') as outfile: for filename in runfiles: if fnmatch.fnmatch(filename, 'RAxML_parsimonyTree.galaxy.RUN.*'): with open(filename, 'r') as infile: for line in infile: outfile.write(line) # Results with open('RAxML_result.galaxy', 'w') as outfile: for filename in runfiles: if fnmatch.fnmatch(filename, 'RAxML_result.galaxy.RUN.*'): with open(filename, 'r') as infile: for line in infile: outfile.write(line) # Multiple Model Partition Files if options.multiple_model: files = glob.glob('RAxML_bestTree.galaxy.PARTITION.*') if len(files) > 0: files.sort(key=getint) # Best Tree Partitions with open('RAxML_bestTreePartitions.galaxy', 'w') as outfile: for filename in files: if fnmatch.fnmatch(filename, 'RAxML_bestTree.galaxy.PARTITION.*'): with open(filename, 'r') as infile: for line in infile: outfile.write(line) else: with open('RAxML_bestTreePartitions.galaxy', 'w') as outfile: outfile.write("No partition files were produced.\n") # Result Partitions files = glob.glob('RAxML_result.galaxy.PARTITION.*') if len(files) > 0: files.sort(key=getint) with open('RAxML_resultPartitions.galaxy', 'w') as outfile: for filename in files: if fnmatch.fnmatch(filename, 'RAxML_result.galaxy.PARTITION.*'): with open(filename, 'r') as infile: for line in infile: outfile.write(line) else: with open('RAxML_resultPartitions.galaxy', 'w') as outfile: outfile.write("No partition files were produced.\n") if __name__ == "__main__": __main__()