RNAlib-2.2.9

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

gquad.h
Go to the documentation of this file.
1 #ifndef VIENNA_RNA_PACKAGE_GQUAD_H
2 #define VIENNA_RNA_PACKAGE_GQUAD_H
3
4 #include <ViennaRNA/data_structures.h>
5 #include <ViennaRNA/params.h>
6
7 #ifndef INLINE
8 #ifdef __GNUC__
9 # define INLINE inline
10 #else
11 # define INLINE
12 #endif
13 #endif
14
25 int E_gquad(int L,
26 int l[3],
27 vrna_param_t *P);
28
29 FLT_OR_DBL exp_E_gquad( int L,
30 int l[3],
31 vrna_exp_param_t *pf);
32
33 int E_gquad_ali(int i,
34 int L,
35 int l[3],
36 const short **S,
37 int n_seq,
38 vrna_param_t *P);
39
40
41 void E_gquad_ali_en( int i,
42 int L,
43 int l[3],
44 const short **S,
45 int n_seq,
46 int en[2],
47 vrna_param_t *P);
48
65 int *get_gquad_matrix(short *S, vrna_param_t *P);
66
67 int *get_gquad_ali_matrix(short *S_cons,
68 short **S,
69 int n_seq,
70 vrna_param_t *P);
71
72 FLT_OR_DBL *get_gquad_pf_matrix( short *S,
73 FLT_OR_DBL *scale,
74 vrna_exp_param_t *pf);
75
76 int **get_gquad_L_matrix( short *S,
77 int start,
78 int maxdist,
79 int n,
80 int **g,
81 vrna_param_t *P);
82
83 void vrna_gquad_mx_local_update( vrna_fold_compound_t *vc,
84 int start);
85
86 void get_gquad_pattern_mfe(short *S,
87 int i,
88 int j,
89 vrna_param_t *P,
90 int *L,
91 int l[3]);
92
93 void
94 get_gquad_pattern_exhaustive( short *S,
95 int i,
96 int j,
97 vrna_param_t *P,
98 int *L,
99 int *l,
100 int threshold);
101
102 void get_gquad_pattern_pf( short *S,
103 int i,
104 int j,
105 vrna_exp_param_t *pf,
106 int *L,
107 int l[3]);
108
109 plist *get_plist_gquad_from_pr( short *S,
110 int gi,
111 int gj,
112 FLT_OR_DBL *G,
113 FLT_OR_DBL *probs,
114 FLT_OR_DBL *scale,
115 vrna_exp_param_t *pf);
116 plist *get_plist_gquad_from_pr_max(short *S,
117 int gi,
118 int gj,
119 FLT_OR_DBL *G,
120 FLT_OR_DBL *probs,
121 FLT_OR_DBL *scale,
122 int *L,
123 int l[3],
124 vrna_exp_param_t *pf);
125
126 plist *get_plist_gquad_from_db( const char *structure,
127 float pr);
128
129 int get_gquad_count(short *S,
130 int i,
131 int j);
132
133 int get_gquad_layer_count(short *S,
134 int i,
135 int j);
136
137
148 int parse_gquad(const char *struc, int *L, int l[3]);
149
150 INLINE PRIVATE int backtrack_GQuad_IntLoop(int c,
151 int i,
152 int j,
153 int type,
154 short *S,
155 int *ggg,
156 int *index,
157 int *p,
158 int *q,
159 vrna_param_t *P);
160
161 INLINE PRIVATE int backtrack_GQuad_IntLoop_L(int c,
162 int i,
163 int j,
164 int type,
165 short *S,
166 int **ggg,
167 int maxdist,
168 int *p,
169 int *q,
170 vrna_param_t *P);
171
172 PRIVATE INLINE int
173 vrna_BT_gquad_mfe(vrna_fold_compound_t *vc,
174 int i,
175 int j,
176 vrna_bp_stack_t *bp_stack,
177 int *stack_count);
178
179 PRIVATE INLINE int
180 vrna_BT_gquad_int(vrna_fold_compound_t *vc,
181 int i,
182 int j,
183 int en,
184 vrna_bp_stack_t *bp_stack,
185 int *stack_count);
186
187 PRIVATE INLINE int
188 vrna_BT_gquad_mfe(vrna_fold_compound_t *vc,
189 int i,
190 int j,
191 vrna_bp_stack_t *bp_stack,
192 int *stack_count){
193
194 /*
195 here we do some fancy stuff to backtrace the stacksize and linker lengths
196 of the g-quadruplex that should reside within position i,j
197 */
198 short *S;
199 int l[3], L, a;
200 vrna_param_t *P;
201
202 P = vc->params;
203 S = vc->sequence_encoding2;
204 L = -1;
205
206 get_gquad_pattern_mfe(S, i, j, P, &L, l);
207
208 if(L != -1){
209 /* fill the G's of the quadruplex into base_pair2 */
210 for(a=0;a<L;a++){
211 bp_stack[++(*stack_count)].i = i+a;
212 bp_stack[(*stack_count)].j = i+a;
213 bp_stack[++(*stack_count)].i = i+L+l[0]+a;
214 bp_stack[(*stack_count)].j = i+L+l[0]+a;
215 bp_stack[++(*stack_count)].i = i+L+l[0]+L+l[1]+a;
216 bp_stack[(*stack_count)].j = i+L+l[0]+L+l[1]+a;
217 bp_stack[++(*stack_count)].i = i+L+l[0]+L+l[1]+L+l[2]+a;
218 bp_stack[(*stack_count)].j = i+L+l[0]+L+l[1]+L+l[2]+a;
219 }
220 return 1;
221 } else {
222 return 0;
223 }
224 }
225
226 PRIVATE INLINE int
227 vrna_BT_gquad_int(vrna_fold_compound_t *vc,
228 int i,
229 int j,
230 int en,
231 vrna_bp_stack_t *bp_stack,
232 int *stack_count){
233
234 int energy, dangles, *idx, ij, p, q, maxl, minl, c0, l1, *rtype, *ggg;
235 unsigned char type;
236 char *ptype;
237 short si, sj, *S, *S1;
238
239 vrna_param_t *P;
240 vrna_md_t *md;
241
242 idx = vc->jindx;
243 ij = idx[j] + i;
244 P = vc->params;
245 md = &(P->model_details);
246 ptype = vc->ptype;
247 rtype = &(md->rtype[0]);
248 type = rtype[(unsigned char)ptype[ij]];
249 S1 = vc->sequence_encoding;
250 S = vc->sequence_encoding2;
251 dangles = md->dangles;
252 si = S1[i + 1];
253 sj = S1[j - 1];
254 ggg = vc->matrices->ggg;
255 energy = 0;
256
257 if(dangles == 2)
258 energy += P->mismatchI[type][si][sj];
259
260 if(type > 2)
261 energy += P->TerminalAU;
262
263 p = i + 1;
264 if(S1[p] == 3){
265 if(p < j - VRNA_GQUAD_MIN_BOX_SIZE){
266 minl = j - i + p - MAXLOOP - 2;
267 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
268 minl = MAX2(c0, minl);
269 c0 = j - 3;
270 maxl = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
271 maxl = MIN2(c0, maxl);
272 for(q = minl; q < maxl; q++){
273 if(S[q] != 3) continue;
274 if(en == energy + ggg[idx[q] + p] + P->internal_loop[j - q - 1]){
275 return vrna_BT_gquad_mfe(vc, p, q, bp_stack, stack_count);
276 }
277 }
278 }
279 }
280
281 for(p = i + 2;
282 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
283 p++){
284 l1 = p - i - 1;
285 if(l1>MAXLOOP) break;
286 if(S1[p] != 3) continue;
287 minl = j - i + p - MAXLOOP - 2;
288 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
289 minl = MAX2(c0, minl);
290 c0 = j - 1;
291 maxl = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
292 maxl = MIN2(c0, maxl);
293 for(q = minl; q < maxl; q++){
294 if(S1[q] != 3) continue;
295 if(en == energy + ggg[idx[q] + p] + P->internal_loop[l1 + j - q - 1]){
296 return vrna_BT_gquad_mfe(vc, p, q, bp_stack, stack_count);
297 }
298 }
299 }
300
301 q = j - 1;
302 if(S1[q] == 3)
303 for(p = i + 4;
304 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
305 p++){
306 l1 = p - i - 1;
307 if(l1>MAXLOOP) break;
308 if(S1[p] != 3) continue;
309 if(en == energy + ggg[idx[q] + p] + P->internal_loop[l1]){
310 return vrna_BT_gquad_mfe(vc, p, q, bp_stack, stack_count);
311 }
312 }
313
314 return 0;
315 }
316
334 INLINE PRIVATE int backtrack_GQuad_IntLoop(int c,
335 int i,
336 int j,
337 int type,
338 short *S,
339 int *ggg,
340 int *index,
341 int *p,
342 int *q,
343 vrna_param_t *P){
344
345 int energy, dangles, k, l, maxl, minl, c0, l1;
346 short si, sj;
347
348 dangles = P->model_details.dangles;
349 si = S[i + 1];
350 sj = S[j - 1];
351 energy = 0;
352
353 if(dangles == 2)
354 energy += P->mismatchI[type][si][sj];
355
356 if(type > 2)
357 energy += P->TerminalAU;
358
359 k = i + 1;
360 if(S[k] == 3){
361 if(k < j - VRNA_GQUAD_MIN_BOX_SIZE){
362 minl = j - i + k - MAXLOOP - 2;
363 c0 = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
364 minl = MAX2(c0, minl);
365 c0 = j - 3;
366 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
367 maxl = MIN2(c0, maxl);
368 for(l = minl; l < maxl; l++){
369 if(S[l] != 3) continue;
370 if(c == energy + ggg[index[l] + k] + P->internal_loop[j - l - 1]){
371 *p = k; *q = l;
372 return 1;
373 }
374 }
375 }
376 }
377
378 for(k = i + 2;
379 k < j - VRNA_GQUAD_MIN_BOX_SIZE;
380 k++){
381 l1 = k - i - 1;
382 if(l1>MAXLOOP) break;
383 if(S[k] != 3) continue;
384 minl = j - i + k - MAXLOOP - 2;
385 c0 = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
386 minl = MAX2(c0, minl);
387 c0 = j - 1;
388 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
389 maxl = MIN2(c0, maxl);
390 for(l = minl; l < maxl; l++){
391 if(S[l] != 3) continue;
392 if(c == energy + ggg[index[l] + k] + P->internal_loop[l1 + j - l - 1]){
393 *p = k; *q = l;
394 return 1;
395 }
396 }
397 }
398
399 l = j - 1;
400 if(S[l] == 3)
401 for(k = i + 4;
402 k < j - VRNA_GQUAD_MIN_BOX_SIZE;
403 k++){
404 l1 = k - i - 1;
405 if(l1>MAXLOOP) break;
406 if(S[k] != 3) continue;
407 if(c == energy + ggg[index[l] + k] + P->internal_loop[l1]){
408 *p = k; *q = l;
409 return 1;
410 }
411 }
412
413 return 0;
414 }
415
432 INLINE PRIVATE int backtrack_GQuad_IntLoop_L(int c,
433 int i,
434 int j,
435 int type,
436 short *S,
437 int **ggg,
438 int maxdist,
439 int *p,
440 int *q,
441 vrna_param_t *P){
442
443 int energy, dangles, k, l, maxl, minl, c0, l1;
444 short si, sj;
445
446 dangles = P->model_details.dangles;
447 si = S[i + 1];
448 sj = S[j - 1];
449 energy = 0;
450
451 if(dangles == 2)
452 energy += P->mismatchI[type][si][sj];
453
454 if(type > 2)
455 energy += P->TerminalAU;
456
457 k = i + 1;
458 if(S[k] == 3){
459 if(k < j - VRNA_GQUAD_MIN_BOX_SIZE){
460 minl = j - i + k - MAXLOOP - 2;
461 c0 = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
462 minl = MAX2(c0, minl);
463 c0 = j - 3;
464 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
465 maxl = MIN2(c0, maxl);
466 for(l = minl; l < maxl; l++){
467 if(S[l] != 3) continue;
468 if(c == energy + ggg[k][l - k] + P->internal_loop[j - l - 1]){
469 *p = k; *q = l;
470 return 1;
471 }
472 }
473 }
474 }
475
476 for(k = i + 2;
477 k < j - VRNA_GQUAD_MIN_BOX_SIZE;
478 k++){
479 l1 = k - i - 1;
480 if(l1>MAXLOOP) break;
481 if(S[k] != 3) continue;
482 minl = j - i + k - MAXLOOP - 2;
483 c0 = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
484 minl = MAX2(c0, minl);
485 c0 = j - 1;
486 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
487 maxl = MIN2(c0, maxl);
488 for(l = minl; l < maxl; l++){
489 if(S[l] != 3) continue;
490 if(c == energy + ggg[k][l - k] + P->internal_loop[l1 + j - l - 1]){
491 *p = k; *q = l;
492 return 1;
493 }
494 }
495 }
496
497 l = j - 1;
498 if(S[l] == 3)
499 for(k = i + 4;
500 k < j - VRNA_GQUAD_MIN_BOX_SIZE;
501 k++){
502 l1 = k - i - 1;
503 if(l1>MAXLOOP) break;
504 if(S[k] != 3) continue;
505 if(c == energy + ggg[k][l - k] + P->internal_loop[l1]){
506 *p = k; *q = l;
507 return 1;
508 }
509 }
510
511 return 0;
512 }
513
514 PRIVATE INLINE
515 int
516 E_GQuad_IntLoop(int i,
517 int j,
518 int type,
519 short *S,
520 int *ggg,
521 int *index,
522 vrna_param_t *P){
523
524 int energy, ge, dangles, p, q, l1, minq, maxq, c0;
525 short si, sj;
526
527 dangles = P->model_details.dangles;
528 si = S[i + 1];
529 sj = S[j - 1];
530 energy = 0;
531
532 if(dangles == 2)
533 energy += P->mismatchI[type][si][sj];
534
535 if(type > 2)
536 energy += P->TerminalAU;
537
538 ge = INF;
539
540 p = i + 1;
541 if(S[p] == 3){
542 if(p < j - VRNA_GQUAD_MIN_BOX_SIZE){
543 minq = j - i + p - MAXLOOP - 2;
544 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
545 minq = MAX2(c0, minq);
546 c0 = j - 3;
547 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
548 maxq = MIN2(c0, maxq);
549 for(q = minq; q < maxq; q++){
550 if(S[q] != 3) continue;
551 c0 = energy + ggg[index[q] + p] + P->internal_loop[j - q - 1];
552 ge = MIN2(ge, c0);
553 }
554 }
555 }
556
557 for(p = i + 2;
558 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
559 p++){
560 l1 = p - i - 1;
561 if(l1>MAXLOOP) break;
562 if(S[p] != 3) continue;
563 minq = j - i + p - MAXLOOP - 2;
564 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
565 minq = MAX2(c0, minq);
566 c0 = j - 1;
567 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
568 maxq = MIN2(c0, maxq);
569 for(q = minq; q < maxq; q++){
570 if(S[q] != 3) continue;
571 c0 = energy + ggg[index[q] + p] + P->internal_loop[l1 + j - q - 1];
572 ge = MIN2(ge, c0);
573 }
574 }
575
576 q = j - 1;
577 if(S[q] == 3)
578 for(p = i + 4;
579 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
580 p++){
581 l1 = p - i - 1;
582 if(l1>MAXLOOP) break;
583 if(S[p] != 3) continue;
584 c0 = energy + ggg[index[q] + p] + P->internal_loop[l1];
585 ge = MIN2(ge, c0);
586 }
587
588 #if 0
589 /* here comes the additional stuff for the odd dangle models */
590 if(dangles % 1){
591 en1 = energy + P->dangle5[type][si];
592 en2 = energy + P->dangle5[type][sj];
593 en3 = energy + P->mismatchI[type][si][sj];
594
595 /* first case with 5' dangle (i.e. j-1) onto enclosing pair */
596 p = i + 1;
597 if(S[p] == 3){
598 if(p < j - VRNA_GQUAD_MIN_BOX_SIZE){
599 minq = j - i + p - MAXLOOP - 2;
600 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
601 minq = MAX2(c0, minq);
602 c0 = j - 4;
603 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
604 maxq = MIN2(c0, maxq);
605 for(q = minq; q < maxq; q++){
606 if(S[q] != 3) continue;
607 c0 = en1 + ggg[index[q] + p] + P->internal_loop[j - q - 1];
608 ge = MIN2(ge, c0);
609 }
610 }
611 }
612
613 for(p = i + 2; p < j - VRNA_GQUAD_MIN_BOX_SIZE; p++){
614 l1 = p - i - 1;
615 if(l1>MAXLOOP) break;
616 if(S[p] != 3) continue;
617 minq = j - i + p - MAXLOOP - 2;
618 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
619 minq = MAX2(c0, minq);
620 c0 = j - 2;
621 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
622 maxq = MIN2(c0, maxq);
623 for(q = minq; q < maxq; q++){
624 if(S[q] != 3) continue;
625 c0 = en1 + ggg[index[q] + p] + P->internal_loop[l1 + j - q - 1];
626 ge = MIN2(ge, c0);
627 }
628 }
629
630 q = j - 2;
631 if(S[q] == 3)
632 for(p = i + 4; p < j - VRNA_GQUAD_MIN_BOX_SIZE; p++){
633 l1 = p - i - 1;
634 if(l1>MAXLOOP) break;
635 if(S[p] != 3) continue;
636 c0 = en1 + ggg[index[q] + p] + P->internal_loop[l1 + 1];
637 ge = MIN2(ge, c0);
638 }
639
640 /* second case with 3' dangle (i.e. i+1) onto enclosing pair */
641
642 }
643 #endif
644 return ge;
645 }
646
647 PRIVATE INLINE
648 int *
649 E_GQuad_IntLoop_exhaustive( int i,
650 int j,
651 int **p_p,
652 int **q_p,
653 int type,
654 short *S,
655 int *ggg,
656 int threshold,
657 int *index,
658 vrna_param_t *P){
659
660 int energy, *ge, dangles, p, q, l1, minq, maxq, c0;
661 short si, sj;
662 int cnt = 0;
663
664 dangles = P->model_details.dangles;
665 si = S[i + 1];
666 sj = S[j - 1];
667 energy = 0;
668
669 if(dangles == 2)
670 energy += P->mismatchI[type][si][sj];
671
672 if(type > 2)
673 energy += P->TerminalAU;
674
675 /* guess how many gquads are possible in interval [i+1,j-1] */
676 *p_p = (int *)vrna_alloc(sizeof(int) * 256);
677 *q_p = (int *)vrna_alloc(sizeof(int) * 256);
678 ge = (int *)vrna_alloc(sizeof(int) * 256);
679
680 p = i + 1;
681 if(S[p] == 3){
682 if(p < j - VRNA_GQUAD_MIN_BOX_SIZE){
683 minq = j - i + p - MAXLOOP - 2;
684 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
685 minq = MAX2(c0, minq);
686 c0 = j - 3;
687 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
688 maxq = MIN2(c0, maxq);
689 for(q = minq; q < maxq; q++){
690 if(S[q] != 3) continue;
691 c0 = energy + ggg[index[q] + p] + P->internal_loop[j - q - 1];
692 if(c0 <= threshold){
693 ge[cnt] = energy + P->internal_loop[j - q - 1];
694 (*p_p)[cnt] = p;
695 (*q_p)[cnt++] = q;
696 }
697 }
698 }
699 }
700
701 for(p = i + 2;
702 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
703 p++){
704 l1 = p - i - 1;
705 if(l1>MAXLOOP) break;
706 if(S[p] != 3) continue;
707 minq = j - i + p - MAXLOOP - 2;
708 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
709 minq = MAX2(c0, minq);
710 c0 = j - 1;
711 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
712 maxq = MIN2(c0, maxq);
713 for(q = minq; q < maxq; q++){
714 if(S[q] != 3) continue;
715 c0 = energy + ggg[index[q] + p] + P->internal_loop[l1 + j - q - 1];
716 if(c0 <= threshold){
717 ge[cnt] = energy + P->internal_loop[l1 + j - q - 1];
718 (*p_p)[cnt] = p;
719 (*q_p)[cnt++] = q;
720 }
721 }
722 }
723
724 q = j - 1;
725 if(S[q] == 3)
726 for(p = i + 4;
727 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
728 p++){
729 l1 = p - i - 1;
730 if(l1>MAXLOOP) break;
731 if(S[p] != 3) continue;
732 c0 = energy + ggg[index[q] + p] + P->internal_loop[l1];
733 if(c0 <= threshold){
734 ge[cnt] = energy + P->internal_loop[l1];
735 (*p_p)[cnt] = p;
736 (*q_p)[cnt++] = q;
737 }
738 }
739
740
741 (*p_p)[cnt] = -1;
742
743 return ge;
744 }
745
746 PRIVATE INLINE
747 int
748 E_GQuad_IntLoop_L(int i,
749 int j,
750 int type,
751 short *S,
752 int **ggg,
753 int maxdist,
754 vrna_param_t *P){
755
756 int energy, ge, dangles, p, q, l1, minq, maxq, c0;
757 short si, sj;
758
759 dangles = P->model_details.dangles;
760 si = S[i + 1];
761 sj = S[j - 1];
762 energy = 0;
763
764 if(dangles == 2)
765 energy += P->mismatchI[type][si][sj];
766
767 if(type > 2)
768 energy += P->TerminalAU;
769
770 ge = INF;
771
772 p = i + 1;
773 if(S[p] == 3){
774 if(p < j - VRNA_GQUAD_MIN_BOX_SIZE){
775 minq = j - i + p - MAXLOOP - 2;
776 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
777 minq = MAX2(c0, minq);
778 c0 = j - 3;
779 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
780 maxq = MIN2(c0, maxq);
781 for(q = minq; q < maxq; q++){
782 if(S[q] != 3) continue;
783 c0 = energy + ggg[p][q-p] + P->internal_loop[j - q - 1];
784 ge = MIN2(ge, c0);
785 }
786 }
787 }
788
789 for(p = i + 2;
790 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
791 p++){
792 l1 = p - i - 1;
793 if(l1>MAXLOOP) break;
794 if(S[p] != 3) continue;
795 minq = j - i + p - MAXLOOP - 2;
796 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
797 minq = MAX2(c0, minq);
798 c0 = j - 1;
799 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
800 maxq = MIN2(c0, maxq);
801 for(q = minq; q < maxq; q++){
802 if(S[q] != 3) continue;
803 c0 = energy + ggg[p][q - p] + P->internal_loop[l1 + j - q - 1];
804 ge = MIN2(ge, c0);
805 }
806 }
807
808 q = j - 1;
809 if(S[q] == 3)
810 for(p = i + 4;
811 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
812 p++){
813 l1 = p - i - 1;
814 if(l1>MAXLOOP) break;
815 if(S[p] != 3) continue;
816 c0 = energy + ggg[p][q - p] + P->internal_loop[l1];
817 ge = MIN2(ge, c0);
818 }
819
820 return ge;
821 }
822
823 PRIVATE INLINE
824 FLT_OR_DBL
825 exp_E_GQuad_IntLoop(int i,
826 int j,
827 int type,
828 short *S,
829 FLT_OR_DBL *G,
830 int *index,
831 vrna_exp_param_t *pf){
832
833 int k, l, minl, maxl, u, r;
834 FLT_OR_DBL q, qe;
835 double *expintern;
836 short si, sj;
837
838 q = 0;
839 si = S[i + 1];
840 sj = S[j - 1];
841 qe = (FLT_OR_DBL)pf->expmismatchI[type][si][sj];
842 expintern = pf->expinternal;
843
844 if(type > 2)
845 qe *= (FLT_OR_DBL)pf->expTermAU;
846
847 k = i + 1;
848 if(S[k] == 3){
849 if(k < j - VRNA_GQUAD_MIN_BOX_SIZE){
850 minl = j - i + k - MAXLOOP - 2;
851 u = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
852 minl = MAX2(u, minl);
853 u = j - 3;
854 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
855 maxl = MIN2(u, maxl);
856 for(l = minl; l < maxl; l++){
857 if(S[l] != 3) continue;
858 if(G[index[k]-l] == 0.) continue;
859 q += qe * G[index[k]-l] * (FLT_OR_DBL)expintern[j - l - 1];
860 }
861 }
862 }
863
864
865 for(k = i + 2;
866 k <= j - VRNA_GQUAD_MIN_BOX_SIZE;
867 k++){
868 u = k - i - 1;
869 if(u > MAXLOOP) break;
870 if(S[k] != 3) continue;
871 minl = j - i + k - MAXLOOP - 2;
872 r = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
873 minl = MAX2(r, minl);
874 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
875 r = j - 1;
876 maxl = MIN2(r, maxl);
877 for(l = minl; l < maxl; l++){
878 if(S[l] != 3) continue;
879 if(G[index[k]-l] == 0.) continue;
880 q += qe * G[index[k]-l] * (FLT_OR_DBL)expintern[u + j - l - 1];
881 }
882 }
883
884 l = j - 1;
885 if(S[l] == 3)
886 for(k = i + 4; k < j - VRNA_GQUAD_MIN_BOX_SIZE; k++){
887 u = k - i - 1;
888 if(u>MAXLOOP) break;
889 if(S[k] != 3) continue;
890 if(G[index[k]-l] == 0.) continue;
891 q += qe * G[index[k]-l] * (FLT_OR_DBL)expintern[u];
892 }
893
894 return q;
895 }
896
902 #endif
vrna_alloc
void * vrna_alloc(unsigned size)
Allocate space safely.
vrna_fc_s::ptype
char * ptype
Pair type array.
Definition: data_structures.h:494
vrna_fc_s::sequence_encoding
short * sequence_encoding
Numerical encoding of the input sequence.
Definition: data_structures.h:489
MAXLOOP
#define MAXLOOP
Definition: energy_const.h:28
vrna_param_s::model_details
vrna_md_t model_details
Model details to be used in the recursions.
Definition: params.h:88
FLT_OR_DBL
double FLT_OR_DBL
Typename for floating point number in partition function computations.
Definition: data_structures.h:39
vrna_fc_s
The most basic data structure required by many functions throughout the RNAlib.
Definition: data_structures.h:424
vrna_param_s
The datastructure that contains temperature scaled energy parameters.
Definition: params.h:50
vrna_fc_s::jindx
int * jindx
DP matrix accessor.
Definition: data_structures.h:451
backtrack_GQuad_IntLoop_L
PRIVATE int backtrack_GQuad_IntLoop_L(int c, int i, int j, int type, short *S, int **ggg, int maxdist, int *p, int *q, vrna_param_t *P)
Definition: gquad.h:432
data_structures.h
vrna_md_s::rtype
int rtype[8]
Reverse base pair type array.
Definition: model.h:241
vrna_md_s
The data structure that contains the complete model details used throughout the calculations.
Definition: model.h:188
INF
#define INF
Definition: energy_const.h:16
params.h
vrna_exp_param_s
The datastructure that contains temperature scaled Boltzmann weights of the energy parameters...
Definition: params.h:94
MAX2
#define MAX2(A, B)
Get the maximum of two comparable values.
Definition: utils.h:117
vrna_plist_s
this datastructure is used as input parameter in functions of PS_dot.h and others ...
Definition: data_structures.h:164
vrna_fc_s::params
vrna_param_t * params
The precomputed free energy contributions for each type of loop.
Definition: data_structures.h:447
vrna_fc_s::matrices
vrna_mx_mfe_t * matrices
The MFE DP matrices.
Definition: data_structures.h:444
get_gquad_matrix
int * get_gquad_matrix(short *S, vrna_param_t *P)
Get a triangular matrix prefilled with minimum free energy contributions of G-quadruplexes.
vrna_md_s::dangles
int dangles
Specifies the dangle model used in any energy evaluation (0,1,2 or 3)
Definition: model.h:191
vrna_bp_stack_s
Base pair stack element.
Definition: data_structures.h:192
pr
FLT_OR_DBL * pr
A pointer to the base pair probability matrix.
parse_gquad
int parse_gquad(const char *struc, int *L, int l[3])
backtrack_GQuad_IntLoop
PRIVATE int backtrack_GQuad_IntLoop(int c, int i, int j, int type, short *S, int *ggg, int *index, int *p, int *q, vrna_param_t *P)
Definition: gquad.h:334
MIN2
#define MIN2(A, B)
Get the minimum of two comparable values.
Definition: utils.h:112
dangles
int dangles
Switch the energy model for dangling end contributions (0, 1, 2, 3)
vrna_mx_mfe_s::ggg
int * ggg
Energies of g-quadruplexes.
Definition: dp_matrices.h:66