Skip to content

Parsing phylogenetic trees (newick format) #51

@LCrossman

Description

@LCrossman

Is your feature request related to a problem? Please describe.

Would like to add parsing of newick format just to print the newick in the first place. Newick is described here:https://en.wikipedia.org/wiki/Newick_format. It is possible to get multiple newick trees inside a single file, they each finish with a semicolon. Some trees can have many nodes, the structure is a graph-type with nodes, edges and leaves. There is an XML format that some python programs parse newick into, phyloXML

Describe the solution you'd like

Looking to start a module phylo.rs with a parse of newick into some type of good struct or hashmap in the first place, with just ability to print it out.

Describe alternatives you've considered

There are some newick tree parsers in crates.io but they all seem to be a few years old, for example newick_0.11.0

Additional context

Various types of newick tree to parse: The one below marked as "popular" is the one I've seen much the most often, so we could concentrate on that structure and allow the others if possible. There are multiple nodes.
(,,(,)); no nodes are named
(A,B,(C,D)); leaf nodes are named
(A,B,(C,D)E)F; all nodes are named
(:0.1,:0.2,(:0.3,:0.4):0.5); all but root node have a distance to parent
(:0.1,:0.2,(:0.3,:0.4):0.5):0.0; all have a distance to parent
(A:0.1,B:0.2,(C:0.3,D:0.4):0.5); distances and leaf names (popular)
(A:0.1,B:0.2,(C:0.3,D:0.4)E:0.5)F; distances and all names
((B:0.2,(C:0.3,D:0.4)E:0.5)F:0.1)A; a tree rooted on a leaf node (rare)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions