BioinformaticsAdvanced~20 min

Sequence Alignment Visualizer

Watch dynamic programming actually happen

Run Needleman–Wunsch and Smith–Waterman over two sequences, then hover any cell in the scoring matrix to see exactly how its value was derived and trace the optimal path.

The takeaway

BLAST is not magic. It is this matrix, filled in cell by cell — and once you have watched the traceback, homology search stops being a black box.

Dynamic programmingGlobal vs local alignmentTracebackGap penaltiesBLOSUM62Percent identity
Read the theory: Protein Folding & AI Structure Prediction
Presets

Orthologous fragments diverged by a single point substitution. Global alignment is right here: the two sequences are homologous end-to-end, so every position should be accounted for.

Sequence type
Algorithm
Sequences (max 20 residues)

Allowed: A C G T U N

Scoring scheme
+2
−1
−2

This is a lineargap model: a gap of length L costs L × penalty. Production tools (BLAST, EMBOSS) use affinegaps — an expensive open, a cheap extend — because one 5-base indel is far more likely than five separate 1-base indels.

Alignment score
19
% Identity
90.9%
% Gaps
0.0%
Alignment length
11

Aligned output

full-length global alignment
Seq1ACGTGGCTAAG
 |||||.|||||
Seq2ACGTGCCTAAG
|identical.mismatch-gap

Dynamic-programming matrix

Every cell holds the best score of any alignment ending there. Hover a cell to see the three candidate moves it chose between. The amber ring is the traceback — the optimal path itself.

A
C
G
T
G
C
C
T
A
A
G
A
C
G
T
G
G
C
T
A
A
G
Hover any interior cell to see how its score was derived.

Global vs. local: why it matters

Needleman–Wunsch (global) assumes the two sequences are homologous along their entire length and forces every residue into the alignment. Use it to compare the same gene between two species.

Smith–Waterman (local) clamps negative scores to zero, so a bad region can never drag the alignment down — it just resets. That lets it find one conserved domain inside two otherwise unrelated proteins, or a short motif in a whole chromosome. This clamp-and-restart is the entire difference, and it is the reason local alignment is the heart of homology search.

This is the engine inside BLAST

Filling an n×m matrix costs O(nm). For a 300-residue query against a 100-billion-residue database that is far too slow, so BLAST first finds short exact word matches (seeds) and only then runs this exact Smith–Waterman extension around them. The heuristic finds candidates; the dynamic program you are looking at scores them.

Try protein mode. DNA gets away with flat match/mismatch scoring. Proteins do not — switch modes to see BLOSUM62 score a chemically conservative swap as a positive, not a penalty.