Sequence Alignment as Graph Search

Aligning DNA strings is shortest-path search on a grid — the problem whose Closed list grows so fat it motivated frontier search

The Simplest Explanation

Given two strings (DNA letters A/C/G/T), align them by sliding in gaps to minimize total cost:

  • Mismatch cost: two different characters aligned against each other
  • Indel cost: a gap inserted in either string

This is exactly shortest-path search on an (n+1)×(m+1) grid where each cell is a partial alignment.

Remember This

Three moves from every cell: diagonal = match/mismatch, right = gap in vertical string, down = gap in horizontal string. Path from top-left to bottom-right = one complete alignment.

The Grid Model

Start node = top-left corner; goal = bottom-right. Every monotone path through the grid corresponds to exactly one alignment; its cost = sum of edge costs along the way.

Why Costs Matter

If indel penalty = 3 and mismatch penalty = 7, inserting two gaps (cost 6) beats one mismatch (cost 7). If the mismatch penalty drops to 5, accepting the mismatch wins. The optimal alignment depends entirely on this ratio — same strings, different answers.

The Scale Problem

Strings of length n and m give (n+1)(m+1)(n{+}1)(m{+}1) cells:

Move setNumber of paths
Horizontal + Vertical only(m+nn)\binom{m+n}{n}
+ Diagonalcombinatorially larger

Real biological sequences run hundreds of thousands of characters → astronomically many paths. Search algorithms (A*, Dijkstra) are needed, not naive enumeration.

Open vs Closed Growth — Why This Problem Matters

On the alignment grid:

  • Open grows linearly — the frontier is at most about twice the grid width
  • Closed grows quadratically ≈ area of explored region

For huge sequences, Closed dominates memory completely. This asymmetry is precisely why Frontier Search / SMGS (which delete Kernel Closed nodes) were invented — sequence alignment is their showcase application.

Properties

PropertyValue
SolutionMinimum-cost path = optimal alignment
Edge costs3 kinds: diagonal (match/mismatch), horizontal indel, vertical indel
Monotone heuristic?Manhattan-style distance to bottom-right works and satisfies consistency when costs ≥ per-step minimum
Memory bottleneckClosed, not Open
QuizIn the alignment grid, a horizontal move represents...
QuizWhy is sequence alignment THE motivating problem for pruning CLOSED?