0% found this document useful (0 votes)
18 views17 pages

DNA Sequence Alignment Algorithms

This document discusses DNA sequence alignment and describes how to find the optimal alignment of two DNA sequences using dynamic programming. It first provides background on DNA sequences and similarity. It then explains the naive recursive algorithm before describing the dynamic programming approach, which builds up a table of partial solutions in order to reuse computations and run in quadratic time.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views17 pages

DNA Sequence Alignment Algorithms

This document discusses DNA sequence alignment and describes how to find the optimal alignment of two DNA sequences using dynamic programming. It first provides background on DNA sequences and similarity. It then explains the naive recursive algorithm before describing the dynamic programming approach, which builds up a table of partial solutions in order to reuse computations and run in quadratic time.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

DNA Sequence Alignment

A dynamic programming algorithm


Some ideas stole from Winter 1996 offering of 590BI at
[Link]
See Lecture 2 by Prof. Ruzzo. Or try current quarter of CSE 527.
Those slides are more detailed and biologically accurate.
DNA Sequence Alignment (aka
“Longest Common Subsequence”)
• The problem
– What is a DNA sequence?
– DNA similarity
– What is DNA sequence alignment?
– Using English words
• The Naïve algorithm
• The Dynamic Programming algorithm
• Idea of Dynamic Programming
What is a DNA sequence
• DNA: string using letters A,C,G,T
– Letter = DNA “base”
– e.g. AGATGGGCAAGATA
• DNA makes up your “genetic code”
DNA similarity
• DNA can mutate.
– Change a letter
• AACCGGTT  ATCCGGTT
– Insert a letter
• AACCGGTT  ATAACCGGTT
– Delete a letter
• AACCGGTT  ACCGGTT
• A few mutations makes sequences different, but
“similar”
Why is DNA similarity important
• New sequences compared to existing
sequences
• Similar sequences often have similar
function
• Most widely used algorithm in
computational biology tools
– e.g. BLAST at
[Link]
What is DNA sequence
alignment?
• Match 2 sequences, with underscore ( _ )
wildcards.
• Best Alignment  minimum underscores
(slight simplification, but okay for 326)
• e.g. ACCCGTTT
TCCCTTT

Best alignment: A_CCCGTTT


(3 underscores) _TCCC_TTT
Moving to English words

zasha
ashes

zash__a
_ashes_
Naïve algorithm
• Try every way to put in underscores
• If it works, and is best so far, record it.
• At end, return best solution.
Naïve Algorithm – Running
Time
• Strings size M,N: ( 2 M  N )
Dynamic Approach – A table
• Table(x,y): best alignment for first x letters
of string 1, and first y letters of string 2
• Decide what to do with the end of string,
then look up best alignment of remainder in
Table.
e.g. ‘a’ vs. ‘s’
• “zasha” vs. “ashes”. 2 possibilities for last
letters:
– (1) match ‘a’ with ‘_’:
• best_alignment(“zash”,”ashes”)+1
– (2) match ‘s’ with ‘_’:
• best_alignment(“zasha”,”ashe”)+1
 best_alignment(“zasha”,”ashes”)
=min(best_alignment(“zash”,”ashes”)+1,
best_alignment(“zasha”,”ashe”)+1)
An example
(empty) Z A S H A
(empty)
A
S
H
E
S
Example with solution
(empty) Z A S H A
(empty) 0 1 2 3 4 5
A 1 2 1 2 3 4
S 2 3 2 1 2 3
H 3 4 3 2 1 2
E 4 5 4 3 2 3
S 5 6 5 4 3 4
zasha__
_ash_es
Pseudocode (bottom-up)
Given: Strings X,Y , Table[0..x,0..y]

For i=1 to x do
Table[i,0]=i
For j=1 to y do
Table[0,j]=i
i=1, j=1
While i<=x and j<=y
If X[x]=Y[y] Then
// matches – no underscores
Table[x,y]=Table[x-1,y-1]
Else
Table[x,y]=min(Table[x-1,y],Table[x,y-1])+1
End If
i=i+1
If i>x Then
i=1
j=j+1
End If
Pseudocode (top-down)
Given: Strings X,Y , Table[0..x,0..y]

BestAlignment (x,y)
Compute Table[x-1,y] if necessary
Compute Table[x,y-1] if necessary
Compute Table[x-1,y-1] if necessary

If X[x]=Y[y] Then
// matches – no underscores
Table[x,y]=Table[x-1,y-1]
Else
Table[x,y]=min(Table[x-1,y],Table[x,y-1])+1
End If
Running time
• Every square in table is filled in once
• Filling it in is constant time
 (n2) squares
 alg is (n2)
Idea of dynamic Albert Q.
Dynamic
programming at Whisler
mountain

Picture from [Link]

• Re-use expensive computations


– Identify critical input to problem (e.g. best
alignment of prefixes of strings)
– Store results in table, indexed by critical input
– Solve cells in table of other cells
• Top-down often easier to program

Common questions

Powered by AI

In dynamic programming algorithms for sequence alignment, re-using expensive computations involves calculating the best alignment for smaller prefixes of the sequences, storing these results in a table, and recalling them when needed for larger subproblems. This re-use avoids unnecessary recalculations and enables efficient problem-solving. For example, once the best alignment for a pair of prefixes is computed, this solution is stored and referenced whenever aligning extensions of these prefixes, streamlining the process and reducing computational overhead from exponential in the naïve approach to polynomial in dynamic programming .

Critical inputs in dynamic programming for DNA sequence alignment define the dimensions of the problem, often corresponding to the lengths of the sequence prefixes being considered. These inputs allow for systematic filling and referencing of the alignment table, ensuring each subproblem's optimal solution contributes to larger problems' solutions. Storing results based on these inputs prevents redundant calculations, thus reducing computational time from exponential in the naïve algorithm to polynomial, specifically Θ(n²) for the table size, enhancing efficiency and scalability .

The top-down dynamic programming approach is often easier to implement for DNA sequence alignment as it follows natural recursive decomposition of the problem, solving and storing results for subproblems only as needed. This laziness can make it easier to manage in terms of space and computational resources, particularly when the entire table does not need to be filled. In contrast, the bottom-up approach fills the table methodically from the simplest to more complex subproblems, which may result in unnecessary computations if not all table entries are required for the final solution. This can be significant in optimizing performance where the entire range of possible sequence alignments might not be interesting .

When comparing DNA sequences, considering biological functions is crucial because sequences with high similarity likely share similar functions or originate from similar evolutionary paths. This information can lead to important biological insights, such as gene functions, cellular pathways, and evolutionary relationships. It aids in understanding the roles of genes and proteins in health and disease, facilitating drug discovery and development by targeting these similar genetic structures for therapeutic intervention .

Dynamic programming is used in DNA sequence alignment to efficiently handle the computational task of finding the best possible alignment between two DNA sequences by systematically solving subproblems and re-using the results. This reduces the computational complexity significantly from trying every possible alignment option, as is done in the naïve algorithm. The dynamic programming algorithm fills a table with the best alignment scores for each prefix of the sequences, which can be used to reconstruct the best alignment with minimum underscores, reflecting fewer mismatches or insertions/deletions .

DNA sequence alignment can be analogized with aligning English words by considering alignment problems similar to inserting spaces or underscores to best match words with each other. For instance, aligning 'zasha' with 'ashes' by inserting underscores maximizes character matches while minimizing space (underlines), akin to aligning DNA sequences to minimize mutations. This analogy helps illustrate the challenge in handling insertions, deletions, and mismatches in sequence alignment, requiring algorithms that can effectively capture similarity despite structural differences, just as English word alignment must best preserve character order and proximity .

The computational complexity of the naïve approach to sequence alignment involves trying every possible way to align two sequences, analogous to checking all combinations, resulting in exponential time complexity, which is inefficient and impractical for large sequences. Conversely, the dynamic programming approach reduces this complexity significantly to polynomial time, specifically Θ(n²). This is achieved by building a table that stores solutions of optimal alignments for subproblems, thus reusing results and avoiding redundant calculations. This demonstrates the power of dynamic programming in transforming an otherwise computationally prohibitive problem into a tractable one .

Mutation affects DNA sequence similarity by introducing changes, such as base substitutions, insertions, or deletions, which can make sequences appear different but still similar. This is significant in computational biology because similar sequences often imply similar functions or evolutionary origins, making DNA sequence alignment a critical task for understanding genetic relationships, predicting gene function, and identifying targets for drugs. Computational tools like BLAST use these principles to compare new sequences against a database of known sequences, aiding in biological discovery and research .

The process of DNA sequence alignment using underscores involves matching two sequences such that the number of underscores, representing mismatches or gaps, is minimized. Dynamic programming constructs an alignment table that records the cost of aligning each prefix of the sequences, using recurrences to capture alignment choices like matching a character or adding an underscore. The example with English words ('zasha' and 'ashes') demonstrates how to align sequences: aligning 'zasha' with 'ashes' results in insertions represented by underscores to create the alignment 'zasha__ _ash_es'. This aligns the characters while minimizing the number of underscores needed for best alignment .

DNA sequence similarity is a primary focus in computational biology tools like BLAST because similar sequences often imply similar biological functions and evolutionary ancestry. These similarities can indicate gene function, facilitate the identification of conserved elements, and assist in phylogenetic analyses. Tools like BLAST utilize these similarities to compare unknown sequences against vast databases to infer function, predict structure, and even suggest potential medical or biotechnological applications, leveraging the biological insights encoded within sequence similarities .

You might also like