Cannot set myself as outgroup catch

This commit is contained in:
Godwin Ani 2024-04-01 11:09:45 -04:00 committed by GitHub
parent 21e54ab7e4
commit 81a46d2714
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -214,18 +214,20 @@ def write_nexus(newick, leaf_colors, params):
def tree_formatting_wrapper(file):
try:
newick = get_newick(file)
tree = ete3.Tree(newick)
majs = list(dict.fromkeys([leaf.name[:2] for leaf in tree]))
#Only try to reroot trees with more than 2 major clades. This was added to fix the ETE3 "Cannot set myself as outgroup" error
if len(majs) > 2:
tree = reroot(tree)
tree.ladderize(direction = 1)
tree.write(outfile = 'ColoredTrees/' + file.split('/')[-1].split('.tree')[0] + '_Colored.tree')
except Exception as e:
print(f" {file.split('/')[-1]} has {e} error ")
def color(file, args):