1 #ifndef VIENNA_RNA_PACKAGE_GQUAD_H 2 #define VIENNA_RNA_PACKAGE_GQUAD_H 39 int E_gquad_ali(
int i,
47 void E_gquad_ali_en(
int i,
76 int *get_gquad_ali_matrix(
short *S_cons,
87 int **get_gquad_L_matrix(
short *S,
99 void get_gquad_pattern_mfe(
short *S,
108 get_gquad_pattern_exhaustive(
short *S,
117 void get_gquad_pattern_pf(
short *S,
125 plist *get_plist_gquad_from_pr(
short *S,
134 plist *get_plist_gquad_from_pr_max(
short *S,
145 plist *get_plist_gquad_from_db(
const char *structure,
149 int get_gquad_count(
short *S,
154 int get_gquad_layer_count(
short *S,
159 void get_gquad_pattern_mfe_ali(
short **S,
196 INLINE PRIVATE
int backtrack_GQuad_IntLoop_comparative(
int c,
244 int l[3], L, a, n_seq;
251 S = vc->sequence_encoding2;
254 get_gquad_pattern_mfe(S, i, j, P, &L, l);
260 get_gquad_pattern_mfe_ali(vc->
S, vc->
S_cons, n_seq, i, j, P, &L, l);
266 for (a = 0; a < L; a++) {
267 bp_stack[++(*stack_count)].i = i + a;
268 bp_stack[(*stack_count)].j = i + a;
269 bp_stack[++(*stack_count)].i = i + L + l[0] + a;
270 bp_stack[(*stack_count)].j = i + L + l[0] + a;
271 bp_stack[++(*stack_count)].i = i + L + l[0] + L + l[1] + a;
272 bp_stack[(*stack_count)].j = i + L + l[0] + L + l[1] + a;
273 bp_stack[++(*stack_count)].i = i + L + l[0] + L + l[1] + L + l[2] + a;
274 bp_stack[(*stack_count)].j = i + L + l[0] + L + l[1] + L + l[2] + a;
294 int energy,
dangles, *idx, ij, p, q, maxl, minl, c0, l1, *ggg;
297 short si, sj, *S, *S1;
307 type = (
unsigned char)ptype[ij];
309 S = vc->sequence_encoding2;
317 energy += P->mismatchI[type][si][sj];
320 energy += P->TerminalAU;
324 if (p < j - VRNA_GQUAD_MIN_BOX_SIZE) {
325 minl = j - i + p -
MAXLOOP - 2;
326 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
327 minl =
MAX2(c0, minl);
329 maxl = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
330 maxl =
MIN2(c0, maxl);
331 for (q = minl; q < maxl; q++) {
335 if (en == energy + ggg[idx[q] + p] + P->internal_loop[j - q - 1])
336 return vrna_BT_gquad_mfe(vc, p, q, bp_stack, stack_count);
342 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
351 minl = j - i + p -
MAXLOOP - 2;
352 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
353 minl =
MAX2(c0, minl);
355 maxl = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
356 maxl =
MIN2(c0, maxl);
357 for (q = minl; q < maxl; q++) {
361 if (en == energy + ggg[idx[q] + p] + P->internal_loop[l1 + j - q - 1])
362 return vrna_BT_gquad_mfe(vc, p, q, bp_stack, stack_count);
369 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
378 if (en == energy + ggg[idx[q] + p] + P->internal_loop[l1])
379 return vrna_BT_gquad_mfe(vc, p, q, bp_stack, stack_count);
415 int energy,
dangles, k, l, maxl, minl, c0, l1;
424 energy += P->mismatchI[type][si][sj];
427 energy += P->TerminalAU;
431 if (k < j - VRNA_GQUAD_MIN_BOX_SIZE) {
432 minl = j - i + k -
MAXLOOP - 2;
433 c0 = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
434 minl =
MAX2(c0, minl);
436 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
437 maxl =
MIN2(c0, maxl);
438 for (l = minl; l < maxl; l++) {
442 if (c == energy + ggg[index[l] + k] + P->internal_loop[j - l - 1]) {
452 k < j - VRNA_GQUAD_MIN_BOX_SIZE;
461 minl = j - i + k -
MAXLOOP - 2;
462 c0 = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
463 minl =
MAX2(c0, minl);
465 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
466 maxl =
MIN2(c0, maxl);
467 for (l = minl; l < maxl; l++) {
471 if (c == energy + ggg[index[l] + k] + P->internal_loop[l1 + j - l - 1]) {
482 k < j - VRNA_GQUAD_MIN_BOX_SIZE;
491 if (c == energy + ggg[index[l] + k] + P->internal_loop[l1]) {
503 backtrack_GQuad_IntLoop_comparative(
int c,
517 int energy,
dangles, k, l, maxl, minl, c0, l1, ss, tt;
522 for (ss = 0; ss < n_seq; ss++) {
528 energy += P->mismatchI[tt][S3[ss][i]][S5[ss][j]];
531 energy += P->TerminalAU;
535 if (S_cons[k] == 3) {
536 if (k < j - VRNA_GQUAD_MIN_BOX_SIZE) {
537 minl = j - i + k -
MAXLOOP - 2;
538 c0 = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
539 minl =
MAX2(c0, minl);
541 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
542 maxl =
MIN2(c0, maxl);
543 for (l = minl; l < maxl; l++) {
547 if (c == energy + ggg[index[l] + k] + n_seq * P->internal_loop[j - l - 1]) {
557 k < j - VRNA_GQUAD_MIN_BOX_SIZE;
566 minl = j - i + k -
MAXLOOP - 2;
567 c0 = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
568 minl =
MAX2(c0, minl);
570 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
571 maxl =
MIN2(c0, maxl);
572 for (l = minl; l < maxl; l++) {
576 if (c == energy + ggg[index[l] + k] + n_seq * P->internal_loop[l1 + j - l - 1]) {
587 k < j - VRNA_GQUAD_MIN_BOX_SIZE;
596 if (c == energy + ggg[index[l] + k] + n_seq * P->internal_loop[l1]) {
635 int energy,
dangles, k, l, maxl, minl, c0, l1;
644 energy += P->mismatchI[type][si][sj];
647 energy += P->TerminalAU;
651 if (k < j - VRNA_GQUAD_MIN_BOX_SIZE) {
652 minl = j - i + k -
MAXLOOP - 2;
653 c0 = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
654 minl =
MAX2(c0, minl);
656 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
657 maxl =
MIN2(c0, maxl);
658 for (l = minl; l < maxl; l++) {
662 if (c == energy + ggg[k][l - k] + P->internal_loop[j - l - 1]) {
672 k < j - VRNA_GQUAD_MIN_BOX_SIZE;
681 minl = j - i + k -
MAXLOOP - 2;
682 c0 = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
683 minl =
MAX2(c0, minl);
685 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
686 maxl =
MIN2(c0, maxl);
687 for (l = minl; l < maxl; l++) {
691 if (c == energy + ggg[k][l - k] + P->internal_loop[l1 + j - l - 1]) {
702 k < j - VRNA_GQUAD_MIN_BOX_SIZE;
711 if (c == energy + ggg[k][l - k] + P->internal_loop[l1]) {
723 backtrack_GQuad_IntLoop_L_comparative(
int c,
742 int mm, dangle_model, k, l, maxl, minl, c0, l1, ss, tt;
747 for (ss = 0; ss < n_seq; ss++) {
750 if (dangle_model == 2)
751 mm += P->mismatchI[tt][S3[ss][i]][S5[ss][j]];
758 k < j - VRNA_GQUAD_MIN_BOX_SIZE;
767 minl = j - i + k -
MAXLOOP - 2;
768 c0 = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
769 minl =
MAX2(c0, minl);
771 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
772 maxl =
MIN2(c0, maxl);
773 for (l = minl; l < maxl; l++) {
777 c0 = mm + ggg[k][l - k] + n_seq * P->internal_loop[l1 + j - l - 1];
786 if (S_cons[k] == 3) {
787 if (k < j - VRNA_GQUAD_MIN_BOX_SIZE) {
788 minl = j - i + k -
MAXLOOP - 2;
789 c0 = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
790 minl =
MAX2(c0, minl);
792 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
793 maxl =
MIN2(c0, maxl);
794 for (l = minl; l < maxl; l++) {
798 if (c == mm + ggg[k][l - k] + n_seq * P->internal_loop[j - l - 1]) {
808 if (S_cons[l] == 3) {
809 for (k = i + 4; k < j - VRNA_GQUAD_MIN_BOX_SIZE; k++) {
817 if (c == mm + ggg[k][l - k] + n_seq * P->internal_loop[l1]) {
831 E_GQuad_IntLoop(
int i,
839 int energy, ge,
dangles, p, q, l1, minq, maxq, c0;
848 energy += P->mismatchI[type][si][sj];
851 energy += P->TerminalAU;
857 if (p < j - VRNA_GQUAD_MIN_BOX_SIZE) {
858 minq = j - i + p -
MAXLOOP - 2;
859 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
860 minq =
MAX2(c0, minq);
862 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
863 maxq =
MIN2(c0, maxq);
864 for (q = minq; q < maxq; q++) {
868 c0 = energy + ggg[index[q] + p] + P->internal_loop[j - q - 1];
875 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
884 minq = j - i + p -
MAXLOOP - 2;
885 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
886 minq =
MAX2(c0, minq);
888 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
889 maxq =
MIN2(c0, maxq);
890 for (q = minq; q < maxq; q++) {
894 c0 = energy + ggg[index[q] + p] + P->internal_loop[l1 + j - q - 1];
902 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
911 c0 = energy + ggg[index[q] + p] + P->internal_loop[l1];
918 en1 = energy + P->dangle5[type][si];
919 en2 = energy + P->dangle5[type][sj];
920 en3 = energy + P->mismatchI[type][si][sj];
925 if (p < j - VRNA_GQUAD_MIN_BOX_SIZE) {
926 minq = j - i + p -
MAXLOOP - 2;
927 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
928 minq =
MAX2(c0, minq);
930 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
931 maxq =
MIN2(c0, maxq);
932 for (q = minq; q < maxq; q++) {
936 c0 = en1 + ggg[index[q] + p] + P->internal_loop[j - q - 1];
942 for (p = i + 2; p < j - VRNA_GQUAD_MIN_BOX_SIZE; p++) {
950 minq = j - i + p -
MAXLOOP - 2;
951 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
952 minq =
MAX2(c0, minq);
954 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
955 maxq =
MIN2(c0, maxq);
956 for (q = minq; q < maxq; q++) {
960 c0 = en1 + ggg[index[q] + p] + P->internal_loop[l1 + j - q - 1];
967 for (p = i + 4; p < j - VRNA_GQUAD_MIN_BOX_SIZE; p++) {
975 c0 = en1 + ggg[index[q] + p] + P->internal_loop[l1 + 1];
989 E_GQuad_IntLoop_exhaustive(
int i,
1000 int energy, *ge,
dangles, p, q, l1, minq, maxq, c0;
1010 energy += P->mismatchI[type][si][sj];
1013 energy += P->TerminalAU;
1022 if (p < j - VRNA_GQUAD_MIN_BOX_SIZE) {
1023 minq = j - i + p -
MAXLOOP - 2;
1024 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
1025 minq =
MAX2(c0, minq);
1027 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
1028 maxq =
MIN2(c0, maxq);
1029 for (q = minq; q < maxq; q++) {
1033 c0 = energy + ggg[index[q] + p] + P->internal_loop[j - q - 1];
1034 if (c0 <= threshold) {
1035 ge[cnt] = energy + P->internal_loop[j - q - 1];
1044 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
1053 minq = j - i + p -
MAXLOOP - 2;
1054 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
1055 minq =
MAX2(c0, minq);
1057 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
1058 maxq =
MIN2(c0, maxq);
1059 for (q = minq; q < maxq; q++) {
1063 c0 = energy + ggg[index[q] + p] + P->internal_loop[l1 + j - q - 1];
1064 if (c0 <= threshold) {
1065 ge[cnt] = energy + P->internal_loop[l1 + j - q - 1];
1075 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
1084 c0 = energy + ggg[index[q] + p] + P->internal_loop[l1];
1085 if (c0 <= threshold) {
1086 ge[cnt] = energy + P->internal_loop[l1];
1100 E_GQuad_IntLoop_L(
int i,
1108 int energy, ge,
dangles, p, q, l1, minq, maxq, c0;
1117 energy += P->mismatchI[type][si][sj];
1120 energy += P->TerminalAU;
1126 if (p < j - VRNA_GQUAD_MIN_BOX_SIZE) {
1127 minq = j - i + p -
MAXLOOP - 2;
1128 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
1129 minq =
MAX2(c0, minq);
1131 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
1132 maxq =
MIN2(c0, maxq);
1133 for (q = minq; q < maxq; q++) {
1137 c0 = energy + ggg[p][q - p] + P->internal_loop[j - q - 1];
1144 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
1153 minq = j - i + p -
MAXLOOP - 2;
1154 c0 = p + VRNA_GQUAD_MIN_BOX_SIZE - 1;
1155 minq =
MAX2(c0, minq);
1157 maxq = p + VRNA_GQUAD_MAX_BOX_SIZE + 1;
1158 maxq =
MIN2(c0, maxq);
1159 for (q = minq; q < maxq; q++) {
1163 c0 = energy + ggg[p][q - p] + P->internal_loop[l1 + j - q - 1];
1171 p < j - VRNA_GQUAD_MIN_BOX_SIZE;
1180 c0 = energy + ggg[p][q - p] + P->internal_loop[l1];
1190 exp_E_GQuad_IntLoop(
int i,
1199 int k, l, minl, maxl, u, r;
1207 qe = (
FLT_OR_DBL)pf->expmismatchI[type][si][sj];
1208 expintern = &(pf->expinternal[0]);
1215 if (k < j - VRNA_GQUAD_MIN_BOX_SIZE) {
1217 u = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
1218 minl =
MAX2(u, minl);
1220 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
1221 maxl =
MIN2(u, maxl);
1222 for (l = minl; l < maxl; l++) {
1226 if (G[index[k] - l] == 0.)
1238 k <= j - VRNA_GQUAD_MIN_BOX_SIZE;
1247 minl = j - i + k -
MAXLOOP - 2;
1248 r = k + VRNA_GQUAD_MIN_BOX_SIZE - 1;
1249 minl =
MAX2(r, minl);
1250 maxl = k + VRNA_GQUAD_MAX_BOX_SIZE + 1;
1252 maxl =
MIN2(r, maxl);
1253 for (l = minl; l < maxl; l++) {
1257 if (G[index[k] - l] == 0.)
1263 * scale[u + j - l + 1];
1269 for (k = i + 4; k <= j - VRNA_GQUAD_MIN_BOX_SIZE; k++) {
1277 if (G[index[k] - l] == 0.)
void * vrna_alloc(unsigned size)
Allocate space safely.
short ** S
Numerical encoding of the sequences in the alignment.
Definition: fold_compound.h:270
short * S_cons
Numerical encoding of the consensus sequence.
Definition: fold_compound.h:267
char * ptype
Pair type array.
Definition: fold_compound.h:225
short * sequence_encoding
Numerical encoding of the input sequence.
Definition: fold_compound.h:220
vrna_md_t model_details
Model details to be used in the recursions.
Definition: basic.h:94
double FLT_OR_DBL
Typename for floating point number in partition function computations.
Definition: basic.h:43
The most basic data structure required by many functions throughout the RNAlib.
Definition: fold_compound.h:132
The datastructure that contains temperature scaled energy parameters.
Definition: basic.h:56
#define MIN2(A, B)
Get the minimum of two comparable values.
Definition: basic.h:111
#define MAXLOOP
Definition: constants.h:29
int parse_gquad(const char *struc, int *L, int l[3])
#define INF
Definition: constants.h:17
int * jindx
DP matrix accessor.
Definition: fold_compound.h:166
Various data structures and pre-processor macros.
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:404
The data structure that contains the complete model details used throughout the calculations.
Definition: model.h:177
The data structure that contains temperature scaled Boltzmann weights of the energy parameters...
Definition: basic.h:101
Definition: fold_compound.h:116
#define MAX2(A, B)
Get the maximum of two comparable values.
Definition: basic.h:116
vrna_param_t * params
The precomputed free energy contributions for each type of loop.
Definition: fold_compound.h:162
unsigned int n_seq
The number of sequences in the alignment.
Definition: fold_compound.h:261
vrna_mx_mfe_t * matrices
The MFE DP matrices.
Definition: fold_compound.h:159
Definition: fold_compound.h:115
int dangles
Specifies the dangle model used in any energy evaluation (0,1,2 or 3)
Definition: model.h:180
Base pair stack element.
Definition: basic.h:142
FLT_OR_DBL * pr
A pointer to the base pair probability matrix.
Functions to deal with sets of energy parameters.
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.
Data structure representing a single entry of an element probability list (e.g. list of pair probabil...
Definition: structures.h:358
int * ggg
Energies of g-quadruplexes.
Definition: dp_matrices.h:72
const vrna_fc_type_e type
The type of the vrna_fold_compound_t.
Definition: fold_compound.h:137
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:624