etetoolkit / ete

Python package for building, comparing, annotating, manipulating and visualising trees. It provides a comprehensive API and a collection of command line tools, including utilities to work with the NCBI taxonomy tree.
http://etetoolkit.org
GNU General Public License v3.0
782 stars 212 forks source link

Using all names in newick format raise NewickError #644

Closed ElpadoCan closed 2 years ago

ElpadoCan commented 2 years ago

The following code raises the NewickError. It seems like any notation with all names raises this exception.

from ete3 import Tree

newick = '((D,F)E,(B,H)B);'

t = Tree(newick)

print(t)
Traceback (most recent call last):
  File "g:\My Drive\01_Postdoc_HMGU\Python_MyScripts\MIA\Git\Cell_ACDC\cellacdc\test1.py", line 5, in <module>
    t = Tree(newick)
  File "C:\Users\Frank\.virtualenvs\acdc\lib\site-packages\ete3\coretype\tree.py", line 212, in __init__
    read_newick(newick, root_node = self, format=format,
  File "C:\Users\Frank\.virtualenvs\acdc\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\Frank\.virtualenvs\acdc\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\Frank\.virtualenvs\acdc\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 'E'
You may want to check other newick loading flags like 'format' or 'quoted_node_names'.

I am using Python 3.9.7 64 bit on Windows 10. Virtual environment created with pyenv. ete3 version 3.1.2 installed with pip.

jhcepas commented 2 years ago

for internal node names encoded in newick, use Tree(newick, format=1)