# HG changeset patch # User earlhaminst # Date 1489782219 14400 # Node ID a4ba317fc713271b07acda8985949d5aa6fc29ca # Parent 276e3ee68c3772adaba21b45ac52a9ac8bc029a2 planemo upload for repository https://github.com/TGAC/earlham-galaxytools/tree/master/tools/ete commit df73a2add6dba8550867034e157ed0699b3b2f53 diff -r 276e3ee68c37 -r a4ba317fc713 ete_species_tree_generator.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ete_species_tree_generator.py Fri Mar 17 16:23:39 2017 -0400 @@ -0,0 +1,56 @@ +import optparse + +from ete3 import NCBITaxa + +ncbi = NCBITaxa() + +parser = optparse.OptionParser() +parser.add_option('-s', '--species', dest="input_species_filename", + help='Species list in text format one species in each line') + +parser.add_option('-f', '--format', type='choice', choices=['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '100'], dest="format", + default='8', help='outpur format for tree') + +parser.add_option('-t', '--treebest', type='choice', choices=['yes', 'no'], dest="treebest", + default='no', help='To be used in TreeBest') + +parser.add_option('-d', '--database', type='choice', choices=['yes', 'no'], dest="database", + default='no', help='Update database') + +options, args = parser.parse_args() + +if options.database == "yes": + try: + ncbi.update_taxonomy_database() + except: + pass + +if options.input_species_filename is None: + raise Exception('-s option must be specified, Species list in text format one species in each line') + +with open(options.input_species_filename) as f: + species_name = [_.strip().replace('_', ' ') for _ in f.readlines()] + +name2taxid = ncbi.get_name_translator(species_name) + +taxid = [name2taxid[_][0] for _ in species_name] + +tree = ncbi.get_topology(taxid) + +if options.treebest == "yes": + inv_map = {str(v[0]): k.replace(" ", "") + "*" for k, v in name2taxid.items()} +else: + inv_map = {str(v[0]): k for k, v in name2taxid.items()} + + +for leaf in tree: + leaf.name = inv_map[leaf.name] + +newickTree = tree.write(format=int(options.format)) + +if options.treebest == "yes": + newickTree = newickTree.rstrip(';') + newickTree = newickTree + "root;" + +with open('newickTree.nhx', 'w') as newickFile: + newickFile.write(newickTree) diff -r 276e3ee68c37 -r a4ba317fc713 ete_species_tree_generator.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ete_species_tree_generator.xml Fri Mar 17 16:23:39 2017 -0400 @@ -0,0 +1,90 @@ + + from a list of species using the ETE Toolkit + + ete3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10.1093/molbev/msw046 + + diff -r 276e3ee68c37 -r a4ba317fc713 ete_tree_generator.py --- a/ete_tree_generator.py Thu Dec 15 12:55:02 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -import optparse - -from ete3 import NCBITaxa - -ncbi = NCBITaxa() - -parser = optparse.OptionParser() -parser.add_option('-s', '--species', dest="input_species_filename", - help='Species list in text format one species in each line') - -parser.add_option('-f', '--format', type='choice', choices=['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '100'], dest="format", - default='8', help='outpur format for tree') - -parser.add_option('-t', '--treebest', type='choice', choices=['yes', 'no'], dest="treebest", - default='no', help='To be used in TreeBest') - -parser.add_option('-d', '--database', type='choice', choices=['yes', 'no'], dest="database", - default='no', help='Update database') - -options, args = parser.parse_args() - -if options.database == "yes": - try: - ncbi.update_taxonomy_database() - except: - pass - -if options.input_species_filename is None: - raise Exception('-s option must be specified, Species list in text format one species in each line') - -with open(options.input_species_filename) as f: - species_name = [_.strip().replace('_', ' ') for _ in f.readlines()] - -name2taxid = ncbi.get_name_translator(species_name) - -taxid = [name2taxid[_][0] for _ in species_name] - -tree = ncbi.get_topology(taxid) - -if options.treebest == "yes": - inv_map = {str(v[0]): k.replace(" ", "") + "*" for k, v in name2taxid.items()} -else: - inv_map = {str(v[0]): k for k, v in name2taxid.items()} - - -for leaf in tree: - leaf.name = inv_map[leaf.name] - -newickTree = tree.write(format=int(options.format)) - -if options.treebest == "yes": - newickTree = newickTree.rstrip(';') - newickTree = newickTree + "root;" - -with open('newickTree.nhx', 'w') as newickFile: - newickFile.write(newickTree) diff -r 276e3ee68c37 -r a4ba317fc713 ete_tree_generator.xml --- a/ete_tree_generator.xml Thu Dec 15 12:55:02 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ - - from a list of species using the ETE Toolkit - - ete3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10.1093/molbev/msw046 - -