View
224
Download
0
Tags:
Embed Size (px)
Citation preview
• Conditions– Division to sub-problems possible
– (Optimal) Sub-problem solution usable (many times?)
– “Bottom-up” approach
Dynamic Programming
FibonacciFib(x) = Fib(x-1)+Fib(x-2), Fib(0)=0 Fib(1)=1
Fib(5) =Fib(3)+Fib(4) =Fib(2)+Fib(1)+Fib(3)+Fib(2) =Fib(1)+Fib(0)+Fib(1)+Fib(2)+Fib(1)+Fib(1)+Fib(0)=Fib(1)+Fib(0)+Fib(1)+ Fib(1)+Fib(0)+Fib(1)+Fib(1)+Fib(0) = 1+0+1+1+0+1+1+0 = 5
Without using dynamic programming we will need to calculate Fib(2) three
times.
Fibonacci
Dynamic programming solution will work “bottom up”:
1. First calculate Fib(2) from known Fib(0) and Fib(1)2. Calculate Fib(3) using calculated Fib(2) and known Fib(1).3. Calculate Fib(4) using calculated Fib(3) and Fib(2).4. Calculate Fib(5) using calculated Fib(4) and Fib(3).
• Dynamic Programming algorithm for finding local matches
between two sequences.
• What is a local match?: – It is a best-matching, highest-scoring region between two
sequences.
– It is a well conserved region between two sequences.
Local Alignment
The differences:
1. We can start a new match instead of extending a previous alignment.
2. Instead of looking only at the far corner, we look anywhere in the table for the best score
Global vs Local
Global Local
Scoring System
Match : +1Mismatch: -2
Indel : -1
Local Alignment
Fill:1.We fill the table like in global alignment, but we don’t allow negative numbers (turn
every negative number to 0)2.No arrows coming out from cells with a 0.
Scoring System– Match : +1– Mismatch: -1– Indel : -2
+1 if M2=N2; -1 if M2=N2
-2
N1N2Nn
M1
M2
Mm
N1N2..M1M2..
N1 ..-M1M2..
N1N2..M1 ..-
Local Alignment
Trace:We trace back from the highest scoring cells.
+1 if M2=N2; -1 if M2=N2
-2
N1N2Nn
M1
M2
Mm
N1N2..M1M2..
N1 ..-M1M2..
N1N2..M1 ..-
0
T
1
A
2
C
3
T
4
A
5
A
6
0 000000
T 1 010010
A 2 0020021
A 3 0011013
T 4 0100201
A 5 0020031
Leave only paths from highest score
TAATAA
TACTATAATA
1300200A 5
1020010T 4
3101100A 3
1200200A 2
010010T 1
0000000
A
6
A
5
T
4
C
3
A
2
T
10
1300200A 5
1020010T 4
3101100A 3
1200200A 2
010010T 1
0000000
A
6
A
5
T
4
C
3
A
2
T
10
And Now… Global Alignment
1.We keep negative numbers.2.Arrows coming out from any cell.3.We trace back from right-bottom to left-top of the table.
Scoring System– Match : +1– Mismatch: -1– Indel : -2
+1 if M2=N2; -1 if M2=N2
-2
N1N2Nn
M1
M2
Mm
N1N2..M1M2..
N1 ..-M1M2..
N1N2..M1 ..-
A 5
T 4
A 3
A 2
T 1
0
A
6
A
5
T
4
C
3
A
2
T
10
Match: +1
Mismatch:-1
Indel: -2
-12-10-8-6-4-2
-10
-8
-6
-4
-2
0
-9-7-5-3-11
130-3-4-7
-202-1-2-5
-3-1-110-3
-6-4-202-1
A 5
T 4
A 3
A 2
T 1
0
A
6
A
5
T
4
C
3
A
2
T
10
Match: +1
Mismatch:-1
Indel: -2
-12-10-8-6-4-2
-10
-8
-6
-4
-2
0
-9-7-5-3-11
130-3-4-7
-202-1-2-5
-3-1-110-3
-6-4-202-1
130-3-1-4-5A 5
-102-1-2-2-4T 4
1-1-110-3-3A 3
-20-202-1-2A 2
-6-4-2-3-11-1T 1
-6-5-4-3-2-100
A
6
A
5
T
4
C
3
A
2
T
10
TACTAATAATA-
TACTAATAAT-A
130-3-1-4-5A 5
-102-1-2-2-4T 4
1-1-110-3-3A 3
-20-202-1-2A 2
-6-4-2-3-11-1T 1
-6-5-4-3-2-100
A
6
A
5
T
4
C
3
A
2
T
10