Download presentation

Presentation is loading. Please wait.

1
Longest Common Subsequence (LCS) Dr. Nancy Warter-Perez June 22, 2005

2
Longest Common Subsequence2 Outline Longest Common Subsequence (LCS) Problem Definition Scoring Algorithm Printing Algorithm

3
June 22, 2005Longest Common Subsequence3 Longest Common Subsequence (LCS) Problem Reference: Pevzner Can have insertion and deletions but no substitutions (no mismatches) Ex: V: ATCTGAT W:TGCATA LCS:TCTA

4
June 22, 2005Longest Common Subsequence4 LCS Problem (cont.) Similarity score s i-1,j s i,j = max { s i,j-1 s i-1,j-1 + 1, if vi = wj On board example

5
June 22, 2005Longest Common Subsequence5 Indels – insertions and deletions (e.g., gaps) alignment of V and W V = rows of similarity matrix (vertical axis) W = columns of similarity matrix (horizontal axis) Space (gap) in W (UP) insertion Space (gap) in V (LEFT) deletion Match (no mismatch in LCS) (DIAG)

6
June 22, 2005Longest Common Subsequence6 LCS(V,W) Algorithm for i = 0 to n si,0 = 0 for j = 1 to m s0,j = 0 for i = 1 to n for j = 1 to m if vi == wj si,j = si-1,j-1 + 1; bi,j = DIAG else if si-1,j >= si,j-1 si,j = si-1,j; bi,j = UP else si,j = si,j-1; bi,j = LEFT

7
June 22, 2005Longest Common Subsequence7 Print-LCS(b,V,i,j) if i = 0 or j = 0 return if bi,j = DIAG PRINT-LCS(b, V, i-1, j-1) print vi else if bi,j = UP PRINT-LCS(b, V, i-1, j) else PRINT-LCS(b, V, I, j-1)

8
June 22, 2005Longest Common Subsequence8 Programming Workshop and Homework – Implement LCS Workshop Write a Python script to implement LCS (V, W). Prompt the user for 2 sequences (V and W) and display b and s Add the Print-LCS(V, i, j) function to your Python script. The script should prompt the user for 2 sequences and print the longest common sequence.

Similar presentations

© 2020 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google