jeetsukumaran / DendroPy

A Python library for phylogenetic scripting, simulation, data processing and manipulation.
https://pypi.org/project/DendroPy/.
BSD 3-Clause "New" or "Revised" License
210 stars 61 forks source link

NewickReaderMalformedStatementError: NewickReaderMalformedStatementError #107

Closed snowflake01986 closed 1 year ago

snowflake01986 commented 5 years ago

As described, there are some '=' in my node labels, which caused collapse when I used dendropy.Tree.get to read the tree file. There is some method to avoid this, is there?

mmore500 commented 1 year ago

Hi @snowflake01986,

A possible suggestion, you might try surrounding the labels containing = with ' characters in the source file if you are loading tree from file. Many formats do not allow unquoted punctuation characters.

As an illustration,

>>> import dendropy
>>> 
>>> s1 = "(A,('b=b',c_c));"
>>> tree1 = dendropy.Tree.get(
...          data=s1,
...          schema="newick",
... )
>>> 
>>> print(tree1.as_string("newick"))
(A,('b=b',c_c));

>>> 
>>> for node in tree1:
...   print(node)
... 
<Node object at 0x7f7d82247d60: 'None' (None)>
<Node object at 0x7f7d82247d30: 'None' (<Taxon 0x7f7d82247c70 'A'>)>
<Node object at 0x7f7d82247c10: 'None' (None)>
<Node object at 0x7f7d82247bb0: 'None' (<Taxon 0x7f7d82247ac0 'b=b'>)>
<Node object at 0x7f7d82247a60: 'None' (<Taxon 0x7f7d82247a00 'c c'>)>

Closing this for now, feel free to reopen.