Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 12

Dynamic Programming

Dynamic Programming

• It is a computational method to align two swquences.


• The technique of dynamic programming can be applied to produce
• global alignments via the Needleman-Wunsch algorithm
• local alignments via the Smith-Waterman algorithm.
Needleman-Wunsch algorithm for global sequence
alignment

• The two sequences are arranged in a matrix form with A+1columns and B+1rows.
• 1st column and 1st row will be empty.
• Fill first block with zero.
• Then fill 1st row and 1st column with gap penalty multiples.
• While filling the matrix there are three possible values
• Horizontal: score+gap penalty
• Vertical: score+gap penalty
• Diagonal: score+(match score/mismatch score)

Mi,j=Maximum[Mi-1,j+W, Mi-1,j-1+Si, Mi,j-i+W]


Let's take 2 following sequences for alignment

Sequence 1: AAAC     A A A C
Sequence 2: AGC
  0 -2 -4 -6 -8
A -2 1 -1 -3 -5

G -4 -1 0 -2 -4

C -6 -3 -2 -1 -1

Match score = 1
Mismatch score=-1
Gap penalty = -2
    A A A C

  0 -2 -4 -6 -8

A -2 1 -1  -3  -5 

G -4 -1   0  -2 -4 

C -6 -3  -2   -1 -1 


    A A A C

  0 -2 -4 -6 -8

A -2 1 -1  -3  -5 

G -4 -1   0  -2 -4 

C -6 -3  -2   -1 -1 

AAAC AAAC

AG- C AGC-
Backward traceback

In backward tracking we have to move from last cell (lower corner) and follows arrow from
which cell the current cell’s values come from and go ahead.
There are 2 rules for it
1. If the value come from column, we will have to write two sequences
2. If value come from horizontal or vertical, then we will have to write perpendicular and
gap to other side.
Align the following sequences using Needleman Wunsch algorithm

GCACCT
GACCT

Match score = 1
Mismatch score=-1
Gap penalty = -2
Smith-Waterman algorithm for Local sequence alignment

Algorithm is same as in global alignment, but there are some changes-


1. Fill the 1st column and 1st row with zero.
2. If the value comes in negative number than it is replaced by zero.
3. Trace back will be start from maximum value.

The basic steps for the algorithm are similar to that of Needleman-Wunsch algorithm.
The steps are:
1. Initialization of a matrix.
2. Matrix Filling with the appropriate scores.
3. Trace back the sequences for a suitable alignment.
To study the Local sequence alignment, consider the given below sequences.
CGTGAATTCAT (sequence#1 or A)
GACTTAC (sequence #2 or B)

Let,
Match score=1
Mismatch score =0
Gap penalty=0

The two sequences are arranged in a matrix form with A+1columns and B+1rows. The values in the first row
and first column are set to zero as shown in Figure 1.
Variables used:
          i,j describes row and columns.
          M is the matrix value of the required cell (stated as Mi,j)
          S is the score of the required cell (Si, j)
          W is the gap alignment

Mi,j=Maximum[Mi-1,j+W, Mi-1,j-1+Si, Mi,j-i+W, 0]


    C G T G A A T T C A T
  0 0 0 0 0 0 0 0 0 0 0 0
G 0  0  1  1 2 2 2 2 2 2 2 2
A 0 0 1 1 2 3 3 3 3 3 3 3
C 0 1 1 1 2 3 3 3 3 4 4 4
T 0 1 1 2 2 3 3 4 4 4 4 5
T 0 1 1 2 2 3 3 4 5 5 5 5
A 0 1 1 2 2 3 4 4 5 5 6 6
C 0 1 1 2 2 3 4 4 5 6 6 6

You might also like