TurboANI is a super fast, homology-aware Average Nucleotide Identity (or ANI) estimation algorithm.
It will replace FastANI as the new community standard for ANI estimation.
The main algorithm flow:
- Build a reference minimizer lookup. Intial reference window identification with inverted index.
- L1: Cluster query-fragment minimizer seed hits into candidate reference intervals (via diagnoal clustering), followed by minimap2 chaining or the much slower optimal ChainX (co-linear chaining).
- L2: slide query-length windows over each L1 window interval and score them via a sliding bottom-s MinHash sketch algorithm.
- Keep best-hit and reference-bin reciprocal filters before averaging ANI.
Key ideas:
simd-minimizersfor canonical minimizer positions and super-k-mer window coordinates. Note that the super-k-mer windows and corresponding minimizer positions were retained.tab-hash::Tab64Twistedfor deterministic 64-bit tabulation-hashed minimizer. This step is a rehash to obtain true pseudo-randomness via twisted/simple tabulation hashing.- Compact inverted minimizer index. It avoids HashMap's pointer-chasing and per-key vector overhead by flattening everything into two arrays with open-addressed slot lookup.
- A MUMmer-style diagonal clustering followed by minimap2-style fast chaining for L1 candidate window screening.
- A cache-friendly exact L2 bottom-s MinHash slide mapper using query-ranked gap counts.
- Reuses precomputed distance tables so that the post-L2 distance calculation becomes a direct table lookup instead of repeated confidence-bound and Mash-distance calculations.
- Efficient Rayon parallelism: work-stealing parallel iterators at multiple levels, including reference-genome indexing, query-genome mapping, and per-fragment L1/L2 mapping. The shared reference index is immutable, while fragment-level minimizers, candidate windows, L2 sliding state, mappings, and counters are worker-local, avoiding lock contention in the dominant mapping stages. This design gives fine-grained load balancing for highly uneven genome-pair workloads.
L2 scoring uses a new mashmap-like incremental bottom-sketch slide mapper: a query fragment's unique minimizers seed the bottom-s union, and each candidate reference super-window is updated as the window slides. The active implementation partitions reference-only hashes into the gaps between sorted query hashes. It maintains the number of active distinct hashes in each gap and the query prefix included in bottom-s, so each insert/delete updates the exact shared-hash score in constant time without rebuilding an ordered union or searching for a pivot.
The final Mash distance and confidence-bound calculation is cached exactly by (sketch_size, best_shared), so each L2 candidate performs a table lookup rather than recomputing the same binomial-bound math.
simd-minimizers uses ntHash internally with SIMD to choose minimizer positions. The turboani binary takes the returned canonical minimizer k-mer value and applies Tab64Twisted tabulation hashing once. That minimizer is reused for L1 lookup and exact L2 bottom-sketch comparison. The tabulation table is deterministic by default and controlled by --tabSeed.
The split mode allows query mapping to a small subset of references to reduce RAM.
Alternative evolutionary models can be used, e.g., binomial model.
On Linux or MacOS (CPU) via bioconda
conda install -c bioconda -c conda-forge turboaniThis is how you can run all-versus-all ANI for a list of genomes (.gz supported, one per line):
### obtain some testing genomes first
wget https://github.com/jianshu93/TurboANI/releases/download/v0.1.8/strep_60_genomes.tar.gz
tar -xzvf strep_60_genomes.tar.gz
cd strep_60_genomes
find . -name "*.fna.gz" | sort > genomes.txt
### one list automatically computes the off-diagonal upper triangle
turboani --ql genomes.txt -o turboani.tsvTesting accuracy with truth:
### obtain pre-computed BLAST-ANI truth (anib.rb from ANI calculator: http://enve-omics.ce.gatech.edu/ani), confirmed with authors that the backend of ANI calculator is exact the same ani.rb here: https://github.com/lmrodriguezr/enveomics/blob/main/Scripts/ani.rb , so truth were generated using ani.rb, blastn 2.13.0.
### OrthoANI truth were obtained using the Java OAU.jar here: https://www.ezbiocloud.net/tools/orthoaniu
wget https://github.com/jianshu93/TurboANI/releases/download/v0.1.8/strep_60_blastANI_truth.tsv
## use python scripts from the script folder to plot results (you may need to install python libraries such as matplotlib)
git clone https://github.com/jianshu93/TurboANI.git
cd TurboANI
chmod a+x ./scripts/plot_TurboANI_blastani.py
./scripts/plot_TurboANI_blastani.py --truth strep_60_blastANI_truth.tsv --turbo turboani.tsv --out-dir out_plot
Run FastANI (via bioconda):
fastANI --ql queries.txt --rl references.txt -o fastani.tsv -t 64
TurboANI is the most accurate sketch-based ANI estimation algorithm ever while being minimum 20 times faster than FastANI (the second most accurate one). See comparisons below:
Single-pair visualization writes a PDF with a query/reference map and fragment identity panel:
./target/release/turboani \
-q query.fa \
-r reference.fa \
-o pair.tsv \
--visualize pair.pdf--visualize intentionally supports only one -q and one -r; it rejects list mode. It is only available via the "--features visual" when compiling (font configuration libraries are requried):
### Linux
RUSTFLAGS="-C target-cpu=x86-64-v3" cargo build --release --features visual
### MacOS
RUSTFLAGS="-C target-cpu=native" cargo build --release --features visualThis it the plot.
In some cases, query genomes assembled from samples can be fragmented and the order or genomic sequences can be random. We recommend the below commands to order the query genome first. Ideally, the reference genome should be more completely (e.g., less fragmented, order known).
$ turboani-order -h
Order and orient fragmented query contigs against a complete reference with pure-Rust rammap asm5 mapping
Usage: turboani-order <REFERENCE> <QUERY> [PREFIX]
Arguments:
<REFERENCE> Complete reference genome FASTA/FASTQ path
<QUERY> Fragmented query genome FASTA/FASTQ path
[PREFIX] Output prefix [default: turboani_reordered]
Options:
-h, --help Print help
-V, --version Print version
List mode is also supported (one file per line, .gz supported). When only
--ql or only --rl is supplied, TurboANI reuses that list for both roles and
automatically computes only pairs with query_index < reference_index:
./target/release/turboani \
--ql genomes.txt \
-o turboani.tsvThe equivalent --rl genomes.txt command is also accepted. Self-comparisons
and reciprocal lower-triangle comparisons are omitted. To request the same
behavior when both lists are provided explicitly, use --triangle; the query
and reference lists must then contain the same genome paths in the same order:
./target/release/turboani \
--ql genomes.txt \
--rl genomes.txt \
--triangle \
-o turboani-upper.tsv--triangle also works with --split. --triangle and --matrix are mutually
exclusive: triangle mode keeps one positional region, whereas matrix mode
computes both directions and averages reciprocal ANI estimates.
Output columns match FastANI:
query_path reference_path ani mapped_fragments total_query_fragments
FastANI compatibility mode is a separate binary that implements the original FastANI algorithm and additional experiments such as minmer Jaccard estimator:
./target/release/fastani -- \
--ql queries.txt \
--rl references.txt \
-o fastani-style.tsv \--fragLen 3000-k 16--minIdentity 80--minFraction 0.2--tabSeed 42--windowSize Nto override p-value-derived minimizer window.--ignoreTopPercent Pto ignore the most frequent minimizers during L1 lookup.--visualize pair.pdfto write a single-pair PDF map/identity plot.
Timing is collected internally and emitted only in debug mode. For a concise timing/counter summary, run with RUST_LOG=debug.
Rayon is used at three levels where the data are independent: reference genome indexing across reference files, query-file comparisons, and fragment mapping inside each query file.
## Linux (no visualization feature, see build section if you want it)
wget https://github.com/jianshu93/TurboANI/releases/download/v0.1.8/turboani_linux_x86-64_v0.1.8.gz
gunzip turboani_linux_x86-64_v0.1.8.gz
mv turboani_linux_x86-64_v0.1.8 turboani
chmod a+x ./turboani
./turboani -h
## MacOS (visualization feature)
wget https://github.com/jianshu93/TurboANI/releases/download/v0.1.8/turboani_darwin_aarch64_v0.1.8.tar.gz
tar -xzvf turboani_darwin_aarch64_v0.1.8.tar.gz
chmod a+x ./turboani
./turboani -h
## Homebrew install for MacOS
## install homebrew first: https://brew.sh
brew update
brew tap jianshu93/TurboANI
brew trust jianshu93/TurboANI
brew install TurboANI
turboani -h
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh## On Linux
RUSTFLAGS="-C target-cpu=x86-64-v3" cargo install turboani
## MacOS
RUSTFLAGS="-C target-cpu=native" cargo install turboani
### Install rustup here: here: https://rustup.rs
### After intalling rustup
rustup install nightly
rustup default nightly
git clone https://github.com/jianshu93/TurboANI
RUSTFLAGS="-C target-cpu=x86-64-v3" cargo build --release
./target/release/turboani -h### Install rustup here: here: https://rustup.rs
### After intalling rustup
rustup install nightly
rustup default nightly
git clone https://github.com/jianshu93/TurboANI
RUSTFLAGS="-C target-cpu=native" cargo build --release
./target/release/turboani -hFor downstream application such as genome deduplication at a given ANI, or species/strain identification/classification at a given ANI, say 95% or 99.5%, one can choose a much larger identity via "--minIdentity 90" for example to 95% ANI and "--minIdentity 95" for 99.5% ANI. This will not affect large ANIs we care about but it will be orders of magnitude faster.
The implementation skips minimizer windows spanning ambiguous bases before passing sequence runs to simd-minimizers. This is usually preferable for Rust SIMD packing and keeps N-rich phage assemblies from creating artificial seeds.
Zhao J, McDonald D, Patel L, Wang C, Gonzalez A, Knight R. Homology-aware average nucleotide identity estimation at scale with TurboANI. bioRxiv. 2026:2026-11. https://www.biorxiv.org/content/10.64898/2026.11.05.764740v1.abstract

