Post on 19-Jan-2016
Pairwise alignments
Introduction to Bioinformatics
Jacques van Helden
Jacques.van-Helden@univ-amu.frUniversité d’Aix-Marseille, France
Lab. Technological Advances for Genomics and Clinics (TAGC, INSERM Unit U1090)
http://tagc.univ-mrs.fr/
FORMER ADDRESS (1999-2011)Université Libre de Bruxelles, Belgique
Bioinformatique des Génomes et des Réseaux (BiGRe lab)http://www.bigre.ulb.ac.be/
Dot plots : intuitive visualization of “alignable” sequence segments
Bioinformatics
Matrice de points (Matrice de pixels; dot-plot)
Le dot plot est une représentation graphique simple des résidus identiques entre les deux séquences.
Les deux séquences sont représentées sur les deux axes
Un point (dot) est tracé pour chaque correspondance entre deux résidus de séquences.
Les lignes diagonales révèlent les régions alignables entre les deux séquences.
Diapo: Emese Meglecz
ADSTARYEMQSDQIYTQN| | | ||||| AETSAQYDMQSDQEFTRD
Matrice de points (Matrice de pixels; dot-plot)
Outre les identités, on peut marquer les similarités entre acides aminés (substitutions conservatives, d’après une matrice de substitution donnée)
Exemple: marquage des paires de résidus ayant un score BLOSUM62 > 1.
Diapo: Emese Meglecz
ADSTARYEMQSDQIYTQN|:::|:|:||||| :|::AETSAQYDMQSDQEFTRD
Matrice de points (Matrice de pixels; dot-plot)
On peut appliquer à la matrice de points un filtrage par fenêtre glissante.
On n’affiche que les diagonale comportant au moins 2 points marqués successifs.
À chaque position de la matrice on extrait la paire de mots de taille w qui commence aux positions correspondantes des deux séquences.
Le score de la paire de mots est calculé en additionnant les scores des paires des résidus (d’après la matrice de substitution).
Si le score dépasse un seuil défini par l’utilisateur, une diagonale noire s'affiche à la position correspondante.
Adapté d’après Emese Meglecz
Matrice de points - Détections des INDELs
Un décalage (gap) entre deux diagonales suggère soit une délétion (sur la première séquence dans l’exemple ci-contre), soit une insertion (dans la seconde séquence).
Le simple alignement entre deux séquences ne permet pas de décider si l’événement évolutif était une délétion ou une insertion.
On désigne par « indel » l’événement évolutif supposé.
Adapté d’après Emese Meglecz
Dot plot
A dot plot is a simple graphical representation of identical residues between two sequences.
The X axis represents the first sequence (PHO5), The Y axis represents the second sequence (PHO3) A dot is plotted for each match between two residues of
the sequences. Diagonal lines reveal regions of identity between the two
sequences.
7
Example: protein sequences of the Pho5p and Pho3p phosphatases in the yeast Saccharomyces cerevisiae
http://emboss.bioinformatics.nl/cgi-bin/emboss/dottup
8
9
Dot plot with word matches
With nucleic sequences, each residue is expected every 4 positions on average. A letter-based dot plot is thus very confusing.
The dot plot can be adapted to display only word matches, which correspond to a diagonal of dots in the letter-based dot plot.
Example: alignment of PHO5 and PHO3 coding sequences, with different word sizes.
Word size = 10Word size = 3Word size = 2
10
Matrice de points - Répétitions intra-séquence
La matrice de points permet de repérer des segments répétés au sein d’une séquence.
Pour cela, on aligne la séquence avec elle-même. Les segments répétées apparaissent comme des lignes obliques parallèles à la
diagonale principale.
Adaptée d’après Emese Meglecz
RégionA RégionBSeq1
Seq1
RégionB
RégionA
Detecting repeats with a dot plot
Sequence repeats are easily detected in a dot plot when a sequence is compared to itself.
The main diagonal is completely marked (by definition, since the sequence is identical do itself)
Repeats appear as segments of lines parallel to the diagonal.
12
Gray scale dottups
Word matches require a perfect match over the whole word length.
A more refined way to show partial similarities is to use windows.
For each point, the window score is the sum of matches of its neighbours on the diagonal.
The gray level reflects the window similarity score.
13Source ?
Substitution matrices in dot plots
Substitution matrices can be used in dot plots The user has to specify the following parameters:
Window size (=word size) Score threshold Substitution matrix
At each position of the plot A pair of words of size w are extracted from the first and second sequences. The score of the word pair is calculated by summing the scores of the corresponding
pairs of residues. If the pair of words passes the threshold, a black diagonal is displayed at the
corresponding position of the dot plot. The regions of similarity between the two sequences are appear as black
diagonals on the dot plot.
14
Aspartokinases: dot plot with simple word matches
Let us compare the peptidic sequences of two enzymes from the bacteria Escherichia coli K12.
LysC aspartokinase involved in lysine biosynthesis MetL bifunctional enzyme which combines two domains
• aspartokinase catalyses the first step of methionine biosynthesis
• homoserine dehydrogenase catalyze the third step of methionine biosynthesis
On the dot plot, the region of similarity between the two aspartokinase domains is barely visible..
15
dottup result, window size=3
Aspartokinases: dot plot with substitution matrix (BLOSUM62)
With dotmatcher, a substitution matrix is used to score the similarity between each pair of residues.
This reveals the similarity between the aspartokinase domains of MetL and LysC. Note that this similarity only covers the N terminal half of MetL, because it is a bi-functional
enzyme : the C-terminal domain is a homoserine dehydrogenase. It is quite tricky to find the appropriate parameters, because these can vary from case ot
case.
16
Matrice de points – Extension à l’échelle génomique On peut transposer le concept de matrice de points à l’échelle génomique, en indiquant par
un point la présence de gènes homologues entre les deux génomes. Cette approche permet de repérer
des régions génomiques où les gènes se succèdent de façon similaires (syntons); des inversions chromosomiques.
Alignment matrix
An alignment matrix is conceptually related to a dot plot
One sequence is pasted horizontally, the other vertically
A score is assigned to each match In the case of dot plots, the
scoring scheme was very simple: match = 1 mismatch = 0
In an alignment matrix, “good” alignments appear as high-scoring diagonals.
Separations between high-scoring diagonals indicate gaps.
Vertical separation: a segment of the vertical sequence is aligned with a gap of the horizontal sequence.
Horizontal separation: gap in the vertical sequence.
18
AATCTTCAGC-----GTATTGCT-ATCTT-AGCCGGAGGTATT---
Software tools for displaying dot plot
Dotlet Junier T, Pagni M (2000) Dotlet: diagonal plots in a web browser. Bioinformatics.
16:178-9. http://myhits.isb-sib.ch/cgi-bin/dotlet
Dnadot http://www.vivo.colostate.edu/molkit/dnadot/ Draw nucleic acid dot plots, convenient for DNA/RNA alignment.
Dotter Sonnhammer EL, Durbin R (1995) A dot-matrix program with dynamic threshold
control suited for genomic DNA and protein sequence analysis. Gene. 167:GC1-10. http://www.cgb.ki.se/cgb/groups/sonnhammer/Dotter.html
19
Finding the best alignment between two sequences
Example of gapless alignment
The simplest way to align two sequences without gap is to slide one sequence over the other one, and score the alignment for each possible offset.
TTGCGGT -| 1 TTAGCCGT
TTGCGGT --- 0 TTAGCCGT
TTGCGGT ---- 0 TTAGCCGT
TTGCGGT ---|- 1 TTAGCCGT
TTGCGGT |--|-- 2 TTAGCCGT
TTGCGGT||----- 2TTAGCCGT
TTGCGGT |-||-|| 5TTAGCCGT
TTGCGGT | 1 TTAGCCGT
TTGCGGT ---||- 2TTAGCCGT
TTGCGGT ----- 0TTAGCCGT
TTGCGGT --|- 1TTAGCCGT
TTGCGGT --- 0TTAGCCGT
TTGCGGT -|TTAGCCGT
TTGCGGT | 2TTAGCCGT
- substitution| match
21
Number of possible gapless alignments
If we only consider substitutions (no deletion, no insertion), sequence alignment is very simple
A simple (but not very efficient) algorithm : Align last position of seq1 with first position of seq2 max score 0 while there are some aligned residues
• Current score number of matching residues
• If the current score > max score, then max score current score best alignment current alignment
• Slide seq1 one residue left Required time :
Let us assume that
• L1 is the length of seq1
• L2 is the length of seq2
• L2 <= L1 (seq2 is the shortest sequence if their sizes differ) There are L1+L2-1 possible offsets between sequence 1 and sequence 2 For each offset, one has to sum the score over the length of the alignment
(max=L2, when seq2 completely overlaps seq1) T ~ (L1 + L2 -1)*L2 - L2*(L2-1)
22
Exercise
We dispose of the two following sequences Seq1 TTTGCGTTAAATCGTGTAGCAATTTAA Seq2 AAGAATGGCGTTTTTAATAGCAATAT
Questions1. By progressively shifting the sequences along each other, find the offset(s) that reveal
similar regions ?
2. At each offset position, identify conserved segments (i.e. uninterrupted successions of identical residues) ?
3. Can you improve the number of matching positions by inserting some gaps ?
23
Number of possible alignments with gaps
Gapless alignments are rarely informative, because they fail to detect insertions and deletions
There might be several local matching regions, separated by a variable-length non-conserved region: ----TTTGCGTT--AAATCGTGTAGCAATTTAA s=substitution; |=match
1111s|s|||||11s||22222|||||||s|22 1=gap in the first sequence
AAGAATGGCGTTTTTAA-----TAGCAATAT-- 2=gap in the second sequence
Allowing gaps increases the complexity of the problem: at each position, there can be either
a gap in the first sequence a gap in the second sequence a superposition of residue 1 with residue 2 (match or substitution)
In total, the computational size of the problem is N~3L, where L is the size of the shortest sequence. The number of possibilities increases thus exponentially with sequence length. This rapidly becomes intractable.
For two sequences of size 1000, there are ~31000 (~10477) possible alignments. We want to find the optimal alignment, i.e. that associated with the highest score,
among all possible alignments. It is however impossible to test each alignment and measure its score, because it would take an “infinite” time.
24
Example of pairwise alignment
Example of alignment
TTTGCGTT--AAATCGTGTAGCAATTT s=substitution s|ss||||ggs||ggggg|||||||s| g=gap ATGCCGTTTTTAA-----TAGCAATAT |=identical residues
Gaps, insertions and deletions Gaps can reflect either an insertion in one of the sequences, or a deletion in the other one. The simple observation of two aligned sequences is insufficient to decide whether a gap results
from an insertion or a deletion. The term indel is sometimes used in this case to designate the evolutionary event.
25
Global (Needleman-Wunsch) versus local (Smith-Waterman) alignment
Global alignment Algorithm: Needleman-Wunsch (1970). EMBOSS Web tool: needle (nucleic acids or proteins). Appropriate, for example, for proteins having a common ancestor and being conserved over their
whole sequences. The final alignment mandatorily includes the aligned sequences over their full lengths.
LQGPSKGTGKGS-SRSWDN
|----|--|||---|--|-
LN-ITKSAGKGAIMRLGDA Local alignment
Algorithm: Smith-Waterman (1981). EMBOSS Web tool: water (nucleic acids or proteins). Appropriate, for example, for proteins sharing a common domain restricted to a segment of the
sequence.
LQGPSSKTGKGS-SSRIWDN
|-|||
LN-ITKKAGKGAIMRLGDA The final alignment is restricted to the conserved segment(s)
KTGKG
|-|||
KAGKG
Needleman, S. B. & Wunsch, C. D. (1970). A general method applicable to the search for similarities in the amino acid sequence of two proteins. J Mol Biol 48, 443-53.
Smith, T. F. & Waterman, M. S. (1981). Identification of common molecular subsequences. J Mol Biol 147, 195-7. 26
Algorithmic aspects
Finding the optimal pairwise alignment by dynamical programming
Dynamical programming - global alignment
Needleman-Wunsch proposed an algorithm called dynamical programming Performs a global alignment (the sequences are aligned on the whole length) The time of processing is proportional to the product of sequence lengths. It si thus
increasing quadratically with the sequence length, instead of exponentially. Guarantees to return the highest scoring alignment between two sequences.
28
Reference: Needleman, S. and Wunsch, C. (1970). A general method applicable to the search for similarities in the amino acid sequences of two proteins. J. Mol. Biol., 48:444–453.
Dynamical programming - global alignment
For each position in the alignment, one can have
a gap in sequence 1 a gap in sequence 2 aligned residues (match or
substitution)
T A C G T
C
T
A
G
G
A
T
29
Dynamical programming - paths
Any possible alignment between the two sequences can be represented as a path from the left top corner to the right bottom corner.
For example, the path highlighted in green corresponds to the alignment below.
- - T A - C G Tg g s s g s s gC T A G G A T –
Obviously, this alignment is not optimal : it does not contain a single match !
T A C G T
C
T
A
G
G
A
T
30
Dynamical programming - global alignment
Our goal is to find the best possible alignment, which corresponds to the path giving the optimal score (we still need to define how this score will be computed).
As discussed before, the number of possible paths increases exponentially with the sequence sizes.
Dynamical programming however allows us to find this optimal score in a quadratic time (L1*L2), by building the solution progressively.
This progressive path finding allows us to avoid evaluating a large number of paths which would anyway return a sub-optimal score.
T A C G T
C
T
A
G
G
A
T
31
Dynamical programming - initialization
The top row and left column are initialized .
We will now progressively fill the other cells of the matrix by calculating, for each cell, its optimal score as a function of the path used to reach this cell.
Two possible ways to initialize If you consider that there is no cost for an
terminal gaps (start, end), initialize first row and column with 0.
If you want to penalize terminal gaps, initialize first row and column with gap penalties.
T A C G T
C
T
A
G
G
A
T
0
0
0
0
0
0
0
0
0 0 0 0 0
32
Dynamical programming – the 3 way to leave a cell
From each starting cell, we can take 3 possible moves:
Diagonal
• Align the two residues (match or substitution)
Rightward
• Align one residue of the horizontal sequence with a gap in the vertical sequence.
Downward
• Align one residue of the vertical sequence with a gap in the horizontal sequence.
Diagonal move : align the two residues Alignment
A
CSubstitution AC
C
CCC
Match
Rightward move: insert gap in vertical sequence
A-
A
C
Downward move: insert gap in horizontal sequence
-C
A
C
33
Dynamical programming – the 3 way to leave a cell
From each starting cell, we can take 3 possible moves:
Diagonal
• Align the two residues (match or substitution)
Rightward
• Align one residue of the horizontal sequence with a gap in the vertical sequence.
Downward
• Align one residue of the vertical sequence with a gap in the horizontal sequence.
We can define a scoring scheme, and define the score of each possible direction.
match +1 substitution -1 gap -2
Diagonal move : align the two residues Alignment
A
C
2
1
-1Substitution AC
C
C
2
3
+1 CC
Match
Rightward move: insert gap in vertical sequence
A-
A
C
2 0
-2
Downward move: insert gap in horizontal sequence
-C
A
C
2
0-2
34
Exercise – what is the best way to reach a cell
Let us assume the following scoring scheme
match +1 substitution -1 gap -2
At a given destination cell, 3 scores are calculated depending on the 3 possible starting positions:
upper neighbour + gap cost left neighbour + gap cost upper-left neighbour +
• match score if the residue match
• substitution cost if residues do not match
For each of the cases besides Compute the 3 possible
scores. Indicate the best score in the
destination cell. Mark the arrow giving this best
score.
A
C
2
0
1 A
C
2
0
1A
C
2
0
1
Example 1
C
C
2
0
1 C
C
2
0
1
Example 2C
C
2
0
1
C
C
2
0
5 C
C
2
0
5
Example 4C
C
2
0
5
Example 3C
C
1
0
5 C
C
1
0
5C
C
1
0
5
Alignment?
35
Dynamical programming – the best way to reach a cell
Let us assume the following scoring scheme
match +1 substitution -1 gap -2
At a given destination cell, 3 scores are calculated depending on the 3 possible starting positions:
upper neighbour + gap cost left neighbour + gap cost upper-left neighbour +
• match score if the residue match
• substitution cost if residues do not match
The highest score is retained and the arrow is labelled
In some cases (example 4), there are several equivalent highest scores
A
C
2
0
1
-1
-2
A
C
2
0
1
1
-1
-2
A
C
2
0
1
-2
Example 1: best move is a substitution
C
C
2
0
1
-1
-2
C
C
2
0
1
3
+1
Example 2: best move is a match
-2
C
C
2
0
1
-2
C
C
2
0
5
3
-2
C
C
2
0
5
3
+1
Example 4: bets move is either gap or match
-2
C
C
2
0
5
-2
Example 3: best move is a gapC
C
1
0
5
3
-2
C
C
1
0
5
2
+1
-2
C
C
1
0
5
-2
Alignment
AC
CC
-C
CC
or -C
36
Dynamical programming - recursive computation
The first row is processed from left to right T A C G T
C
T
A
G
G
A
T
0
0
0
0
0
0
0
0
-1
0
-1
0
1
0
-1
0
-1
37
Dynamical programming - recursive computation
The second row is then processedT A C G T
C
T
A
G
G
A
T
0
0
0
0
0
0
0
0
0
-1
1
0
-1
-1
0
1
-1
0
-1
0
0
-1
0
38
Dynamical programming - recursive computation
The process is iterated until the right corner is reached.
Exercise: calculate the remaining scores.
T A C G T
C
T
A
G
G
A
T
0
0
0
0
0
0
0
0
0
-1
1
-1
-1
0
-1
-1
2
0
0
1
-1
0
1
0
-1
0
-2
1
0
-1
0
-1
-1
39
Needleman-Wunsch : exercise
Using the Needleman-Wunsch algorithm, fill the scores of the alignment matrix with the following parameters
Substitution matrix: BLOSUM62 Gap opening penalty: -5 Gap extension penalty: -1 Initial and terminal gaps: 0
S V E T D
T
S
I
N
Q
E
T
40
Needleman-Wunsch : solution of the exercise
A substitution matrix can be used to assign specific scores to each pair of residues.
Exercise: fill the scores of the alignment matrix using the BLOSUM62 substitution matrix.
Gap opening penalty: -5 Gap extension penalty: -1 Initial and terminal gaps: 0
S V E T D
T
S
I
N
Q
E
T
0
0
0
0
0
0
0
0
0
1
4
-1
1
0
0
1
0
0
-1
7
2
1
0
1
0
-1
0
2
7
4
6
1
0
5
0
1
2
6
3
11
0
0
5
5
5
5
8
11
- S V - - E T D- | : - - | | -T S I N Q E T -
41
Needleman-Wunsch example
Alignment of E.coli metL and thrA proteins with Needleman-Wunsch algorithm.
The vertical bars indicate identity between two amino-acids.
The columns and dots indicate similarities, i.e. pairs of residues having a positive scores in the chosen substitution matrix (BLOSUM62).
# Matrix: EBLOSUM62# Gap_penalty: 10.0# Extend_penalty: 0.5# Length: 867# Identity: 254/867 (29.3%)# Similarity: 423/867 (48.8%)# Gaps: 104/867 (12.0%)# Score: 929.0
metL 1 MSVIAQAGAKGRQLHKFGGSSLADVKCYLRVAGIMAEYSQPDDM-MVVSA 49 .::.||||:|:|:.:.:||||.|:...::...: .|:||thrA 1 MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSA 39
metL 50 AGSTTNQLINWLK-----------LSQTDRLSAHQVQQTLRRYQCDLISG 88 ....||.|:..:: :|..:|:.| :|::|thrA 40 PAKITNHLVAMIEKTISGQDALPNISDAERIFA------------ELLTG 77
metL 89 LLPAEEADSL--ISAFV-SDLERLAALLDSGIN------DAVYAEVVGHG 129 |..|:....| :..|| .:..::..:| .||: |::.|.::..|thrA 78 LAAAQPGFPLAQLKTFVDQEFAQIKHVL-HGISLLGQCPDSINAALICRG 126
metL 130 EVWSARLMSAVLNQQGLPAAWLD-AREFLRAERAAQPQVD--EGLSYPLL 176 |..|..:|:.||..:|.....:| ..:.|......:..|| |.......thrA 127 EKMSIAIMAGVLEARGHNVTVIDPVEKLLAVGHYLESTVDIAESTRRIAA 176
metL 177 QQLLVQHPGKRLVVTGFISRNNAGETVLLGRNGSDYSATQIGALAGVSRV 226 .::...| .:::.||.:.|..||.|:||||||||||..:.|.......thrA 177 SRIPADH---MVLMAGFTAGNEKGELVVLGRNGSDYSAAVLAACLRADCC 223
metL 227 TIWSDVAGVYSADPRKVKDACLLPLLRLDEASELARLAAPVLHARTLQPV 276 .||:||.|||:.|||:|.||.||..:...||.||:...|.|||.||:.|:thrA 224 EIWTDVDGVYTCDPRQVPDARLLKSMSYQEAMELSYFGAKVLHPRTITPI 273
metL 277 SGSEIDLQLRCSYTPDQ-----GSTRIERVLASGTGARIVTSHDDVCLIE 321 :..:|...::.:..|.. |::|.|..|. .:.:::.:::.:..thrA 274 AQFQIPCLIKNTGNPQAPGTLIGASRDEDELP----VKGISNLNNMAMFS 319
metL 322 FQVPASQDFKLAHKEIDQILKRAQVRPLAVGVHNDRQLLQFCYTSEVADS 371 ...|..:........:...:.||::..:.:...:....:.||........thrA 320 VSGPGMKGMVGMAARVFAAMSRARISVVLITQSSSEYSISFCVPQSDCVR 369
metL 372 ALKILDE-------AGLPGELRLRQGLALVAMVGAGVTRNPLHCHRFWQQ 414 |.:.:.| .||...|.:.:.||::::||.|: :.thrA 370 AERAMQEEFYLELKEGLLEPLAVTERLAIISVVGDGM-----------RT 408
metL 415 LKGQPVE-FTWQSDDGISLVAVLRTGPTESL------------IQGLHQS 451 |:|...: |...:...|::||:.:.....|: ::..||.thrA 409 LRGISAKFFAALARANINIVAIAQGSSERSISVVVNNDDATTGVRVTHQM 458
metL 452 VFRAEKRIGLVLFGKGNIGSRWLELFAREQSTLSARTGFEFVLAGVVDSR 501 :|..::.|.:.:.|.|.:|...||...|:||.|..: ..:..:.||.:|:thrA 459 LFNTDQVIEVFVIGVGGVGGALLEQLKRQQSWLKNK-HIDLRVCGVANSK 507
metL 502 RSLLSYDGLDASRALAFFNDEAVEQDEE----SLFLWMRAHPYDDLVVLD 547 ..|.:..||: |..:.:|..:..|. .|...::.:...:.|::|thrA 508 ALLTNVHGLN----LENWQEELAQAKEPFNLGRLIRLVKEYHLLNPVIVD 553
metL 548 VTASQQLADQYLDFASHGFHVISANKLAGASDSNKYRQIHDAFEKTGRHW 597 .|:||.:||||.||...||||::.||.|..|..:.|.|:..|.||:.|.:thrA 554 CTSSQAVADQYADFLREGFHVVTPNKKANTSSMDYYHQLRYAAEKSRRKF 603
metL 598 LYNATVGAGLPINHTVRDLIDSGDTILSISGIFSGTLSWLFLQFDGSVPF 647 ||:..||||||:...:::|:::||.::..|||.||:||::|.:.|..:.|thrA 604 LYDTNVGAGLPVIENLQNLLNAGDELMKFSGILSGSLSYIFGKLDEGMSF 653
metL 648 TELVDQAWQQGLTEPDPRDDLSGKDVMRKLVILAREAGYNIEPDQVRVES 697 :|....|.:.|.|||||||||||.||.|||:|||||.|..:|...:.:|.thrA 654 SEATTLAREMGYTEPDPRDDLSGMDVARKLLILARETGRELELADIEIEP 703
metL 698 LVPAHCEG-GSIDHFFENGDELNEQMVQRLEAAREMGLVLRYVARFDANG 746 ::||.... |.:..|..|..:|::....|:..||:.|.|||||...|.:|thrA 704 VLPAEFNAEGDVAAFMANLSQLDDLFAARVAKARDEGKVLRYVGNIDEDG 753
metL 747 KARVGVEAVREDHPLASLLPCDNVFAIESRWYRDNPLVIRGPGAGRDVTA 796 ..||.:..|..:.||..:...:|..|..|.:|:..|||:||.|||.||||thrA 754 VCRVKIAEVDGNDPLFKVKNGENALAFYSHYYQPLPLVLRGYGAGNDVTA 803
metL 797 GAIQSDINR-LAQLL 810 ..:.:|:.| |:..| thrA 804 AGVFADLLRTLSWKLGV 820
#---------------------------------------#---------------------------------------
42
Dynamical programming - local alignment
The Needleman-Wunsch algorithm performs a global alignemnt (it finds the best path between the two corners of the alignment matrix).
This is appropriate when the sequences are similar over their whole length, but local similarities could be missed.
In 1981, Smith and Waterman published an adaptation of the Needleman-Wunsch algorithm, which allows to detect local similarities.
Reference: Smith, T. F. and Waterman, M. S. (1981). Identification of common molecular subsequences. J. Mol. Biol., 147:195–197. 43
Dynamical programming - local alignment
Smith-Waterman algorithm The algorithm is similar to Needleman-
Wunsch, but negative scores are replaced by 0
Alignments stop after local maxima In this case we have two overlapping
alignments, each having a score of 2 :TA TACG
TA TAGG Basically, the cost of the C/G substitution
is compensate by the benefit of the G/G match.
Reference: Smith, T. F. and Waterman, M. S. (1981). Identification of common molecular subsequences. J. Mol. Biol., 147:195–197.
T A C G T
C
T
A
G
G
A
T
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
2
1
0
1
0
0
1
0
0
1
0
0
0
0
0
0
0
1
2
0
0
0
0
1
0
0
0
1
1
44
Smith-Waterman: exercise
Using the Smith-Waterman algorithm, fill the scores of the alignment matrix with the following parameters
Substitution matrix: BLOSUM62 Gap opening penalty: -5 Gap extension penalty: -1 Initial and terminal gaps: 0
S V E T D
T
S
I
N
Q
E
T
45
Smith-Waterman : solution of the exercise
A substitution matrix can be used to assign specific scores to each pair of residues.
Exercise: fill the scores of the alignment matrix using the BLOSUM62 substitution matrix.
Gap opening penalty: -5 Gap extension penalty: -1 Initial and terminal gaps: 0
S V E T D
T
S
I
N
Q
E
T
0
0
0
0
0
0
0
0
0
1
4
0
1
0
0
1
0
0
0
7
2
1
0
1
0
0
0
2
7
4
6
1
0
5
1
1
2
6
3
11
0
0
5
5
5
5
8
11
S V - - E T| : - - | |S I N Q E T
46
Case studyBacterial aspartokinaes
Needleman-Wunsch with partial similarities
Alignment of E.coli lysC and metL proteins with Needleman-Wunsch algorithm.
metL contains two domains: aspartokinase and homoserine dehydrogenase.
LysC only contains the aspartokinase domains.
With Smith-Waterman, the %similarity is calculated over the whole length of the alignment (854aa), which gives 24.5%.
Actually, most of the alignment length is in the terminal gap (the homoserine dehydrogenase domain of metL).
This percentage is lower than the usual threshold for considering two proteins as homolog.
# Matrix: EBLOSUM62# Gap_penalty: 10.0# Extend_penalty: 0.5# Length: 854# Identity: 136/854 (15.9%)# Similarity: 209/854 (24.5%)# Gaps: 449/854 (52.6%)# Score: 351.0metL 1 MSVIAQAGAKGRQLHKFGGSSLADVKCYLRVAGIMAEYSQPDDMMVVSAA 50 ||.|. :.||||:|:||.....|.|.|:...:.. .::|:||:lysC 1 MSEIV--------VSKFGGTSVADFDAMNRSADIVLSDANV-RLVVLSAS 41
metL 51 GSTTNQLINWLK-LSQTDRLSAHQVQQTLRRYQCDLISGL----LPAEEA 95 ...||.|:...: |...:|. :....:|..|..::..| :..||.lysC 42 AGITNLLVALAEGLEPGERF---EKLDAIRNIQFAILERLRYPNVIREEI 88
metL 96 DSLISAFVSDLERLAALLDSGINDAVYAEVVGHGEVWSARLMSAVLNQQG 145 :.|:.. ::.|...|||..| .|:..|:|.|||:.|..|...:|.::.lysC 89 ERLLEN-ITVLAEAAALATS---PALTDELVSHGELMSTLLFVEILRERD 134
metL 146 LPAAWLDAREFLRA-ERAAQPQVDEGLSYPLLQQLLVQHPGKRLVVT-GF 193 :.|.|.|.|:.:|. :|..:.:.|......|....|:....:.||:| ||lysC 135 VQAQWFDVRKVMRTNDRFGRAEPDIAALAELAALQLLPRLNEGLVITQGF 184
metL 194 ISRNNAGETVLLGRNGSDYSATQIGALAGVSRVTIWSDVAGVYSADPRKV 243 |...|.|.|..|||.||||:|..:......|||.||:||.|:|:.|||.|lysC 185 IGSENKGRTTTLGRGGSDYTAALLAEALHASRVDIWTDVPGIYTTDPRVV 234
metL 244 KDACLLPLLRLDEASELARLAAPVLHARTLQPVSGSEIDLQLRCSYTPDQ 293 ..|..:..:...||:|:|...|.|||..||.|...|:|.:.:..|..|..lysC 235 SAAKRIDEIAFAEAAEMATFGAKVLHPATLLPAVRSDIPVFVGSSKDPRA 284
metL 294 GSTRI---------ERVLASGTGARIVTSHDDVCLIEFQVPASQDFKLAH 334 |.|.: .|.||......::|.| ...:..|:.| || lysC 285 GGTLVCNKTENPPLFRALALRRNQTLLTLH------SLNMLHSRGF-LA- 326
metL 335 KEIDQILKRAQVRPLAVGVHNDRQLLQFCYTSEVA--------------D 370 |:..||.| ||.. :....||||: |lysC 327 -EVFGILAR----------HNIS--VDLITTSEVSVALTLDTTGSTSTGD 363
metL 371 SAL--KILDEAGLPGELRLRQGLALVAMVGAGVTR------------NPL 406 :.| .:|.|......:.:.:||||||::|..::: .|.lysC 364 TLLTQSLLMELSALCRVEVEEGLALVALIGNDLSKACGVGKEVFGVLEPF 413
metL 407 HCHRFWQQLKGQPVEFTWQSDDGISLVAVLRTGPTESLIQGLHQSVFRAE 456 :............:.|....:| .|.::|.||.::|. lysC 414 NIRMICYGASSHNLCFLVPGED------------AEQVVQKLHSNLFE 449
metL 457 KRIGLVLFGKGNIGSRWLELFAREQSTLSARTGFEFVLAGVVDSRRSLLS 506 lysC 450 449
metL 507 YDGLDASRALAFFNDEAVEQDEESLFLWMRAHPYDDLVVLDVTASQQLAD 556 lysC 450 449
metL 557 QYLDFASHGFHVISANKLAGASDSNKYRQIHDAFEKTGRHWLYNATVGAG 606 lysC 450 449
metL 607 LPINHTVRDLIDSGDTILSISGIFSGTLSWLFLQFDGSVPFTELVDQAWQ 656 lysC 450 449
metL 657 QGLTEPDPRDDLSGKDVMRKLVILAREAGYNIEPDQVRVESLVPAHCEGG 706 lysC 450 449
metL 707 SIDHFFENGDELNEQMVQRLEAAREMGLVLRYVARFDANGKARVGVEAVR 756 lysC 450 449
metL 757 EDHPLASLLPCDNVFAIESRWYRDNPLVIRGPGAGRDVTAGAIQSDINRL 806 lysC 450 449
metL 807 AQLL 810 lysC 450 449
#---------------------------------------#---------------------------------------
48
Smith-Waterman with partial similarities
Alignment of E.coli lysC and metL proteins with Smith-Waterman algorithm.
The alignment is almost identical to the one reported by Needleman-Wunsch, but the score is now considered on the aligned segments only (482 aa).
On this region, there is 42.5% of similarity.
# Matrix: EBLOSUM62# Gap_penalty: 10.0# Extend_penalty: 0.5# Length: 482# Identity: 133/482 (27.6%)# Similarity: 205/482 (42.5%)# Gaps: 85/482 (17.6%)# Score: 353.5metL 16 KFGGSSLADVKCYLRVAGIMAEYSQPDDMMVVSAAGSTTNQLINWLK-LS 64 ||||:|:||.....|.|.|:...:.. .::|:||:...||.|:...: |.lysC 8 KFGGTSVADFDAMNRSADIVLSDANV-RLVVLSASAGITNLLVALAEGLE 56
metL 65 QTDRLSAHQVQQTLRRYQCDLISGL----LPAEEADSLISAFVSDLERLA 110 ..:|. :....:|..|..::..| :..||.:.|:.. ::.|...|lysC 57 PGERF---EKLDAIRNIQFAILERLRYPNVIREEIERLLEN-ITVLAEAA 102
metL 111 ALLDSGINDAVYAEVVGHGEVWSARLMSAVLNQQGLPAAWLDAREFLRA- 159 ||..| .|:..|:|.|||:.|..|...:|.::.:.|.|.|.|:.:|. lysC 103 ALATS---PALTDELVSHGELMSTLLFVEILRERDVQAQWFDVRKVMRTN 149
metL 160 ERAAQPQVDEGLSYPLLQQLLVQHPGKRLVVT-GFISRNNAGETVLLGRN 208 :|..:.:.|......|....|:....:.||:| |||...|.|.|..|||.lysC 150 DRFGRAEPDIAALAELAALQLLPRLNEGLVITQGFIGSENKGRTTTLGRG 199
metL 209 GSDYSATQIGALAGVSRVTIWSDVAGVYSADPRKVKDACLLPLLRLDEAS 258 ||||:|..:......|||.||:||.|:|:.|||.|..|..:..:...||:lysC 200 GSDYTAALLAEALHASRVDIWTDVPGIYTTDPRVVSAAKRIDEIAFAEAA 249
metL 259 ELARLAAPVLHARTLQPVSGSEIDLQLRCSYTPDQGSTRI---------E 299 |:|...|.|||..||.|...|:|.:.:..|..|..|.|.: .lysC 250 EMATFGAKVLHPATLLPAVRSDIPVFVGSSKDPRAGGTLVCNKTENPPLF 299
metL 300 RVLASGTGARIVTSHDDVCLIEFQVPASQDFKLAHKEIDQILKRAQVRPL 349 |.||......::|.| ...:..|:.| || |:..||.| lysC 300 RALALRRNQTLLTLH------SLNMLHSRGF-LA--EVFGILAR------ 334
metL 350 AVGVHNDRQLLQFCYTSEVA--------------DSAL--KILDEAGLPG 383 ||.. :....||||: |:.| .:|.|.....lysC 335 ----HNIS--VDLITTSEVSVALTLDTTGSTSTGDTLLTQSLLMELSALC 378
metL 384 ELRLRQGLALVAMVGAGVTR------------NPLHCHRFWQQLKGQPVE 421 .:.:.:||||||::|..::: .|.:............:.lysC 379 RVEVEEGLALVALIGNDLSKACGVGKEVFGVLEPFNIRMICYGASSHNLC 428
metL 422 FTWQSDDGISLVAVLRTGPTESLIQGLHQSVF 453 |....:| .|.::|.||.::|lysC 429 FLVPGED------------AEQVVQKLHSNLF 448
#---------------------------------------#---------------------------------------
49
Case studyPairwise similarities between opsins
Needleman-Wunsch – pairwise comparisons between opsins
51
Dynamical programming - summary
Guarantees to find the optimal score. Is able to return all the alignments which raise the optimal score. Processing time is proportional to product of sequence lengths. Can be adapted for global (Needleman-Wunsch) or local (Smith-Waterman)
alignment. Global alignments
are appropriate for aligning sequences conserved over their whole length (recent divergence).
Local alignments Are able to detect domains which cover only a fraction of the sequences Are also able to return a complete alignment, when the conservation covers the whole
sequence
52
References
Dynamical programming applied to pairwise sequence alignment Needleman-Wunsch (pairwise, global)
• Needleman, S. B. & Wunsch, C. D. (1970). A general method applicable to the search for similarities in the amino acid sequence of two proteins. J Mol Biol 48, 443-53.
Smith-Waterman (pairwise, local)
• Smith, T. F. & Waterman, M. S. (1981). Identification of common molecular subsequences. J Mol Biol 147, 195-7.
Software tools The EMBOSS suite provides efficient implementations of the two “classical” dynamical
programming algorithms
• needle Needleman-Wunsch
• water Smith-Waterman Pairwise Sequence Alignment tools at the EBI
• A web interface to EMBOSS tools (needle, water)
• http://www.ebi.ac.uk/Tools/psa/ They can be installed locally or accessed via the SRS Web server
• http://srs.ebi.ac.uk/
53
Exercice
T A C G T
Q
P
M
L
S
C
Q54