Convert a tree edge list into a newick tree
| media | ||
| src | ||
| test | ||
| .gitignore | ||
| .python-version | ||
| Cargo.lock | ||
| Cargo.toml | ||
| draw.py | ||
| pyproject.toml | ||
| README.md | ||
| uv.lock | ||
graph to newick
a simple program to convert a tree in edge list format (source node, target node) to newick format.
Installation
Requirements
From source
Clone this repository
git clone https://forge.s1gm4.eu/sortion/graph-to-newick.git
cd graph-to-newick
Build the binary
cargo build --release
The binary will be in ./target/release/graph-to-newick.
Usage
graph-to-newick requires an input TSV file with two columns: (1) source node, (2) target node, or in tree language (1) child node, (2) parent node, and the name of the root node.
It outputs the tree for the given root node in Newick format.
Example
With example graph file ./test/test.abc:
A B
B C
C D
E C
F C
G B
graph-to-newick --input ./test/test.abc --root D > ./test/test.newick
It would output to stdout:
(((F,E,(G,A)B)C)D);
Rendered with biopython, we have:
