Reconstructs a genome phylogeny from pairwise Average Nucleotide Identity (ANI) using an all-vs-all FastANI comparison. The similarity matrix is converted to a distance matrix, a neighbor-joining tree is inferred with QuickTree, and the result is previewed as ASCII via gotree.
.
├── data/ # Input genome FASTA files (*.fasta)
├── results/ # Output files (created at runtime)
├── run_ani_pipeline.sh # Main pipeline script
├── convert_ani_to_distance.py # FastANI matrix → Newick converter
└── README.md
| Tool | Purpose | Install |
|---|---|---|
fastANI |
All-vs-all ANI computation | GitHub |
quicktree |
Neighbor-joining tree inference | GitHub |
gotree |
ASCII tree preview | GitHub |
Requires Python 3.7+.
pip install pandas scikit-bioPlace all genome FASTA files (.fasta) in a single directory, e.g. data/.
bash Run_ani.sh <genome_dir> [threads] [output_prefix]| Argument | Required | Default | Description |
|---|---|---|---|
genome_dir |
Yes | — | Directory containing *.fasta genome files |
threads |
No | 16 |
Number of CPU threads for FastANI |
output_prefix |
No | fastani_output |
Prefix for output file names |
Example:
bash run_ani_pipeline.sh data/ 8 my_genomesconvert_ani_to_distance.py can also be run independently if you already have a FastANI .matrix file:
python3 ANI_Newick.py -i fastani_output.txt.matrix -o ani_tree.nwk| Flag | Required | Default | Description |
|---|---|---|---|
-i / --input |
Yes | — | FastANI .matrix file |
-o / --output |
No | fastani_tree.nwk |
Output Newick file |
Enumerates all *.fasta files in the input directory and writes paths to genome_list.txt. Exits early if fewer than 2 genomes are found.
Runs FastANI in all-vs-all mode using --matrix to produce both a pairwise table and a triangular similarity matrix.
convert_ani_to_distance.py parses the FastANI lower-triangular matrix, repairs any merged decimal numbers (a known FastANI output artifact), and converts ANI similarity to distance:
distance = 1 − (ANI / 100)
Missing values (NA) are treated as 0.0. The diagonal is set to 100.0 (self-identity). The result is written as a PHYLIP-format distance matrix.
QuickTree reads the PHYLIP distance matrix and infers a neighbor-joining tree, written in Newick format.
gotree renders the tree as ASCII to the terminal for a quick sanity check.
| File | Description |
|---|---|
<prefix>.txt |
Raw FastANI pairwise ANI values |
<prefix>.txt.matrix |
FastANI lower-triangular similarity matrix |
distance_matrix.phy |
PHYLIP distance matrix (QuickTree input) |
ani_tree.nwk |
Final neighbor-joining tree (Newick format) |
ANI measures nucleotide-level sequence identity between two genomes across shared genomic regions. Common interpretation thresholds:
| ANI | Interpretation |
|---|---|
| ≥ 95% | Generally accepted species boundary |
| 80–95% | Genus-level divergence (approximate) |
| < 80% | Deeper divergence; ANI less informative |
The NJ tree produced here reflects overall genomic similarity, not a formal phylogenomic reconstruction. For publication-quality phylogenies, consider corroborating with core-genome or marker-gene approaches.