alignment

# Alignment backtracking arrows show where the score

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: t Graph Alignment: Dynamic Programming Every path in the edit graph corresponds to an alignment: Dynamic Programming Example Dynamic Programming Example Initialization: 0th row and 0th column all zeroes. Alignment: Backtracking Arrows show where the score originated from. Backtracking Example Find a match in row and column 2. i=2, j=2,5 is a match (T). if from the top j=2, i=4,5,7 is a match (T). if from the left Since vi = wj, si,j = si-1,j-1 +1 if vi = wj s2,2 s2,5 s4,2 s5,2 s7,2 = = = = = [s1,1 [s1,4 [s3,1 [s4,1 [s6,1 = = = = = 1] 1] 1] 1] 1] + + + + + 1 1 1 1 1 10 Backtracking Example LCS Algorithm The corresponding alignment: LCS(v,w) for i  1 to si,0  0 for j 1 to s0,j  0 for i  1 to for j  1 n Runtime: O(nm) Memory: O(nm) m n to m si-1,j si,j-1 si-1,j-1 + 1, if vi = wj if si,j = si-1,j bi,j if si,j = si,j-1 if si,j = si-1,j-1 + 1 return (sn,m, b) si,j max Now What? Printing LCS: Backtracking •  LCS(v,w) created the alignment grid PrintLCS(b,v,i,j) 1.   if i = 0 o r j = 0 2.   return 3.   if bi,j = “ “ 4.   PrintLCS(b,v,i-1,j-1) 5.   print vi 6.   else 7.   if bi,j = “ “ 8.   PrintLCS(b,v,i-1,j) 9.   else 10.  PrintLCS(b,v,i,j-1) •  To read the best alignment: Follow the arrows backwards from sink 11...
View Full Document

## This note was uploaded on 02/10/2014 for the course CS 548 taught by Professor Asaben-hur during the Spring '12 term at Colorado State.

Ask a homework question - tutors are online