nj.rs
Neighbor-Joining phylogenetic tree inference in Rust, with Python and WASM bindings.
Takes a mutiple sequence alignment and returns a Newick string. Alphabet (DNA/protein) is auto-detected. Supports optional bootstrap support values on internal nodes. Optionally, only the distance matrix or average distance can be computed. Wrappers use a plugin system for implementing progress/error logging.
Substitution models: PDiff (DNA + protein), JukesCantor (DNA), Kimura2P (DNA), Poisson (protein)
CLI
A progress bar is shown on stderr when bootstrapping.
Rust
[]
= "0.0.18"
use ;
use SubstitutionModel;
// Parse from a FASTA string
let sequences = parse_fasta?;
// Run Neighbor-Joining
let newick = nj?;
Distance-only computation (no tree, no bootstrap):
use ;
use SubstitutionModel;
let result = distance_matrix?;
// result.names — Vec<String> of taxon names
// result.matrix — n×n Vec<Vec<f64>>, symmetric, diagonal zero
average_distance takes the same DistConfig and returns the mean of all pairwise distances as an f64.
Python
=
=
Distance-only computation:
=
# result["names"] — list of taxon names
# result["matrix"] — n×n list of lists, symmetric, diagonal zero
JavaScript / WASM
import from '@holmrenser/nj';
const msa = ;
const newick = ;
const = ;