Browser-based pairwise SNP distance matrix calculator from aligned FASTA files.
snp-distsx is a web application implementing the snp-dists algorithm by Torsten Seemann (Melbourne Bioinformatics, University of Melbourne), reimplemented in TypeScript for the browser. No data ever leaves your machine.
- Upload a multiple sequence alignment (FASTA or gzipped FASTA)
- Compute pairwise SNP distances entirely client-side — zero server uploads
- Interactive heatmap with colour-coded distance matrix (canvas-rendered)
- Distribution histogram with adjustable cluster threshold line
- Scrollable distance table with conditional cell formatting
- Export to TSV, CSV, or long/molten format
- Supports all snp-dists options:
-a(count all),-k(preserve case),-c(CSV),-b(blank corner),-m(molten),-t(headers),-L(lower triangle),-x(max distance) - Light/dark theme
Faithful TypeScript reimplementation of snp-dists v1.2.0 (Torsten Seemann, GPLv3).
For each pair of aligned sequences A and B, at each position i:
- Count a SNP if
A[i] ≠ B[i]and neitherA[i]norB[i]is an ignore character - By default, non-ACGT bases (gaps
-, Ns, IUPAC ambiguity codes) are replaced with.and skipped - Enable Count all differences (
-a) to include these positions
Sequences are stored as Uint8Array (char codes) for fast inner-loop comparison.
snippy (per sample) → snippy-core → core.full.aln
↓
[optional] Gubbins → filtered_polymorphic_sites.fasta
↓
snp-distsx → interactive matrix + heatmap
↓
Export TSV/CSV for downstream analysis or phylogenetics
A FASTA file where all sequences are the same length (a multiple sequence alignment or pseudo-alignment). Accepts .fasta, .fa, .fna, .aln, .fsa and .gz compressed variants.
npm install
npm run dev # start dev server at http://localhost:5173
npm run test # run unit tests
npm run build # production build to dist/
npm run check # tests + lint + build (CI equivalent)# Build image
docker build -t snp-distsx .
# Run (serves on http://localhost:8080)
docker run -p 8080:80 snp-distsxUnit tests cover:
| Module | Tests |
|---|---|
parseFasta |
Multi-line sequences, empty input, mismatched lengths, name parsing |
computeMatrix |
SNP counting, gap skipping, maxDiff early exit, symmetry |
formatOutput |
TSV/CSV, blank corner, lower triangle, molten format |
npm run testOriginal snp-dists tool: Seemann T (2018). snp-dists: Pairwise SNP distance matrix from a FASTA sequence alignment. https://github.com/tseemann/snp-dists — GPLv3
Web application: Nabil-Fareed Alikhan <nabil@happykhan.com> Centre for Genomic Pathogen Surveillance, University of Oxford https://www.happykhan.com
GPL-3.0-only — in keeping with the original snp-dists licence.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 only.