Convert a tree edge list into a newick tree
Find a file
2026-06-08 20:18:41 +02:00
media Initial commit 2026-06-08 20:18:41 +02:00
src Initial commit 2026-06-08 20:18:41 +02:00
test Initial commit 2026-06-08 20:18:41 +02:00
.gitignore Initial commit 2026-06-08 20:18:41 +02:00
.python-version Initial commit 2026-06-08 20:18:41 +02:00
Cargo.lock Initial commit 2026-06-08 20:18:41 +02:00
Cargo.toml Initial commit 2026-06-08 20:18:41 +02:00
draw.py Initial commit 2026-06-08 20:18:41 +02:00
pyproject.toml Initial commit 2026-06-08 20:18:41 +02:00
README.md Initial commit 2026-06-08 20:18:41 +02:00
uv.lock Initial commit 2026-06-08 20:18:41 +02:00

graph to newick

a simple program to convert a tree in edge list format (source node, target node) to newick format.

Installation

Requirements

  • Rust

    uses petgraph to handle the graph datastructure and clap for the command line interface.

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:

result tree rendered with biopython