Skip to content

Document that PhylogenyWrapper.getNodeLabels() and .getParsedNewick() may throw an Error #116

@gaurav

Description

@gaurav

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.

const { graph } = parseNewick(this.phylogeny.newick || '()');

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.

parseNewick(newickTrimmed);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions