tècniques i eines bioinformàtiques

34
Tècniques i Eines Bioinformàtiques informatics, Sequence and Genome Analysis David W. Mount xible Pattern Matching in Strings (2002) Gonzalo Navarro and Mathieu Raffinot orithms on strings (2001) M. Crochemore, C. Hancart and T. Lecroq p://www-igm.univ-mlv.fr/~lecroq/string/index

Upload: doane

Post on 07-Jan-2016

34 views

Category:

Documents


7 download

DESCRIPTION

Tècniques i Eines Bioinformàtiques. Bioinformatics, Sequence and Genome Analysis David W. Mount Flexible Pattern Matching in Strings (2002) Gonzalo Navarro and Mathieu Raffinot Algorithms on strings (2001) M. Crochemore, C. Hancart and T. Lecroq - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Tècniques i Eines Bioinformàtiques

Tècniques i Eines Bioinformàtiques

•Bioinformatics, Sequence and Genome AnalysisDavid W. Mount

•Flexible Pattern Matching in Strings (2002)Gonzalo Navarro and Mathieu Raffinot

•Algorithms on strings (2001)M. Crochemore, C. Hancart and T. Lecroq

•http://www-igm.univ-mlv.fr/~lecroq/string/index.html

Page 2: Tècniques i Eines Bioinformàtiques

Algorismes i estructures eficients de cerca

String matching: definition of the problem (text,pattern) depends on what we have: text or patterns• Exact matching:

• 1 pattern ---> The algorithm depends on |p| and || • k patterns ---> The algorithm depends on k, |p| and ||

• The text ----> Data structure for the text (suffix tree, ...)

• The patterns ---> Data structures for the patterns

Page 3: Tècniques i Eines Bioinformàtiques

Exact string matching: one pattern

For instance, given the sequence

CTACTACTACGTCTATACTGATCGTAGCTACTACATGC

search for the pattern ACTGA.

How does the string algorithms made the search?

and for the pattern TACTACGGTATGACTAA

Page 4: Tècniques i Eines Bioinformàtiques

Exact string matching: Brute force algorithm

Given the pattern ATGTA, the search is

G T A C T A G A G G A C G T A T G T A C T G ...A T G T A

A T G T A

A T G T A

A T G T A A T G T A

A T G T A

Example:

Page 5: Tècniques i Eines Bioinformàtiques

Exact string matching: Brute force algorithm

Text :

Pattern :

From left to right: prefix

• Which is the next position of the window?

• How the comparison is made?

Pattern :

Text :

The window is shifted only one cell

Page 6: Tècniques i Eines Bioinformàtiques

Exact string matching: one pattern

There is a sliding window along the text against which the pattern is compared:

How does the matching algorithms made the search?

Pattern :

Text :

Which are the facts that differentiate the algorithms?

1. How the comparison is made.2. The length of the shift.

At each step the comparison is made and the window is shifted to the right.

Page 7: Tècniques i Eines Bioinformàtiques

Exact string matching: one pattern (text on-line)

Experimental efficiency (Navarro & Raffinot)

2 4 8 16 32 64 128 256

64

32

16

8

4

2

| |

Long. pattern

Horspool

BNDMBOM

BNDM : Backward Nondeterministic Dawg Matching

BOM : Backward Oracle Matching

w

Page 8: Tècniques i Eines Bioinformàtiques

Horspool algorithm

Text :

Pattern :Sufix search

• Which is the next position of the window?

• How the comparison is made?

Pattern :

Text : a

Shift until the next ocurrence of “a” in the pattern:

aa a

a a a

We need a preprocessing phase to construct the shift table.

Page 9: Tècniques i Eines Bioinformàtiques

Horspool algorithm : example

Given the pattern ATGTA

• The shift table is:

A C G T

Page 10: Tècniques i Eines Bioinformàtiques

Horspool algorithm : example

Given the pattern ATGTA

• The shift table is:

A 4C G T

Page 11: Tècniques i Eines Bioinformàtiques

Horspool algorithm : example

Given the pattern ATGTA

• The shift table is:

A 4C 5G T

Page 12: Tècniques i Eines Bioinformàtiques

Horspool algorithm : example

Given the pattern ATGTA

• The shift table is:

A 4C 5G 2T

Page 13: Tècniques i Eines Bioinformàtiques

Horspool algorithm : example

Given the pattern ATGTA

• The shift table is:

A 4C 5G 2T 1

Page 14: Tècniques i Eines Bioinformàtiques

Horspool algorithm : example

Given the pattern ATGTA

• The shift table is:

A 4C 5G 2T 1

• The searching phase: G T A C T A G A G G A C G T A T G T A C T G ...A T G T A

A T G T A

A T G T A

A T G T A A T G T A

A T G T A

Page 15: Tècniques i Eines Bioinformàtiques

Exemple algorisme de Horspool

Given the pattern ATGTA

• The shift table is:

A 4C 5G 2T 1

• The searching phase: G T A C T A G A G G A C G T A T G T A C T G ...A T G T A

A T G T A

A T G T A

A T G T A A T G T A

A T G T A A T G T A

Page 16: Tècniques i Eines Bioinformàtiques

Qüestions sobre l’algorisme de Horspool

A 4C 5G 2T 1 Given a random text over an

equally likely probability distribution (EPD):

Given the pattern ATGTA, the shift table is

1.- Determine the expected shift of the window. And, if the PD is not equally likely?

2.- Determine the expected number of shifts assuming a text of length n.

3.- Determine the expected number of comparisons in the suffix search phase

Page 17: Tècniques i Eines Bioinformàtiques

Exact string matching: one pattern (text on-line)

Experimental efficiency (Navarro & Raffinot)

2 4 8 16 32 64 128 256

64

32

16

8

4

2

| |

Long. pattern

Horspool

BNDMBOM

BNDM : Backward Nondeterministic Dawg Matching

BOM : Backward Oracle Matching

w

Page 18: Tècniques i Eines Bioinformàtiques

Text :

Pattern :

Search for suffixes of T that are factors of

BNDM algorithm

• Which is the next position of the window ?

• How the comparison is made?

That is denoted as

D2 = 1 0 0 0 1 0 0

Depends on the value of the leftmost bit of D

Once the next character x is read D3 = D2<<1 & B(x)

B(x): mask of x in the pattern P. For instance, if B(x) = ( 0 0 1 1 0 0 0)

D = (0 0 0 1 0 0 0) & (0 0 1 1 0 0 0 ) = (0 0 0 1 0 0 0 )

x

Page 19: Tècniques i Eines Bioinformàtiques

BNDM algorithm: exaple

Given the pattern ATGTA

• The searching phase: G T A C T A G A G G A C G T A T G T A C T G ...A T G T A

A T G T A

A T G T A

A T G T A

• The mask of characters is:

B(A) = ( 1 0 0 0 1 )B(C) = ( 0 0 0 0 0 )B(G) = ( 0 0 1 0 0 )B(T) = ( 0 1 0 1 0 )

D1 = ( 0 1 0 1 0 )D2 = ( 1 0 1 0 0 ) & ( 0 0 0 0 0 ) = ( 0 0 0 0 0 )

D1 = ( 0 0 1 0 0 )D2 = ( 0 1 0 0 0 ) & ( 0 0 1 0 0 ) = ( 0 0 0 0 0 )

D1 = ( 1 0 0 0 1 )D2 = ( 0 0 0 1 0 ) & ( 0 1 0 1 0 ) = ( 0 0 0 1 0 )D3 = ( 0 0 1 0 0 ) & ( 0 0 1 0 0) = ( 0 0 1 0 0 )D4 = ( 0 1 0 0 0 ) & ( 0 0 0 0 0) = ( 0 0 0 0 0 )

Page 20: Tècniques i Eines Bioinformàtiques

Exemple algorisme BNDM

A T G T A

• Given the pattern ATGTA

• The mask of characters is :

• The searching phase: G T A C T A G A G G A C G T A T G T A C T G ...A T G T A

B(A) = ( 1 0 0 0 1 )B(C) = ( 0 0 0 0 0 )B(G) = ( 0 0 1 0 0 )B(T) = ( 0 1 0 1 0 )

D1 = ( 1 0 0 0 1 )D2 = ( 0 0 0 1 0 ) & ( 0 1 0 1 0 ) = ( 0 0 0 1 0 )D3 = ( 0 0 1 0 0 ) & ( 0 0 1 0 0 ) = ( 0 0 1 0 0 )D4 = ( 0 1 0 0 0 ) & ( 0 1 0 1 0 ) = ( 0 1 0 0 0 )D5 = ( 1 0 0 0 0 ) & ( 1 0 0 0 1 ) = ( 1 0 0 0 0 )D6 = ( 0 0 0 0 0 ) & ( * * * * * ) = ( 0 0 0 0 0 ) Trobat!

Page 21: Tècniques i Eines Bioinformàtiques

Exemple algorisme BNDM

Given the pattern ATGTA

• The searching phase: G T A C T A G A A T A C G T A T G T A C T G ...A T G T A

A T G T A

A T G T A

• The mask of characters is :

B(A) = ( 1 0 0 0 1 )B(C) = ( 0 0 0 0 0 )B(G) = ( 0 0 1 0 0 )B(T) = ( 0 1 0 1 0 )

D1 = ( 0 1 0 1 0 )D2 = ( 1 0 1 0 0 ) & ( 0 0 0 0 0 ) = ( 0 0 0 0 0 )

D1 = ( 0 1 0 1 0 )D2 = ( 1 0 1 0 0 ) & ( 1 0 0 0 1 ) = ( 1 0 0 0 0 ) D3 = ( 0 0 0 0 0 ) & ( 1 0 0 0 1 ) = ( 0 0 0 0 0 )

How the shif is determined?

Page 22: Tècniques i Eines Bioinformàtiques

Alg. Cerca exacta d’un patró (text on-line)

Algorismes més eficients (Navarro & Raffinot)

2 4 8 16 32 64 128 256

64

32

16

8

4

2

| |

Long. patró

Horspool

BNDMBOM

BNDM : Backward Nondeterministic Dawg Matching

BOM : Backward Oracle Matching

w

Page 23: Tècniques i Eines Bioinformàtiques

Autòmata Factor Oracle: propietats

Factor Oracle del mot G T A T G T A

GG AT T ATTA

G

Tots els estats són finals ==> Reconeix tots els factors …. i més

GG AT T ATTA

G

Hip: reconeix tots factors de GTA

L’estat reconeix tots els factors que acaben a la quarta lletra T que no eren reconeguts:GTAT, TAT, AT perque T ja ho era.

Reconeix tots els factors de de les primeres 4 lletres

Page 24: Tècniques i Eines Bioinformàtiques

Autòmata Factor Oracle: algorisme

Algorisme: per a i=1 fins p fer Afegir transicions que reconeguin factors acabats a i;

?

Page 25: Tècniques i Eines Bioinformàtiques

Autòmata Factor Oracle: algorisme

Que passa si el següent caràcter existeix?

TT

Page 26: Tècniques i Eines Bioinformàtiques

Autòmata Factor Oracle: algorisme

Que passa si el següent caràcter no existeix?

TT

Page 27: Tècniques i Eines Bioinformàtiques

Autòmata Factor Oracle: exemple d’algorisme

GG AT T ATTA

G

i reconeix mots que no són factors com GTGTA.

Però, si no el reconeix ==> no és factor!

Es l’estratègia de l’algorisme BOM

Page 28: Tècniques i Eines Bioinformàtiques

Algorisme BOM (Backward Oracle Matching)

• Com es determina la següent posició de la finestra?

• Com fa la comparació?

Text :

Patró : Autòmata: Factor Oracle

Comproba si el sufix és factor del patró

a

• Si la a no s’ha trobat

• Si arriben a l’estat final de l’autòmat amb la a

a

Page 29: Tècniques i Eines Bioinformàtiques

Autòmata Factor Oracle: exemple d’algorisme

• Es construeix l’autòmata del patró invers: Suposem que el patró és ATGTATG

• I la cerca sobre el text : G T A C T A G A A T G T G T A G A C A T G T A T G G T G A...A T G T A T G

• Com fa la comparació?

GG AT T ATTA

G

Page 30: Tècniques i Eines Bioinformàtiques

Autòmata Factor Oracle: exemple d’algorisme

• Es construeix l’autòmata del patró invers: Suposem que el patró és ATGTATG

• I la cerca sobre el text : G T A C T A G A A T G T G T A G A C A T G T A T G G T GA T G T A T G

• Com fa la comparació?

GG AT T ATTA

G

A T G T A T G

Page 31: Tècniques i Eines Bioinformàtiques

Autòmata Factor Oracle: exemple d’algorisme

• Es construeix l’autòmata del patró invers: Suposem que el patró és ATGTATG

• I la cerca sobre el text : G T A C T A G A A T G T G T A G A C A T G T A T G G T G A T G T A T G

• Com fa la comparació?

GG AT T ATTA

G

A T G T A T G A T G T A T G

Page 32: Tècniques i Eines Bioinformàtiques

Autòmata Factor Oracle: exemple d’algorisme

• Es construeix l’autòmata del patró invers: Suposem que el patró és ATGTATG

• I la cerca sobre el text : G T A C T A G A A T G T G T A G A C A T G T A T G G T GA T G T A T G

• Com fa la comparació?

GG AT T ATTA

G

A T G T A T G A T G T A T G

A T G T A T G

Page 33: Tècniques i Eines Bioinformàtiques

Autòmata Factor Oracle: exemple d’algorisme

• Es construeix l’autòmata del patró invers: Suposem que el patró és ATGTATG

• I la cerca sobre el text : G T A C T A G A A T G T G T A G A C A T G T A T G G T G ...A T G T A T G

• Com fa la comparació?

GG AT T ATTA

G

A T G T A T G A T G T A T G

A T G T A T G A T G T A T G

Page 34: Tècniques i Eines Bioinformàtiques

Autòmata Factor Oracle: exemple d’algorisme

• Es construeix l’autòmata del patró invers: Suposem que el patró és ATGTATG

• I la cerca sobre el text : G T A C T A G A A T G T G T A G A C A T G T A T G G T G ...A T G T A T G

• Com fa la comparació?

GG AT T ATTA

G

A T G T A T G A T G T A T G

A T G T A T G A T G T A T G

A T G T A T G