[SOLVED] Errors loading in a treefile using ETE3
1
1
Entering edit mode
2.1 years ago
k.williamson ▴ 10

Hi there,

I am trying to load a treefile with ete3 using the following:

from ete3 import Tree
t=Tree("ROOT_LGM60.treefile")

However, when I do this, I get the following error messages:

Traceback (most recent call last):
  File "C:/Users/kelse/OneDrive/Documents/Script_Test/leaf_rename.py", line 11, in <module>
    t=Tree('ROOT_LGM60.treefile', format=0)
  File "C:\Users\kelse\Anaconda3\lib\site-packages\ete3\coretype\tree.py", line 213, in __init__
    quoted_names=quoted_node_names)
  File "C:\Users\kelse\Anaconda3\lib\site-packages\ete3\parser\newick.py", line 266, in read_newick
    return _read_newick_from_string(nw, root_node, matcher, format, quoted_names)
  File "C:\Users\kelse\Anaconda3\lib\site-packages\ete3\parser\newick.py", line 341, in _read_newick_from_string
    _read_node_data(closing_internal, current_parent, "internal", matcher, formatcode)
  File "C:\Users\kelse\Anaconda3\lib\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 '100/100:0.1675844217' 
You may want to check other newick loading flags like 'format' or 'quoted_node_names'.

I think it is having an issue with the support values, but I am not sure. This tree was generated using IQ-TREE with aLRT/UFBOOT support. Here is an portion of what the treefile itself looks like:

(0:0.3740934650,(((((((((((1:0.5940078752,46:0.4962741857)100/100:0.1675844217,57:0.6477068763)30.7/67:0.0400940719,88:0.5505298303) ...and so on.

Any help with how to fix this would be appreciated!

Thanks, Kelsey

etetoolkit • 1.5k views
ADD COMMENT
2
Entering edit mode
2.1 years ago
cfos4698 ★ 1.1k

Based on https://groups.google.com/g/etetoolkit/c/8Cl69X7oIg4, you'll have to choose one of the support values to be represented in ete3. You first read in the tree with format=1, which means the tree format is "flexible with internal node names" (http://etetoolkit.org/docs/latest/tutorial/tutorial_trees.html#reading-and-writing-newick-trees), then choose which of the support values from iqtree to use.

tree = Tree("newick", format=1)
for node in tree: 
  if not node.is_leaf():
   node.support = float(node.name.split("/")[1])

You could (e.g.) choose the first value: node.support = float(node.name.split("/")[0])

ADD COMMENT
0
Entering edit mode

Thank you! This solved the problem

ADD REPLY

Login before adding your answer.

Traffic: 1602 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6