schultzm / Budgitree

GNU Affero General Public License v3.0
4 stars 0 forks source link

Any ideas on how to use this tool in resolving polytomies in IQ-TREE or RAxML outputs? #1

Open Anto007 opened 4 months ago

Anto007 commented 4 months ago

Hi @schultzm, this looks like a very useful tool and thank you for bringing this out. Do you know if this would also work for resolving polytomies in IQ-TREE or RAxML output files? From my quick testing, Budgitree tool (installed via conda on my Ubuntu machine) throws up different errors with both IQ-TREE & RAxML outputs (see below)

budgitree smuggle iqtree.tree > mod_iqtree.tree 
Removing polytomies.
Traceback (most recent call last):
  File "/home/tools/conda_python3.7_env/bin/budgitree", line 8, in <module>
    sys.exit(main())
  File "/home/tools/conda_python3.7_env/lib/python3.7/site-packages/budgitree/__main__.py", line 119, in main
    print(next(trees))
  File "/home/tools/conda_python3.7_env/lib/python3.7/site-packages/Bio/Phylo/NewickIO.py", line 308, in to_strings
    rawtree = newickize(tree.root) + ";"
  File "/home/tools/conda_python3.7_env/lib/python3.7/site-packages/Bio/Phylo/NewickIO.py", line 301, in newickize
    return "(%s)%s" % (",".join(subtrees), label + make_info_string(clade))
  File "/home/tools/conda_python3.7_env/lib/python3.7/site-packages/Bio/Phylo/NewickIO.py", line 300, in <genexpr>
    subtrees = (newickize(sub) for sub in clade)
  File "/home/tools/conda_python3.7_env/lib/python3.7/site-packages/Bio/Phylo/NewickIO.py", line 301, in newickize
    return "(%s)%s" % (",".join(subtrees), label + make_info_string(clade))
  File "/home/tools/conda_python3.7_env/lib/python3.7/site-packages/Bio/Phylo/NewickIO.py", line 300, in <genexpr>
    subtrees = (newickize(sub) for sub in clade)
  File "/home/tools/conda_python3.7_env/lib/python3.7/site-packages/Bio/Phylo/NewickIO.py", line 293, in newickize
    unquoted_label = re.match(token_dict["unquoted node label"], label)
  File "/home/tools/conda_python3.7_env/lib/python3.7/re.py", line 175, in match
    return _compile(pattern, flags).match(string)
RecursionError: maximum recursion depth exceeded

budgitree smuggle RAxML.tree > mod_RAxML.tree 
Removing polytomies.
Traceback (most recent call last):
  File "/home/tools/conda_python3.7_env/bin/budgitree", line 8, in <module>
    sys.exit(main())
  File "/home/tools/conda_python3.7_env/lib/python3.7/site-packages/budgitree/__main__.py", line 87, in main
    t = Tree(tree.format("newick"))
  File "/home/tools/conda_python3.7_env/lib/python3.7/site-packages/ete3/coretype/tree.py", line 213, in __init__
    quoted_names=quoted_node_names)
  File "/home/tools/conda_python3.7_env/lib/python3.7/site-packages/ete3/parser/newick.py", line 266, in read_newick
    return _read_newick_from_string(nw, root_node, matcher, format, quoted_names)
  File "/home/tools/conda_python3.7_env/lib/python3.7/site-packages/ete3/parser/newick.py", line 341, in _read_newick_from_string
    _read_node_data(closing_internal, current_parent, "internal", matcher, formatcode)
  File "/home/tools/conda_python3.7_env/lib/python3.7/site-packages/ete3/parser/newick.py", line 445, in _read_node_data
    raise NewickError("Unexpected newick format '%s' " %subnw[0:50])
ete3.parser.newick.NewickError: Unexpected newick format ':0.15726[100]'
Anto007 commented 4 months ago

Just in case anyone runs into a similar issue, the below alternative on ete3 python toolkit worked for me with the output treefile from IQ-TREE:

from ete3 import Tree
t=Tree('iqtree.tree', format=1)
t.resolve_polytomy(recursive=True)
t.write(format=1, outfile="mod_iqtree.tree") 
schultzm commented 3 weeks ago

Thanks @Anto007. If you could send the trees that were causing you problems, I can run some tests. I have only tested with FastTree output.