View
109
Download
1
Category
Preview:
Citation preview
IFT3295Démonstration
28 septembre 2011
Shift-And (avec erreurs)
Plan
• Présentation en détail de l'algorithme Shift-And (avec erreurs)
• Présentation de PROSITE
Shift-And (avec erreurs)
• Wu et Manber (1992)
• Base du logiciel agrep de Unix
• Recherche approximative d'un mot dans un texte
• Permet les insertions, les délétions et les substitutions de caractères
Shift-And (avec erreurs)
• Exemple :– Texte : aabaacaabacab– Mot : aabac (|mot| = m)– Alphabet : {a, b, c}
• Pré-traitement : – Pour chaque caractère x de l'alphabet, on
construit un tableau de bits Sx tel que Sx[pos] = 1 si motpos = x (pour 1 <= pos <= m)
Shift-And (avec erreurs)
• Pré-traitement : – Pour chaque caractère x de l'alphabet, on
construit un tableau de bits Sx tel que Sx[pos] = 1 si motpos = x (pour 1 <= pos <= m)
1
1
0
1
0
0
0
1
0
0
0
0
0
0
1
a
a
b
a
c
Mot : Sa Sb Sc
Shift-And (avec erreurs)
• Soit k, le nombre d'erreurs que l'on veut permettre
• On doit construire (k+1) tableaux de bits R de taille m * (n+1) (où n = |texte|) (quoique la plupart des colonnes pourront être oubliées) :– R0, R1, …, Rk
Shift-And (avec erreurs)
• Les tableaux R doivent être construits dans l'ordre croissant du nombre d'erreurs
• Regardons d'abord la construction de R0, qui est l'équivalent de Shift-Or (recherche exacte)
Shift-And (avec erreurs)
• Au départ :
a a b a a c a a b a c a b
1 1 1 1 1 1 1 1 1 1 1 1 1 1
a 0
a 0
b 0
a 0
c 0
R0
Shift-And (avec erreurs)
• Objectif : trouver 1 sur la ligne m match
a a b a a c a a b a c a b
1 1 1 1 1 1 1 1 1 1 1 1 1 1
a 0
a 0
b 0
a 0
c 0
R0
Shift-And (avec erreurs)
R0j+1[i] =
a a b a a c a a b a c a b
1 1 1 1 1 1 1 1 1 1 1 1 1 1
a 0
a 0
b 0
a 0
c 0
R0
1 si R0j[i-1] = 1 et moti = textej+1
0 sinonj+1j
i
i-1
Shift-And (avec erreurs)
a a b a a c a a b a c a b
1 1 1 1 1 1 1 1 1 1 1 1 1 1
a 0
a 0
b 0
a 0
c 0
R0
R0j+1[i] =
1 si R0j[i-1] = 1 et moti = textej+1
0 sinonj+1j
i
i-1
Shift-And (avec erreurs)
a a b a a c a a b a c a b
1 1 1 1 1 1 1 1 1 1 1 1 1 1
a 0 1
a 0
b 0
a 0
c 0
R0
R0j+1[i] =
1 si R0j[i-1] = 1 et moti = textej+1
0 sinonj+1j
i
i-1
Shift-And (avec erreurs)
a a b a a c a a b a c a b
1 1 1 1 1 1 1 1 1 1 1 1 1 1
a 0 1
a 0
b 0
a 0
c 0
R0
R0j+1[i] =
1 si R0j[i-1] = 1 et moti = textej+1
0 sinonj+1j
i
i-1
Shift-And (avec erreurs)
a a b a a c a a b a c a b
1 1 1 1 1 1 1 1 1 1 1 1 1 1
a 0 1
a 0
b 0
a 0
c 0
R0
R0j+1[i] =
1 si R0j[i-1] = 1 et moti = textej+1
0 sinonj+1j
i
i-1
Shift-And (avec erreurs)
a a b a a c a a b a c a b
1 1 1 1 1 1 1 1 1 1 1 1 1 1
a 0 1
a 0 0
b 0
a 0
c 0
R0
R0j+1[i] =
1 si R0j[i-1] = 1 et moti = textej+1
0 sinonj+1j
i
i-1
Shift-And (avec erreurs)
a a b a a c a a b a c a b
1 1 1 1 1 1 1 1 1 1 1 1 1 1
a 0 1
a 0 0
b 0 0
a 0 0
c 0 0
R0
R0j+1[i] =
1 si R0j[i-1] = 1 et moti = textej+1
0 sinon
Shift-And (avec erreurs)
a a b a a c a a b a c a b
1 1 1 1 1 1 1 1 1 1 1 1 1 1
a 0 1 1
a 0 0 1
b 0 0 0
a 0 0 0
c 0 0 0
R0
R0j+1[i] =
1 si R0j[i-1] = 1 et moti = textej+1
0 sinon
Shift-And (avec erreurs)
• Qu'est-ce que ça représente?
a a b a a c a a b a c a b
1 1 1 1 1 1 1 1 1 1 1 1 1 1
a 0 1 1
a 0 0 1
b 0 0 0
a 0 0 0
c 0 0 0
R0
j+1j
i
i-1
Shift-And (avec erreurs)
• Qu'est-ce que ça représente?
a a b a a c a a b a c a b
1 1 1 1 1 1 1 1 1 1 1 1 1 1
a 0 1 1
a 0 0 1
b 0 0 0
a 0 0 0
c 0 0 0
R0
j+1j
i
i-1
Shift-And (avec erreurs)
• Qu'est-ce que ça représente?
a a b a a c a a b a c a b
1 1 1 1 1 1 1 1 1 1 1 1 1 1
a 0 1 1
a 0 0 1
b 0 0 0
a 0 0 0
c 0 0 0
R0
j+1j
i
i-1
Shift-And (avec erreurs)
• Qu'est-ce que ça représente?
a a b a a c a a b a c a b
1 1 1 1 1 1 1 1 1 1 1 1 1 1
a 0 1 1 0
a 0 0 1 0
b 0 0 0 1
a 0 0 0 0
c 0 0 0 0
R0
j+1j
i
i-1
Shift-And (avec erreurs)
• Qu'est-ce que ça représente?
a a b a a c a a b a c a b
1 1 1 1 1 1 1 1 1 1 1 1 1 1
a 0 1 1 0
a 0 0 1 0
b 0 0 0 1
a 0 0 0 0
c 0 0 0 0
R0
j+1j
i
i-1
Shift-And (avec erreurs)
• Qu'est-ce que ça représente?
a a b a a c a a b a c a b
1 1 1 1 1 1 1 1 1 1 1 1 1 1
a 0 1 1 0
a 0 0 1 0
b 0 0 0 1
a 0 0 0 0
c 0 0 0 0
R0
j+1j
i
i-1
Shift-And (avec erreurs)
• Cette transition peut être calculée bien plus efficacement
• R0j+1 = Rshift[R0
j] AND Sj+1
où Sj+1 est la table de pré-traitement du caractère qui est à la position j+1 dans le texte
1
1
0
1
0
Sa
0
0
1
0
0
Sb
0
0
0
0
1
Sc
Shift-And (avec erreurs)
• Rshift :– On décale les bits à droite d'une
position, on élimine le dernier bit et on insère 1 à gauche
Rshift[00000] = 10000
Rshift[10001] = 11000
Shift-And (avec erreurs)
• R0j+1 = Rshift[R0
j] AND Sj+1
a a b a a c a a b a c a b
a 0
a 0
b 0
a 0
c 0
R0
1
1
0
1
0
Sa
0
0
1
0
0
Sb
0
0
0
0
1
Sc
Shift-And (avec erreurs)
a a b a a c a a b a c a b
a 0
a 0
b 0
a 0
c 0
R0
1
1
0
1
0
Sa
0
0
1
0
0
Sb
0
0
0
0
1
Sc
j+1j
• R0j+1 = Rshift[R0
j] AND Sj+1
Shift-And (avec erreurs)
a a b a a c a a b a c a b
a 0 1
a 0 0
b 0 0
a 0 0
c 0 0
R0
1
1
0
1
0
Sa
0
0
1
0
0
Sb
0
0
0
0
1
Sc
j+1j
0
• R0j+1 = Rshift[R0
j] AND Sj+1
Shift-And (avec erreurs)
a a b a a c a a b a c a b
a 0 1
a 0 0
b 0 0
a 0 0
c 0 0
R0
1
1
0
1
0
Sa
0
0
1
0
0
Sb
0
0
0
0
1
Sc
j+1j
• R0j+1 = Rshift[R0
j] AND Sj+1
Shift-And (avec erreurs)
a a b a a c a a b a c a b
a 0 1
a 0 0
b 0 0
a 0 0
c 0 0
R0
1
1
0
1
0
Sa
0
0
1
0
0
Sb
0
0
0
0
1
Sc
j+1j
• R0j+1 = Rshift[R0
j] AND Sj+1
Shift-And (avec erreurs)
a a b a a c a a b a c a b
a 0 1
a 0 0
b 0 0
a 0 0
c 0 0
R0
1
1
0
1
0
Sa
0
0
1
0
0
Sb
0
0
0
0
1
Sc
j+1j
• R0j+1 = Rshift[R0
j] AND Sj+1
Shift-And (avec erreurs)
a a b a a c a a b a c a b
a 0 1 1
a 0 0 1
b 0 0 0
a 0 0 0
c 0 0 0
R0
1
1
0
1
0
Sa
0
0
1
0
0
Sb
0
0
0
0
1
Sc
j+1j
0
• R0j+1 = Rshift[R0
j] AND Sj+1
Shift-And (avec erreurs)
a a b a a c a a b a c a b
a 0 1 1
a 0 0 1
b 0 0 0
a 0 0 0
c 0 0 0
R0
1
1
0
1
0
Sa
0
0
1
0
0
Sb
0
0
0
0
1
Sc
j+1j
• R0j+1 = Rshift[R0
j] AND Sj+1
Shift-And (avec erreurs)
a a b a a c a a b a c a b
a 0 1 1
a 0 0 1
b 0 0 0
a 0 0 0
c 0 0 0
R0
1
1
0
1
0
Sa
0
0
1
0
0
Sb
0
0
0
0
1
Sc
j+1j
• R0j+1 = Rshift[R0
j] AND Sj+1
Shift-And (avec erreurs)
a a b a a c a a b a c a b
a 0 1 1
a 0 0 1
b 0 0 0
a 0 0 0
c 0 0 0
R0
1
1
0
1
0
Sa
0
0
1
0
0
Sb
0
0
0
0
1
Sc
j+1j
• R0j+1 = Rshift[R0
j] AND Sj+1
Shift-And (avec erreurs)
a a b a a c a a b a c a b
a 0 1 1 1
a 0 0 1 1
b 0 0 0 1
a 0 0 0 0
c 0 0 0 0
R0
1
1
0
1
0
Sa
0
0
1
0
0
Sb
0
0
0
0
1
Sc
j+1j
0
• R0j+1 = Rshift[R0
j] AND Sj+1
Shift-And (avec erreurs)
a a b a a c a a b a c a b
a 0 1 1 1
a 0 0 1 1
b 0 0 0 1
a 0 0 0 0
c 0 0 0 0
R0
1
1
0
1
0
Sa
0
0
1
0
0
Sb
0
0
0
0
1
Sc
j+1j
• R0j+1 = Rshift[R0
j] AND Sj+1
Shift-And (avec erreurs)
a a b a a c a a b a c a b
a 0 1 1 0
a 0 0 1 0
b 0 0 0 1
a 0 0 0 0
c 0 0 0 0
R0
1
1
0
1
0
Sa
0
0
1
0
0
Sb
0
0
0
0
1
Sc
j+1j
• R0j+1 = Rshift[R0
j] AND Sj+1
Shift-And (avec erreurs)
a a b a a c a a b a c a b
a 0 1 1 0 1 1 0 1 1 0 1 0 1 0
a 0 0 1 0 0 1 0 0 1 0 0 0 0 0
b 0 0 0 1 0 0 0 0 0 1 0 0 0 0
a 0 0 0 0 1 0 0 0 0 0 1 0 0 0
c 0 0 0 0 0 0 0 0 0 0 0 1 0 0
R0
1
1
0
1
0
Sa
0
0
1
0
0
Sb
0
0
0
0
1
Sc• R0j+1 = Rshift[R0
j] AND Sj+1
Shift-And (avec erreurs)
• Nous venons de voir la construction de R0, qui est l'équivalent de Shift-Or (recherche exacte)
• Que fait-on pour R1, R2, …, Rk?
• Trois types d'erreurs sont permises : insertions, délétions et substitutions
Shift-And (avec erreurs)
• Insertion (1er cas) :
a a b a a c a a b a c a b
a a
j+1
i = 2
R0j+1[2] = 0
Shift-And (avec erreurs)
• Insertion (1er cas) :
a a b a a c a a b a c a b
a a b
j+1
i = 2 R1j+1[2] = 1
R0j+1[2] = 0
Shift-And (avec erreurs)
• Insertion (2e cas) :
a a b a a c a a b a c a b
a a
j+1
i = 2
R0j+1[2] = 0
Shift-And (avec erreurs)
• Insertion (2e cas) :
a a b a a c a a b a c a b
a b a
j+1
i = 2
R0j+1[2] = 0
R1j+1[2] = 1
Shift-And (avec erreurs)
• Délétion (1er cas) :
a a b a a c a a b a c a b
a b a a b
j+1
i = 5
R0j+1[5] = 0
Shift-And (avec erreurs)
• Délétion (1er cas) :
a a b a a c a a b a c a b
a b a a b
j+1
i = 5
R0j+1[5] = 0
R1j+1[5] = 1
Shift-And (avec erreurs)
• Délétion (2e cas) :
a a b a a c a a b a c a b
a b a a b c
j+1
i = 6
R0j+1[6] = 0
R1j+1[6] = 1
Shift-And (avec erreurs)
• Substitution (1er cas) :
a a b a a c a a b a c a b
a a b a c
j+1
i = 5
R0j+1[5] = 0
Shift-And (avec erreurs)
• Substitution (1er cas) :
a a b a a c a a b a c a b
a a b a c
j+1
i = 5
R0j+1[5] = 0
R1j+1[5] = 1
Shift-And (avec erreurs)
• Substitution (2e cas) :
a a b a a c a a b a c a b
a a b c a
j+1
i = 5
R0j+1[5] = 0
R1j+1[5] = 1
Shift-And (avec erreurs)
• On peut résumer tous ces cas dans la formule de transition suivante :
Rdj+1 = Rshift[Rd
j] AND Sj+1 OR
Rshift[Rd-1j] OR
Rshift[Rd-1j+1] OR
Rd-1j
Shift-And (avec erreurs)
• On peut résumer tous ces cas dans la formule de transition suivante :
Rdj+1 = Rshift[Rd
j] AND Sj+1 OR
Rshift[Rd-1j OR Rd-1
j+1] OR
Rd-1j
Shift-And (avec erreurs)Rd
j+1 = Rshift[Rdj] AND Sj+1 OR Rshift[Rd-1
j OR Rd-1j+1] OR Rd-1
j
a a b a a c a a b a c a b
a 0
a 0
b 0
a 0
c 0
R1
Shift-And (avec erreurs)Rd
j+1 = Rshift[Rdj] AND Sj+1 OR Rshift[Rd-1
j OR Rd-1j+1] OR Rd-1
j
a a b a a c a a b a c a b
a 0
a 0
b 0
a 0
c 0
R1
Shift-And (avec erreurs)Rd
j+1 = Rshift[Rdj] AND Sj+1 OR Rshift[Rd-1
j OR Rd-1j+1] OR Rd-1
j
R1j+1 = Rshift[00000] AND 11010 OR Rshift[00000 OR 10000] OR 00000
= 10000 AND 11010 OR Rshift[10000] = 10000 OR 11000 = 11000
a a b a a c a a b a c a b
a 0
a 0
b 0
a 0
c 0
R1
j+1j
Shift-And (avec erreurs)
a a b a a c a a b a c a b
a 0 1 1 0 1 1 0 1 1 0 1 0 1 0
a 0 0 1 0 0 1 0 0 1 0 0 0 0 0
b 0 0 0 1 0 0 0 0 0 1 0 0 0 0
a 0 0 0 0 1 0 0 0 0 0 1 0 0 0
c 0 0 0 0 0 0 0 0 0 0 0 1 0 0
R0
1
1
0
1
0
Sa
0
0
1
0
0
Sb
0
0
0
0
1
Sc
Shift-And (avec erreurs)Rd
j+1 = Rshift[Rdj] AND Sj+1 OR Rshift[Rd-1
j OR Rd-1j+1] OR Rd-1
j
R1j+1 = Rshift[00000] AND 11010 OR Rshift[00000 OR 10000] OR 00000
= 10000 AND 11010 OR Rshift[10000] = 10000 OR 11000 = 11000
a a b a a c a a b a c a b
a 0 1
a 0 1
b 0 0
a 0 0
c 0 0
R1
j+1j
Shift-And (avec erreurs)Rd
j+1 = Rshift[Rdj] AND Sj+1 OR Rshift[Rd-1
j OR Rd-1j+1] OR Rd-1
j
a a b a a c a a b a c a b
a 0 1
a 0 1
b 0 0
a 0 0
c 0 0
R1
j+1j
Shift-And (avec erreurs)Rd
j+1 = Rshift[Rdj] AND Sj+1 OR Rshift[Rd-1
j OR Rd-1j+1] OR Rd-1
j
R1j+1 = Rshift[11000] AND 11010 OR Rshift[10000 OR 11000] OR 10000
= 11100 AND 11010 OR Rshift[11000] OR 10000
= 11000 OR 11100 OR 10000 = 11100
a a b a a c a a b a c a b
a 0 1
a 0 1
b 0 0
a 0 0
c 0 0
R1
j+1j
Shift-And (avec erreurs)
a a b a a c a a b a c a b
a 0 1 1 0 1 1 0 1 1 0 1 0 1 0
a 0 0 1 0 0 1 0 0 1 0 0 0 0 0
b 0 0 0 1 0 0 0 0 0 1 0 0 0 0
a 0 0 0 0 1 0 0 0 0 0 1 0 0 0
c 0 0 0 0 0 0 0 0 0 0 0 1 0 0
R0
1
1
0
1
0
Sa
0
0
1
0
0
Sb
0
0
0
0
1
Sc
Shift-And (avec erreurs)Rd
j+1 = Rshift[Rdj] AND Sj+1 OR Rshift[Rd-1
j OR Rd-1j+1] OR Rd-1
j
R1j+1 = Rshift[11000] AND 11010 OR Rshift[10000 OR 11000] OR 10000
= 11100 AND 11010 OR Rshift[11000] OR 10000
= 11000 OR 11100 OR 10000 = 11100
a a b a a c a a b a c a b
a 0 1 1
a 0 1 1
b 0 0 1
a 0 0 0
c 0 0 0
R1
j+1j
Shift-And (avec erreurs)
• Il est inutile de garder toutes les colonnes des (k+1) tableaux en mémoire
• L'idée est de calculer la colonne (j+1) pour R0, ensuite pour R1, … et enfin pour Rk
• Ensuite, on pourra oublier la colonne j de tous les tableaux lorsqu'on calculera la colonne (j+2)
Shift-And (avec erreurs)
• Complexité :
– O(kn) lorsque le mot n'est pas trop grand
avec
k = nombre d'erreurs permises
n = longueur du texte
- O(kn * nbMotsMachine) sinon
PROSITE
• Base de données dédiée à l'identification de familles de protéines et de domaines
• Collection de motifs décrits en tant que patterns ou profils, reliés à la documentation décrivant les familles de protéines ou les domaines en question
PROSITE
• Pattern = expression régulière
• Les patterns sont identifiés à partir des alignements multiples des protéines d'une même famille
PROSITE
• Les patterns choisis représentent des motifs importants dans la séquence (10 à 20 acides aminés)– régions conservées qui ont une signification
biologique importante (site catalytique, site de liaison, etc.)
• On peut identifier la fonction d'une protéine dont la séquence diffère beaucoup avec celles de la base de données si on y retrouve un certain pattern
PROSITE
• Syntaxe des patterns :– Chaque élément est séparé par -– x : n'importe quel– x(2) : x-x– x(2,4) : x-x, x-x-x ou x-x-x-x – [ALT] : Ala, Leu ou Thr– {AM} : n'importe quel sauf Ala, Met– < (au début) : doit être dans la partie N-terminale– > (à la fin) : doit être dans la partie C-terminale
PROSITE
• Exemples :– [AC]-x-V-x(4)-{ED} =
[Ala or Cys]-any-Val-any-any-any-any-{any but Glu or Asp}
– < A-x-[ST](2)-x(0,1)-V =
Ala-any-[Ser or Thr]-[Ser or Thr]-(any or none)-Val
qui doit être dans la partie N-terminale de la séquence
Recommended