# Sequence alignment scoring

The following table is from Deonier's text Computational Gene Analysis at p. 152. This is an exercise in global sequence alignment and scoring of alternative sequences. The text proposed a solution (in parentheses). Setting aside the upper left hand portion of the table it seems there may be a better path.

It's more likely I misunderstand the idea than that there is a typo.

$$\begin{array}{c | c | c | c | c | c | c |}- & -& T & G & G & T & G\\ \hline - & (0 ) & -2 & -4 & -6 &-8 & -10 \\ \hline A &(-2) & -1 & -3 & -5 & -7 & -9 \\ \hline T &-4 & (-1) & -2 & -4 & -4 & -6 \\ \hline C &-6 & -3 & (-2) & -3 & -5 & -5 \\ \hline G &-8 & -5 & -2 & (-1) & -3 & -4 \\ \hline T &-10 & -7 & -4 &-3 & (0) & (-2 )\\ \hline \end{array}$$

Just looking at the upper left corner,

$$\begin{array}{c | c | c |} (0) & -2 & -4...\\ \hline -2 & (-1) & -3...\\ \hline -4 & (-1) & -2...\\ \hline -6 & -3 & (-2)...\\ \hline \end{array}$$

which seems to give -7 versus -8 for the book's path. Below are the book's alignment and the one corresponding to my scoring, which may reveal my error.

$$\begin{array}{c | c | c | c | c | c | c |} A: & A & T & C & G & T & - \\ \hline B: & - & T & G & G & T & G \\ \hline \end{array}$$

$$\begin{array}{c | c | c | c | c | c | c |} A: & A & T & C & G & T & - \\ \hline B: & T & - & G & G & T & G \\ \hline \end{array}$$

I had no trouble constructing the matrix just scoring it. it's a small point but I don't like to move on without understanding it. Thanks for any assistance.

Edit: Both current answer seem clear on this but just for completeness: a match = 1; mismatch = -1; indel = -2.

If I am myself not mistaken, the table shows the paths of least resistance. There are many paths through this table and all of them are not shown only the ones that cost the least. You need to understand that a mismatch between the letters costs -1 (eg - AT), but an empty square costs -2 (-A or -T). So your solution would cost = -1-3-4-3-2-4 which sums up too -17.

This is a full alignment table. The top value is going diagonal, the second value is going down and the third value is going right.

• Could you explain how you get that -17? A gap costs between -2 and -10 depending on which one in the table in the OP. The score of the mismatch also changes. Where are your numbers coming from? – terdon Apr 26 '14 at 11:46
• The score of a mismatch is always -2, only if you use more than one gap then it increases by -2 with every gap. That is why the top row is -2 (one gap); -4 (two gaps); -6 (three gaps) and so on. I did explain how I got -17 = - 1 - 3 - 4 - 3 - 2 - 4. You just need to add the values of each place. – DovydasG Apr 26 '14 at 18:02

The problem is that you are using the T twice. Let's build the alignment manually, we have two sequences:

>seq1
ATCGT
>seq2
TGGTG


So, to build the alignment using your approach, we would take the first nt of seq1, the A and choose the highest scoring nt from seq2 to align it against. In your example, that would be the T (-1) which produces:

A
T


OK, now we move to the next nt of seq1, the T. Now, in your table, the highest score is indeed for TT but we have already used the T from seq2, we can't use it again! In your alignment, you used a -. The score for T- at position 2 is -4. This means that your alignment:

ATCGT-
T-GGTG


Has a score of:

$(AT)_{pos1} + (T-)_{pos2} + (CG)_{pos3} + (GG)_{pos4} + (TT)_{pos5} + (-G)_{pos6}$

Which is:

$-1-4-2-1-10 = -18$

While the book's alignment is:

$(A-)_{pos1} + (TT)_{pos2} + (CG)_{pos3} + (GG)_{pos4} + (TT)_{pos5} + (-G)_{pos6}$

Which is:

$-2 -1 -2 -1 -10 = -16$

• @daniel in which case it is probably mistaken (my approach, not your text). Taking what you show out of context, I am simply using the score for each position. So, since T- has a score of -10 in your table, I am using that. – terdon Apr 26 '14 at 15:03
• We agree about the alignments. Why is the second score -4 in my alignment? That might clarify for me. – daniel Apr 26 '14 at 15:51
• If you are saying the -4 in my score is because it's -2 in the 2d position, then why isn't -1 in the 4th position -4? This might clarify. – daniel Apr 26 '14 at 16:03
• @daniel the -4 in your score is because a T in seq1 aligned to a - in seq2 has a score of -4 in the table. The -1 is because TT has a score of -1 in the table. However, while I have actually worked with this kind of thing, I have never worked with it in depth and it was a few years ago now, I may well be wrong. – terdon Apr 26 '14 at 21:26