Hamming Distance
Position-wise mismatches and percent identity for two equal-length sequences.
The Hamming Distance Calculator computes the number of position-wise mismatching characters between two equal-length DNA, RNA, or Protein sequences to quantify point mutational divergence and sequence identity.
Free, runs in your browser. Nothing you enter is uploaded.
How to use it
- Input Sequence 1 and Sequence 2 of identical character length.
- Calculate mismatch count (Hamming distance) and percent identity.
What you enter
- Two sequences (s1, s2) of strictly identical length
- Supports nucleic acid (A/C/G/T/U/N) and amino acid alphabets
What you get
- Hamming Distance (absolute mismatch integer count)
- Percent Sequence Identity (%) and Transition/Transversion Ratio
- Mismatched residue table with position, reference base, and query base
Formula
d_H(s1, s2) = Σ [s1[i] ≠ s2[i]] | Percent Identity = [1 - (d_H / Length)] * 100
Evaluates character equality at each index 'i' from 0 to N-1 for two equal-length strings. Returns the total count of non-identical positions and computes relative percent identity.
Example: 100-bp Amplicon Variant Comparison
Input: Seq 1: 100 bp WT DNA | Seq 2: 100 bp Variant DNA (contains 4 point mutations)
Result: Hamming Distance: 4 mismatches | Percent Identity: 96.00% | Mismatch Positions: 14, 38, 72, 89
A distance of 4 indicates a 4% mutational divergence, characteristic of closely related viral isolates or clonal sublineages.
Questions
What is Hamming distance?
Hamming distance is the number of positions at which two equal-length sequences have different characters, representing substitution mutations.
Limitations
- Requires both sequences to be of identical length; sequences with insertions or deletions (indels) must be aligned first or evaluated via Levenshtein edit distance.
- Treats all substitutions equally; does not weight conservative vs radical amino acid changes or transitions vs transversions.
References
- Hamming RW (1950) Bell System Technical Journal 29(2):147-160.
- Shannon CE (1948) Bell System Technical Journal 27(3):379-423.
Related reading
- Evaluating Phasing Accuracy with Switch Error & Hamming Distance
- Understanding UMIs & Barcodes in Single-Cell Sequencing
- Smith-Waterman Dynamic Programming Sequence Alignment
All free tools · By Dr. Zubair Khalid, DVM, MS, PhD.