1 #ifndef VIENNA_RNA_PACKAGE_GQUAD_H 2 #define VIENNA_RNA_PACKAGE_GQUAD_H 37 int E_gquad_ali(
int i,
45 void E_gquad_ali_en(
int i,
71 int *get_gquad_ali_matrix(
short *S_cons,
80 int **get_gquad_L_matrix(
short *S,
90 void get_gquad_pattern_mfe(
short *S,
98 get_gquad_pattern_exhaustive(
short *S,
106 void get_gquad_pattern_pf(
short *S,
113 plist *get_plist_gquad_from_pr(
short *S,
120 plist *get_plist_gquad_from_pr_max(
short *S,
130 plist *get_plist_gquad_from_db(
const char *structure,
133 int get_gquad_count(
short *S,
137 int get_gquad_layer_count(
short *S,
152 int parse_gquad(
const char *struc,
int *L,
int l[3]);
207 S = vc->sequence_encoding2;
210 get_gquad_pattern_mfe(S, i, j, P, &L, l);
215 bp_stack[++(*stack_count)].i = i+a;
216 bp_stack[(*stack_count)].j = i+a;
217 bp_stack[++(*stack_count)].i = i+L+l[0]+a;
218 bp_stack[(*stack_count)].j = i+L+l[0]+a;
219 bp_stack[++(*stack_count)].i = i+L+l[0]+L+l[1]+a;
220 bp_stack[(*stack_count)].j = i+L+l[0]+L+l[1]+a;
221 bp_stack[++(*stack_count)].i = i+L+l[0]+L+l[1]+L+l[2]+a;
222 bp_stack[(*stack_count)].j = i+L+l[0]+L+l[1]+L+l[2]+a;
238 int energy,
dangles, *idx, ij, p, q, maxl, minl, c0, l1, *rtype, *ggg;
241 short si, sj, *S, *S1;
251 rtype = &(md->
rtype[0]);
252 type = rtype[(
unsigned char)ptype[ij]];
254 S = vc->sequence_encoding2;
262 energy += P->mismatchI[type][si][sj];
265 energy += P->TerminalAU;
269 if(p < j - VRNA_GQUAD_MIN_BOX_SIZE){
270 minl = j - i + p -
MAXLOOP - 2;
271 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
272 minl =
MAX2(c0, minl);
274 maxl = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
275 maxl =
MIN2(c0, maxl);
276 for(q = minl; q < maxl; q++){
277 if(S[q] != 3)
continue;
278 if(en == energy + ggg[idx[q] + p] + P->internal_loop[j - q - 1]){
279 return vrna_BT_gquad_mfe(vc, p, q, bp_stack, stack_count);
286 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
289 if(l1>MAXLOOP)
break;
290 if(S1[p] != 3)
continue;
291 minl = j - i + p - MAXLOOP - 2;
292 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
293 minl =
MAX2(c0, minl);
295 maxl = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
296 maxl =
MIN2(c0, maxl);
297 for(q = minl; q < maxl; q++){
298 if(S1[q] != 3)
continue;
299 if(en == energy + ggg[idx[q] + p] + P->internal_loop[l1 + j - q - 1]){
300 return vrna_BT_gquad_mfe(vc, p, q, bp_stack, stack_count);
308 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
311 if(l1>MAXLOOP)
break;
312 if(S1[p] != 3)
continue;
313 if(en == energy + ggg[idx[q] + p] + P->internal_loop[l1]){
314 return vrna_BT_gquad_mfe(vc, p, q, bp_stack, stack_count);
349 int energy,
dangles, k, l, maxl, minl, c0, l1;
358 energy += P->mismatchI[type][si][sj];
361 energy += P->TerminalAU;
365 if(k < j - VRNA_GQUAD_MIN_BOX_SIZE){
366 minl = j - i + k - MAXLOOP - 2;
367 c0 = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
368 minl =
MAX2(c0, minl);
370 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
371 maxl =
MIN2(c0, maxl);
372 for(l = minl; l < maxl; l++){
373 if(S[l] != 3)
continue;
374 if(c == energy + ggg[index[l] + k] + P->internal_loop[j - l - 1]){
383 k < j - VRNA_GQUAD_MIN_BOX_SIZE;
386 if(l1>MAXLOOP)
break;
387 if(S[k] != 3)
continue;
388 minl = j - i + k - MAXLOOP - 2;
389 c0 = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
390 minl =
MAX2(c0, minl);
392 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
393 maxl =
MIN2(c0, maxl);
394 for(l = minl; l < maxl; l++){
395 if(S[l] != 3)
continue;
396 if(c == energy + ggg[index[l] + k] + P->internal_loop[l1 + j - l - 1]){
406 k < j - VRNA_GQUAD_MIN_BOX_SIZE;
409 if(l1>MAXLOOP)
break;
410 if(S[k] != 3)
continue;
411 if(c == energy + ggg[index[l] + k] + P->internal_loop[l1]){
447 int energy,
dangles, k, l, maxl, minl, c0, l1;
456 energy += P->mismatchI[type][si][sj];
459 energy += P->TerminalAU;
463 if(k < j - VRNA_GQUAD_MIN_BOX_SIZE){
464 minl = j - i + k - MAXLOOP - 2;
465 c0 = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
466 minl =
MAX2(c0, minl);
468 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
469 maxl =
MIN2(c0, maxl);
470 for(l = minl; l < maxl; l++){
471 if(S[l] != 3)
continue;
472 if(c == energy + ggg[k][l - k] + P->internal_loop[j - l - 1]){
481 k < j - VRNA_GQUAD_MIN_BOX_SIZE;
484 if(l1>MAXLOOP)
break;
485 if(S[k] != 3)
continue;
486 minl = j - i + k - MAXLOOP - 2;
487 c0 = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
488 minl =
MAX2(c0, minl);
490 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
491 maxl =
MIN2(c0, maxl);
492 for(l = minl; l < maxl; l++){
493 if(S[l] != 3)
continue;
494 if(c == energy + ggg[k][l - k] + P->internal_loop[l1 + j - l - 1]){
504 k < j - VRNA_GQUAD_MIN_BOX_SIZE;
507 if(l1>MAXLOOP)
break;
508 if(S[k] != 3)
continue;
509 if(c == energy + ggg[k][l - k] + P->internal_loop[l1]){
520 E_GQuad_IntLoop(
int i,
528 int energy, ge,
dangles, p, q, l1, minq, maxq, c0;
537 energy += P->mismatchI[type][si][sj];
540 energy += P->TerminalAU;
546 if(p < j - VRNA_GQUAD_MIN_BOX_SIZE){
547 minq = j - i + p - MAXLOOP - 2;
548 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
549 minq =
MAX2(c0, minq);
551 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
552 maxq =
MIN2(c0, maxq);
553 for(q = minq; q < maxq; q++){
554 if(S[q] != 3)
continue;
555 c0 = energy + ggg[index[q] + p] + P->internal_loop[j - q - 1];
562 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
565 if(l1>MAXLOOP)
break;
566 if(S[p] != 3)
continue;
567 minq = j - i + p - MAXLOOP - 2;
568 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
569 minq =
MAX2(c0, minq);
571 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
572 maxq =
MIN2(c0, maxq);
573 for(q = minq; q < maxq; q++){
574 if(S[q] != 3)
continue;
575 c0 = energy + ggg[index[q] + p] + P->internal_loop[l1 + j - q - 1];
583 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
586 if(l1>MAXLOOP)
break;
587 if(S[p] != 3)
continue;
588 c0 = energy + ggg[index[q] + p] + P->internal_loop[l1];
595 en1 = energy + P->dangle5[type][si];
596 en2 = energy + P->dangle5[type][sj];
597 en3 = energy + P->mismatchI[type][si][sj];
602 if(p < j - VRNA_GQUAD_MIN_BOX_SIZE){
603 minq = j - i + p - MAXLOOP - 2;
604 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
605 minq =
MAX2(c0, minq);
607 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
608 maxq =
MIN2(c0, maxq);
609 for(q = minq; q < maxq; q++){
610 if(S[q] != 3)
continue;
611 c0 = en1 + ggg[index[q] + p] + P->internal_loop[j - q - 1];
617 for(p = i + 2; p < j - VRNA_GQUAD_MIN_BOX_SIZE; p++){
619 if(l1>MAXLOOP)
break;
620 if(S[p] != 3)
continue;
621 minq = j - i + p - MAXLOOP - 2;
622 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
623 minq =
MAX2(c0, minq);
625 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
626 maxq =
MIN2(c0, maxq);
627 for(q = minq; q < maxq; q++){
628 if(S[q] != 3)
continue;
629 c0 = en1 + ggg[index[q] + p] + P->internal_loop[l1 + j - q - 1];
636 for(p = i + 4; p < j - VRNA_GQUAD_MIN_BOX_SIZE; p++){
638 if(l1>MAXLOOP)
break;
639 if(S[p] != 3)
continue;
640 c0 = en1 + ggg[index[q] + p] + P->internal_loop[l1 + 1];
653 E_GQuad_IntLoop_exhaustive(
int i,
664 int energy, *ge,
dangles, p, q, l1, minq, maxq, c0;
674 energy += P->mismatchI[type][si][sj];
677 energy += P->TerminalAU;
686 if(p < j - VRNA_GQUAD_MIN_BOX_SIZE){
687 minq = j - i + p - MAXLOOP - 2;
688 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
689 minq =
MAX2(c0, minq);
691 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
692 maxq =
MIN2(c0, maxq);
693 for(q = minq; q < maxq; q++){
694 if(S[q] != 3)
continue;
695 c0 = energy + ggg[index[q] + p] + P->internal_loop[j - q - 1];
697 ge[cnt] = energy + P->internal_loop[j - q - 1];
706 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
709 if(l1>MAXLOOP)
break;
710 if(S[p] != 3)
continue;
711 minq = j - i + p - MAXLOOP - 2;
712 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
713 minq =
MAX2(c0, minq);
715 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
716 maxq =
MIN2(c0, maxq);
717 for(q = minq; q < maxq; q++){
718 if(S[q] != 3)
continue;
719 c0 = energy + ggg[index[q] + p] + P->internal_loop[l1 + j - q - 1];
721 ge[cnt] = energy + P->internal_loop[l1 + j - q - 1];
731 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
734 if(l1>MAXLOOP)
break;
735 if(S[p] != 3)
continue;
736 c0 = energy + ggg[index[q] + p] + P->internal_loop[l1];
738 ge[cnt] = energy + P->internal_loop[l1];
752 E_GQuad_IntLoop_L(
int i,
760 int energy, ge,
dangles, p, q, l1, minq, maxq, c0;
769 energy += P->mismatchI[type][si][sj];
772 energy += P->TerminalAU;
778 if(p < j - VRNA_GQUAD_MIN_BOX_SIZE){
779 minq = j - i + p - MAXLOOP - 2;
780 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
781 minq =
MAX2(c0, minq);
783 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
784 maxq =
MIN2(c0, maxq);
785 for(q = minq; q < maxq; q++){
786 if(S[q] != 3)
continue;
787 c0 = energy + ggg[p][q-p] + P->internal_loop[j - q - 1];
794 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
797 if(l1>MAXLOOP)
break;
798 if(S[p] != 3)
continue;
799 minq = j - i + p - MAXLOOP - 2;
800 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
801 minq =
MAX2(c0, minq);
803 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
804 maxq =
MIN2(c0, maxq);
805 for(q = minq; q < maxq; q++){
806 if(S[q] != 3)
continue;
807 c0 = energy + ggg[p][q - p] + P->internal_loop[l1 + j - q - 1];
815 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
818 if(l1>MAXLOOP)
break;
819 if(S[p] != 3)
continue;
820 c0 = energy + ggg[p][q - p] + P->internal_loop[l1];
829 exp_E_GQuad_IntLoop(
int i,
837 int k, l, minl, maxl, u, r;
845 qe = (
FLT_OR_DBL)pf->expmismatchI[type][si][sj];
846 expintern = pf->expinternal;
853 if(k < j - VRNA_GQUAD_MIN_BOX_SIZE){
854 minl = j - i + k - MAXLOOP - 2;
855 u = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
856 minl =
MAX2(u, minl);
858 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
859 maxl =
MIN2(u, maxl);
860 for(l = minl; l < maxl; l++){
861 if(S[l] != 3)
continue;
862 if(G[index[k]-l] == 0.)
continue;
863 q += qe * G[index[k]-l] * (
FLT_OR_DBL)expintern[j - l - 1];
870 k <= j - VRNA_GQUAD_MIN_BOX_SIZE;
873 if(u > MAXLOOP)
break;
874 if(S[k] != 3)
continue;
875 minl = j - i + k - MAXLOOP - 2;
876 r = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
877 minl =
MAX2(r, minl);
878 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
880 maxl =
MIN2(r, maxl);
881 for(l = minl; l < maxl; l++){
882 if(S[l] != 3)
continue;
883 if(G[index[k]-l] == 0.)
continue;
884 q += qe * G[index[k]-l] * (
FLT_OR_DBL)expintern[u + j - l - 1];
890 for(k = i + 4; k < j - VRNA_GQUAD_MIN_BOX_SIZE; k++){
893 if(S[k] != 3)
continue;
894 if(G[index[k]-l] == 0.)
continue;
895 q += qe * G[index[k]-l] * (
FLT_OR_DBL)expintern[u];
void * vrna_alloc(unsigned size)
Allocate space safely.
char * ptype
Pair type array.
Definition: data_structures.h:540
short * sequence_encoding
Numerical encoding of the input sequence.
Definition: data_structures.h:535
int dangles
Specifies the dangle model used in any energy evaluation (0,1,2 or 3)
Definition: model.h:194
#define MAXLOOP
Definition: energy_const.h:29
vrna_md_t model_details
Model details to be used in the recursions.
Definition: params.h:93
double FLT_OR_DBL
Typename for floating point number in partition function computations.
Definition: data_structures.h:48
The most basic data structure required by many functions throughout the RNAlib.
Definition: data_structures.h:454
The datastructure that contains temperature scaled energy parameters.
Definition: params.h:55
int parse_gquad(const char *struc, int *L, int l[3])
int * jindx
DP matrix accessor.
Definition: data_structures.h:481
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:338
Various data structures and pre-processor macros.
#define INF
Definition: energy_const.h:17
Functions to deal with sets of energy parameters.
The data structure that contains temperature scaled Boltzmann weights of the energy parameters...
Definition: params.h:99
The data structure that contains the complete model details used throughout the calculations.
Definition: model.h:191
#define MAX2(A, B)
Get the maximum of two comparable values.
Definition: utils.h:120
this datastructure is used as input parameter in functions of PS_dot.h and others ...
Definition: data_structures.h:182
vrna_param_t * params
The precomputed free energy contributions for each type of loop.
Definition: data_structures.h:477
vrna_mx_mfe_t * matrices
The MFE DP matrices.
Definition: data_structures.h:474
Base pair stack element.
Definition: data_structures.h:222
FLT_OR_DBL * pr
A pointer to the base pair probability matrix.
#define MIN2(A, B)
Get the minimum of two comparable values.
Definition: utils.h:115
int rtype[8]
Reverse base pair type array.
Definition: model.h:244
int dangles
Switch the energy model for dangling end contributions (0, 1, 2, 3)
int * get_gquad_matrix(short *S, vrna_param_t *P)
Get a triangular matrix prefilled with minimum free energy contributions of G-quadruplexes.
int * ggg
Energies of g-quadruplexes.
Definition: dp_matrices.h:72
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:436