Newick tree parser and renderer
Winter 2022 ~ @TitouanCh
Display trees in the Newick format using this free simple online parser...
Introduction
In early 2022, I became interested in population genetics as I had an upcoming internship in this field.
To get some practice before starting the internship, I decided to work on a simple project: making my own Newick Tree Parser and Renderer.
Newick format
The Newick tree format, named after the restaurant is was created in, is a widely used textual representation for describing hierarchical relationships among biological sequences, such as genetic data or taxa in phylogenetic trees.
It employs parentheses to denote nested groupings of sequences or nodes, with commas separating siblings (sequences or nodes at the same level). For example, a simple Newick tree might look like this: (A:0.1,B:0.2);, where A and B are leaf nodes representing sequences, and 0.1 and 0.2 are branch lengths.
More complex trees can represent nested relationships, such as (A:0.1,(B:0.2,(C:0.3,D:0.4):0.5):0.6);. This simplicity and flexibility make Newick format very useful for storing and exchanging phylogenetic tree structures.
My implementation
The simple renderer above is programmed in javascript, I've utilised recursion to be able to render any possible structure.