-
Notifications
You must be signed in to change notification settings - Fork 0
Description
PhylogenyWrapper.getNodeLabels() and PhylogenyWrapper.getParsedNewick() currently use the parse method in newick-js to parse Newick strings. See also PhylogenyWrapper.getParsedNewickWithIRIs(), which by default uses getParsedNewick() to parse the Newick.
phyx.js/src/wrappers/PhylogenyWrapper.js
Line 155 in d3623e3
| const { graph } = parseNewick(this.phylogeny.newick || '()'); |
phyx.js/src/wrappers/PhylogenyWrapper.js
Line 255 in d3623e3
| const { graph, root, rootWeight } = parseNewick(newick); |
If the Newick string is malformed in particular ways (such as if they're empty), this will throw an Error, which at the moment we propagate to the code calling us. We should document this so that code that calls us knows to check for an exception.
One (slow) way of checking this is to run PhylogenyWrapper.getErrorsInNewickString(), which does wrap parse() -- so you can test whether a Newick string if valid for newick-js/phyx.js purposes by checking to see if this method returns an empty list before using either of the two methods described above. But that's probably unnecessarily complicated for most uses.
phyx.js/src/wrappers/PhylogenyWrapper.js
Line 78 in d3623e3
| parseNewick(newickTrimmed); |