
1. Setup:
Input:
Strings $X = x_1 . . . x_m , Y = y_1 . . . y_n$ over some alphabet Σ like {A,C,G,T}.
Penalty $α_{gap}$ for inserting a gap, $α_{ab}$ for matching a & b [presumably $α_{ab} = 0$ of a = b]
Feasible solutions:
Alignments - i.e., insert gaps to equalize lengths of the string
Goal:
Alignment with minimum possible total penalty
2. Analysis
-
Optimal Substructure
For a optimal alignment of X, Y, there are 3 relevant possibilities for the contents of the final position:
$$case 1: x_m & y_n $$$$ case 2: x_m & gap$$
$$ case 3: y_n & gap$$
If case 1 holds, then induced alignment of X’ & Y’ is optimal;
If case 2 holds, then induced alignment of X’ & Y is optimal;
If case 3 holds, then induced alignment of X & Y’ is optimal. (contradiction) -
Relevant Subproblems
$(X_i , Y_j)$ where:
$X_i$ = 1st i letters of X
$Y_j$ = 1st j letters of Y
(Only peel off letters from the right end of the strings.) -
Recurrence
$P_ij$ = penalty of optimal alignment of $X_i$ & $Y_j$ .
For all $i = 1, . . . , m$ and $j = 1, . . . , n$:1P_ij = min(a[xi][yi]+P[i-1][j-1], a_gap+P[i][j-1], a_gap+P[i-1][j])
Base case:
$$P_{i,0} = P_{0,i} = i * alpha_{gap}$$
3. The Algorithm
|
|
- Running time: $O(mn)$
4. Reconstructing a Solution
Trace back from A[m][n].
|
|




近期评论