Docsity

Sequence Alignment - Bioinformatics - Lecture Slides, Slides of Bioinformatics

Partial preview of the text

Download Sequence Alignment - Bioinformatics - Lecture Slides and more Slides Bioinformatics in PDF only on Docsity!

Sequence Alignment II

Optimal Alignments

  • So we know how to compute the similarity

between two sequences

  • How do we construct an alignment that gives that similarity?
  • We will use the (already computed) array from the previous algorithm
  • Start at entry ( m , n ) and repeat the choices made to get the similarity score - Note that sometimes we had more than one choice giving the same optimal score

Algorithm Align input: indices i, j, array a given by algorithm Similarity output: alignment in align-s, align-t , and length in len if i = 0 and j = 0 then len ← 0 else if i > 0 and a [ i, j ] = a [i - 1, j ] + g then Align ( i - 1, j , len ) len ← len + 1 align-s [ len ] ← s [ i ] align-t [ len ] ← - else if i >0 and j >0 and a [i, j ] = a [i-1, j -1] + p ( i,j ) then Align ( i - 1, j - 1, len ) len ← len + 1 align-s [ len ] ← s [ i ] align-t [ len ] ← t [ j ] else // j > 0 and a [ i, j ] = a [i, j - 1] + g Align ( i , j - 1, len ) len ← len + 1 align-s [ len ] ← - align-t [ len ] ← t [ j ]

Algorithm Complexity

  • First algorithm has four loops
    • O ( m ), O ( n ), O ( mn )
    • So complexity is: O ( m ) + O ( n ) + O ( mn ) = O ( mn ) = O ( n^2 )
  • Second algorithm is
    • O ( len ) = O ( m + n )

Local Comparison

  • First row and column initialized to 0
  • We now fill in the other elements of a as before, choosing the maximum of, now, 4 values - We have the previous three choices, plus a fourth choice - 0 - We always have the choice zero, by aligning the two empty suffixes - Find the alignment same way as before, but stop if we reach an entry with value zero - Start search at the largest value in the array

Local Alignment with match: +1,

mismatch -1, gap 0

A A C C T A T A G C T

G 0 0 0 0 0 0 0 0 0 1 0 0

C 0 0 0 1 1 0 0 0 0 0 2 1

G 0 0 0 0 0 0 0 0 0 1 0 1

A 0 1 1 0 0 0 1 0 1 0 0 0

T 0 0 0 0 0 1 0 2 1 0 0 1

A 0 1 1 0 0 0 2 0 3 2 1 0

T 0 0 0 0 0 1 1 3 2 2 1 2

A 0 1 1 0 0 0 2 2 4 3 2 Docsity.com 1

Semiglobal Comparisons

  • We don’t want to penalize the gaps at the end

as we do those in middle since they don’t

have biological significance

  • Usually result from incomplete data acquisition
  • This approach is known as semiglobal alignment
  • We can modify the basic algorithm for this type of alignment

Semiglobal Comparisons

  • Suppose we don’t want to charge for spaces

after the last character of s

  • Consider an optimal alignment
    • Spaces after the end of s are matched with a suffix of t
    • Removing final part of alignment, we have an alignment between s and a prefix of t
    • So find optimal alignment between s and a prefix of t - but these are already computed in last row of a! - So take max value from last row of a

Semiglobal Comparisons

  • What about spaces at the beginning of s and

t?

  • These are represented by the values in the first row and column of a - So, if we don’t want to charge for them, just initialize this row and column to be all 0
  • So the changes to the basic algorithm are:
    • Initialize row 1, column 1 to zero
    • Look for maximum in last row or column