Docsity

Dynamic Programming in Computer Science: Sequence Alignment and Manhattan Tourist Problem , Study notes of Computer Science

Partial preview of the text

Download Dynamic Programming in Computer Science: Sequence Alignment and Manhattan Tourist Problem and more Study notes Computer Science in PDF only on Docsity!

Dynamic Programming:

Sequence alignment

CS 466

Saurabh Sinha

DNA Sequence Comparison: First

Success Story

  • Finding sequence similarities with genes of

known function is a common approach to

infer a newly sequenced gene’s function

  • In 1984 Russell Doolittle and colleagues

found similarities between cancer-causing

gene and normal growth factor (PDGF) gene

  • A normal growth gene switched on at the

wrong time causes cancer!

Role for Bioinformatics

• Gene similarities between two genes with known

and unknown function alert biologists to some

possibilities

• Computing a similarity score between two genes

tells how likely it is that they have similar

functions

• Dynamic programming is a technique for

revealing similarities between genes

Motivating Dynamic

Programming

Imagine seeking a

path (from source

to sink) to travel

(only eastward and

southward) with the

most number of

attractions (*) in the

Manhattan grid

Sink

Source

Dynamic programming example:

Manhattan Tourist Problem

Manhattan Tourist Problem: Formulation

Goal: Find the longest path in a weighted

grid.

Input: A weighted grid G with two distinct

vertices, one labeled “ source ” and the other

labeled “ sink ”

Output: A longest path in G from “ source ” to

“ sink ”

MTP: Greedy Algorithm Is Not Optimal 1 2 5 2 1 5 2 3 4 0 0 0

promising start, but leads to bad choices! source sink

MTP: Simple Recursive

Program

MT ( n,m )

if n=0 or m=

return MT(n,m)

x  MT(n-1,m)+

length of the edge from (n- 1,m) to (n,m)

y  MT(n,m-1)+

length of the edge from (n,m-1) to (n,m)

return max{x,y}

What’s wrong with this approach?

i source 1 5 S1,0 = 5 S0,1 = 1

• Calculate optimal path score for each vertex in the graph

• Each vertex’s score is the maximum of the prior vertices

score plus the weight of the respective edge in between

MTP: Dynamic Programming

j

MTP: Dynamic Programming

(cont’d)

source 1 3 5 8 4 S2,0 = 8 i S1,1 = 4 S0,2 = 3 3

  • j

MTP: Dynamic Programming

(cont’d)

greedy alg. fails!

i source 1 3 8 5 8 8 4 9 13 8 9 12 S3,1 = 9 S2,2 = 12 S1,3 = 8 j

MTP: Dynamic Programming

(cont’d)

i source 1 3 8 5 8 8 4 9 13 8 12 9 15 9 j S3,2 = 9 S2,3 = 15

MTP: Recurrence

Computing the score for a point (i,j) by the

recurrence relation:

si, j = max si-1, j + weight of the edge between ( i-1, j ) and ( i, j ) si, j-1 + weight of the edge between ( i, j-1 ) and ( i, j )

The running time is n x m for a n by m grid

( n = # of rows, m = # of columns)

Manhattan Is Not A Perfect Grid

What about diagonals?

  • The score at point B is given by: sB = max of sA1 + weight of the edge (A 1 , B) sA2 + weight of the edge (A 2 , B) sA3 + weight of the edge (A 3 , B) B A 3 A 1 A 2