6.5 RNA Secondary Structure 18 novembre 2014
Calendario Oggi è la lezione 17/24: ultima lezione su Programmazione dinamica Metodo greedy: 18, 19 Grafi: 20, 21, 22, 23 Reti di flusso: 23, 24 (=mercoledì 10 dicembre) Martedì 16 dicembre: Esercizi Mercoledì 17 dicembre: Esercizi, 3 test
Struttura di una biomolecola Biomolecola: DNA, RNA Struttura primaria: descrizione esatta della sua composizione atomica e dei legami presenti fra gli atomi Struttura secondaria: capacità di assumere una struttura spaziale regolare e ripetitiva
DNA Struttura secondaria: doppia elica (Watson e Crick). Ogni catena è composta da nucleotidi: A, C, G, T A (adenina), C (citosina), G (guanina), T (timina) Le catene sono connesse da basi complementari: A-T, C-G
Per una stessa stringa di RNA possono esistere più strutture secondarie
Two views of RNA secondary structure
RNA Secondary Structure: Examples Examples. C G G U G G G C G G U C G C G C U A U A U A G U A U A U A base pair A U G U G G C C A U A U G G G G C A U A G U U G G C C A U 4 ok sharp turn: no! crossing: no! 8
Un generico esempio C G A A U G U G G C C A U A U G G G G C A U G G A U G G G G C A U
RNA Secondary Structure Secondary structure. A set of pairs S = { (b i, b j ) } that satisfy: [Watson-Crick.] S is a matching and each pair in S is a Watson-Crick complement: A-U, U-A, C-G, or G-C. [No sharp turns.] The ends of each pair are separated by at least 4 intervening bases. If (b i, b j ) S, then i < j - 4. [Non-crossing.] If (b i, b j ) and (b k, b l ) are two pairs in S, then we cannot have i < k < j < l. Free energy. Usual hypothesis is that an RNA molecule will form the secondary structure with the optimum total free energy. approximate by number of base pairs Goal. Given an RNA molecule B = b 1 b 2 b n, find a secondary structure S that maximizes the number of base pairs. 10
RNA Secondary Structure: Subproblems First attempt. OPT(j) = maximum number of base pairs in a secondary structure of the substring b 1 b 2 b j. Case 1: b j is not involved in a pair : OPT(j)=OPT(j-1) Case 2: b j matches b t for some 1 t<j-4 1 t j Difficulty. Results in two sub-problems: Finding secondary structure in: b 1 b 2 b t-1. Finding secondary structure in: b t+1 b t+2 b j-1. OPT(t-1) need different sub-problems 11
Dynamic Programming Over Intervals Notation. OPT(i, j) = maximum number of base pairs in a secondary structure of the substring b i b i+1 b j. Case 1. If i j - 4. OPT(i, j) = 0 by no-sharp turns condition. Case 2. Base b j is not involved in a pair. OPT(i, j) = OPT(i, j-1) Case 3. Base b j pairs with b t for some i t < j - 4. non-crossing constraint (no match over t) decouples resulting sub-problems OPT(i, j) = 1 + max t { OPT(i, t-1) + OPT(t+1, j-1) } take max over t such that i t < j-4 and b t and b j are Watson-Crick complements 12 i t-1 t t+1 j-1 j
Dynamic Programming Over Intervals Notation. OPT(i, j) = maximum number of base pairs in a secondary structure of the substring b i b i+1 b j. Case 1. If i j - 4. OPT(i, j) = 0 by no-sharp turns condition. Case 2. Base b j is not involved in a pair. OPT(i, j) = OPT(i, j-1) Case 3. Base b j pairs with b t for some i t < j - 4. non-crossing constraint (no match over t) decouples resulting sub-problems OPT(i, j) = 1 + max t { OPT(i, t-1) + OPT(t+1, j-1) } i t-1 t t+1 j-1 j Proprietà della sottostruttura ottima: Caso 3: una soluzione ottima O per b i b i+1 b j è formata dalla coppia b t - b j più un insieme L di coppie scelte da b i b t-1 e un insieme R di coppie scelte da b t+1 b j. Inoltre L è una struttura secondaria (Watson-Crick, no-sharp, non-crossing) ed è ottima (massima cardinalità) per b i b t-1, altrimenti potrei sostituirne una migliore di L in O, ottenendo una soluzione per b i b i+1 b j migliore di O: assurdo! Analogo per R. 13
Relazione di ricorrenza OPT(i, j) = maximum number of base pairs in a secondary structure of the substring b i b i+1 b j with i, j = 1, 2,, n Caso generale: i< j 4 ovvero i j-5, ovvero j i+5 i = 1 allora j 6 i = 2 allora j 7 i = n-5 allora j n i = n-4 allora j n+1 i = n allora j n+5 n = 9 allora i 9-5=4, j 6 4 0 0 0 3 0 0 i 2 0 1 6 7 8 9 j
Bottom Up Dynamic Programming Over Intervals Q. What order to solve the sub-problems? A. Do shortest intervals first (from length 5 up to n-1). RNA(b 1,,b n ) { for k = 5, 6,, n-1 for i = 1, 2,, n-k j = i + k Compute M[i, j] } return M[1, n] using recurrence i n=9, 4=n-5 4 0 0 0 3 0 0 2 0 1 6 7 8 9 j j = i+5, i = 1,, n-5 j = i+6, i = 1,, n-6 j = i+7, i = 1,., n-7 j = i+k, i = 1,, n-k j = n, i = 1 Running time. O(n 3 ). k = 5, 6,, n-1 15
Esempio
b 4 =G does not match b 9 =U b 2 =C does not match b 7 =A
0 1,8) ( 1) (3, 1 max 1 (3,8) max (3,9)., 5 3 9 t OPT t OPT OPT OPT compl b U b t t 0 1,6) ( 1) (1, 1 max 1 (1,6) max (1,7)., 3 1 7 t OPT t OPT OPT OPT compl A b b t t 1 1,7) ( 1) (2, 1 max 0 (2,7) max (2,8)., 4 2 8 t OPT t OPT OPT OPT compl G b b t t
oppure A C C G G U A G U
Dynamic Programming Summary Recipe. Characterize structure of problem. Recursively define value of optimal solution. Compute value of optimal solution. Construct optimal solution from computed information. Dynamic programming techniques. Binary choice: weighted interval scheduling. Multi-way choice: esercizio della canoa. Adding a new variable: knapsack. Dynamic programming over intervals: RNA secondary structure. Top-down vs. bottom-up: different people have different intuitions. 23
Tale proprietà è detta: Proprietà della Sottostruttura Ottima.
Proprietà della sottostruttura ottima: Scheduling di attività pesate Il punto cruciale qui è che O {n} : è una soluzione, cioè è un insieme di attività compatibili di {1,, p(n)} (perché le attività di O sono compatibili) è ottima, cioè ha cardinalità massima fra le soluzioni al sottoproblema relativo alle attività {1,, p(n)} (infatti, se così non fosse, esisterebbe una soluzione O per {1,, p(n)} di cardinalità strettamente superiore a quella di O {n} e allora O {n} sarebbe una soluzione strettamente migliore di O.
Proprietà della sottostruttura ottima: Sequence Alignment 1 OPT(i, j) = min cost of aligning strings x 1 x 2... x i and y 1 y 2... y j OPT è un allineamento ottimale per x 1 x 2... x i and y 1 y 2... y j. Case 1: OPT matches x i -y j. pay mismatch for x i -y j + min cost of aligning two strings x 1 x 2... x i-1 and y 1 y 2... y j-1 Quindi OPT= { x i -y j } X, con X insieme di coppie ordinate Il punto cruciale qui è che X : è una soluzione, cioè è un allineamento per x 1 x 2... x i-1 e y 1 y 2... y j-1 (perché OPT lo è, quindi le posizioni non si incrociano etc.) è ottima, cioè ha costo minimo fra le soluzioni al sottoproblema per x 1 x 2... x i-1 e y 1 y 2... y j-1 (infatti, se così non fosse, esisterebbe una soluzione OPT per x 1 x 2... x i-1 e y 1 y 2... y j-1 di cardinalità strettamente superiore a quella di X e allora OPT ( i, j) OPT ( i 1, j 1) migliore 26 di OPT). x i y OPT {x i -y j } sarebbe una soluzione per x 1 x 2... x i and y 1 y 2... y j strettamente j
Proprietà della sottostruttura ottima: Sequence Alignment 2 OPT(i, j) = min cost of aligning strings x 1 x 2... x i and y 1 y 2... y j. Case 2a: OPT leaves x i unmatched. pay gap for x i and min cost of aligning x 1 x 2... x i-1 and y 1 y 2... y j Case 2b: OPT leaves y j unmatched. pay gap for y j and min cost of aligning x 1 x 2... x i and y 1 y 2... y j-1 In maniera analoga 27
Esercizi: varianti al problema dello zaino
Dall elenco
Dall elenco