1 / 12

Project 3: Dynamic Programming

Project 3: Dynamic Programming. Optimal String Alignment. Development of a Dynamic Programming Algorithm Characterize the structure of a solution Recursively define the value of a solution Compute the value of a solution in a bottom-up fashion(using a table)

Download Presentation

Project 3: Dynamic Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Project 3: Dynamic Programming Optimal String Alignment

  2. Development of a Dynamic Programming Algorithm • Characterize the structure of a solution • Recursively define the value of a solution • Compute the value of a solution in a bottom-up fashion(using a table) • Construct a solution from computed information

  3. Example: Optimal String Alignment • Images taken from http://www.sbc.su.se/~per/molbioinfo2001/dynprog/dynamic.html • Want to find optimal (best) alignment between two strings where matches count as 1, mismatches count as 0, and “gaps” count as 0. • Example: • G A A T T C A G T T A • G G A T C G A • G _ A A T T C A G T T A • G G _ A _ T C _ G _ _ A • Notice that every alignment can start in exactly one of three ways: • Two non-gap characters • Non-gap above, gap below • Gap above, non-gap below Score == 6

  4. Example: Optimal String Alignment • Notice in an optimal alignment of (s1,s2,…,sn) with (t1,t2,…,tm) one of these must be true: • S2..n must be optimally aligned with T2..m • S2..n must be optimally aligned with T1..m • S1..n must be optimally aligned with T2..m • The score of each is then • Score(S2..n, T2..m) + Score(S1,T1) • Score(S2..n, T1..m) + Score(S1,gap) • Score(S1..n, T2..m) + Score(T1,gap) • We want to select the maximum of these, giving • Score(S1..n, T1..m) = • max(Score(S2..n, T2..m) + Score(S1,T1), • Score(S2..n, T1..m) + Score(S1,gap), • Score(S1..n, T2..m) + Score(gap,T1)) • base case given by scoring function Only gives score of optimal, not actual alignment

  5. Example: Optimal String Alignment • Let’s build a table, M, of values such that M[i][j] is the optimal score for S1..i aligned with T1..j. • If we have this, M[n][m] is the overall optimal score • M is zero-indexed to allow for beginning gap • Notice by our recurrence relation, • M[i][j] = max(M[i-1][j-1] + Score(Si,Tj), M[i][j-1] + Score(gap,Tj), M[i-1][j] + Score(Si,gap))

  6. Example: Optimal String Alignment Base Case M[i][0] = Score(Si,gap) M[0][j] = Score(gap,Sj)

  7. Example: Optimal String Alignment M[i][j] = max(M[i-1][j-1] + Score(Si,Tj), M[i][j-1] + Score(gap,Tj), M[i-1][j] + Score(Si,gap))

  8. Example: Optimal String Alignment M[i][j] = max(M[i-1][j-1] + Score(Si,Tj), M[i][j-1] + Score(gap,Tj), M[i-1][j] + Score(Si,gap))

  9. Example: Optimal String Alignment M[i][j] = max(M[i-1][j-1] + Score(Si,Tj), M[i][j-1] + Score(gap,Tj), M[i-1][j] + Score(Si,gap))

  10. Example: Optimal String Alignment M[i][j] = max(M[i-1][j-1] + Score(Si,Tj), M[i][j-1] + Score(gap,Tj), M[i-1][j] + Score(Si,gap))

  11. Example: Optimal String Alignment M[i][j] = max(M[i-1][j-1] + Score(Si,Tj), M[i][j-1] + Score(gap,Tj), M[i-1][j] + Score(Si,gap))

  12. Example: Optimal String Alignment • Still need to find actual alignment that results in maximum score • Can be done by tracing back from optimal value to find where it must have originated • representing earlier optimal alignment • G _ A A T T C A G T T A • G G _ A _ T C _ G _ _ A

More Related