Suppose we are aligning the 2 short sequences AADDEFGH and ADCDEGH.
For illustration we will use a very simple scoring scheme: an identity scores 2 and a gap of any length costs 1.
Working from the C-terminus of the sequences, we work along the outside of the grid and fill in the scores:
| A | A | D | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| A | 0 | |||||||
| D | 0 | |||||||
| C | 0 | |||||||
| D | 0 | |||||||
| E | 0 | |||||||
| G | 0 | |||||||
| H | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
We now move in along the diagonal and calculate the scores in the same way. However, for each cell, we also add the maximum of:
(we term the first of these "the diagonal cell" and the second and third "the off-diagonal cells"
| A | A | D | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| A | 1 | 0 | ||||||
| D | 1 | 0 | ||||||
| C | 1 | 0 | ||||||
| D | 1 | 0 | ||||||
| E | 1 | 0 | ||||||
| G | 1 | 1 | 1 | 1 | 1 | 1 | 4 | 0 |
| H | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
In this example the G:G cell scores two for the match and adds two from the diagonal cell. The other cells all score 1 as their diagonal is 0, but there is an off-diagonal cell with a score of 2 (minus a gap penalty of 1).
We now repeat for the each set of cells:
|
|
|
|
|
We can now find the highest scoring cell on the top or left of the grid and trace-back from that point through the grid to work out how that high score was accumulated. These cells are highlighted:
| A | A | D | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| A | 9 | 10 | 6 | 4 | 3 | 3 | 1 | 0 |
| D | 6 | 7 | 8 | 6 | 3 | 3 | 1 | 0 |
| C | 6 | 6 | 7 | 4 | 3 | 3 | 1 | 0 |
| D | 4 | 4 | 6 | 7 | 4 | 3 | 1 | 0 |
| E | 3 | 3 | 3 | 3 | 5 | 4 | 1 | 0 |
| G | 1 | 1 | 1 | 1 | 1 | 1 | 4 | 0 |
| H | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
and, from this, we can deduce the optimum alignment of the sequences:
| A | A | D | - | D | E | F | G | H |
|---|---|---|---|---|---|---|---|---|
| - | A | D | C | D | E | - | G | H |