beast2 icon indicating copy to clipboard operation
beast2 copied to clipboard

TreeParser does not seem to correctly initialise m_storedNodes

Open tgvaughan opened this issue 2 years ago • 0 comments
trafficstars

To reproduce, create a TreeParser instance with a labeled newick string and set IsLabelledTree="true". Following the part of initAndValidate() responsible for sorting the labels alphabetically, the leaf nodes in m_nodes[] will have different IDs for a given node number compared with those in m_storedNodes[].

The side effect of this is that one cannot rely on node.getID() to return the taxon name for a given node, as this mapping - while initially okay - is broken once a state.restore() is performed.

While it's easy to fix the alphabetical sorting to update both m_nodes and m_storedNodes instead of only m_nodes, I'm not sure it's really necessary: It's possible/likely that my occasional use of node.getID() to obtain taxon labels is non-idiomatic/deprecated in favour of tree.getTaxonName(node). But maybe we should fix this anyway just to avoid difficult-to-diagnose problems when programmers occasionally do the wrong thing? :)

tgvaughan avatar Dec 22 '22 12:12 tgvaughan