1 #ifndef __VIENNA_RNA_PACKAGE_INTERIOR_LOOPS_H__
2 #define __VIENNA_RNA_PACKAGE_INTERIOR_LOOPS_H__
11 #include <ViennaRNA/energy_par.h>
12 #include <ViennaRNA/constraints.h>
16 # define INLINE inline
110 INLINE PRIVATE
int E_IntLoop_Co(
int type,
141 int q, p, j_q, p_i, pq, *c_pq, max_q, max_p, tmp, *rtype, noGUclosure, no_close, energy;
144 unsigned char type, type_2;
147 char *ptype = vc->
ptype;
148 short *S = vc->sequence_encoding;
151 int *indx = vc->jindx;
152 char *hc = vc->hc->
matrix;
153 int *hc_up = vc->hc->
up_int;
156 int ij = indx[j] + i;
157 int hc_decompose = hc[ij];
159 int *c = vc->matrices->c;
160 int *ggg = vc->matrices->ggg;
162 int with_gquad = md->
gquad;
168 type = (
unsigned char)ptype[ij];
169 rtype = &(md->rtype[0]);
171 no_close = (((type==3)||(type==4))&&noGUclosure);
174 for(q = j - 1; q >= max_q; q--){
177 if(hc_up[q+1] < j_q)
break;
179 pq = indx[q] + i + 1;
183 max_p =
MAX2(max_p, tmp);
185 max_p =
MIN2(max_p, tmp);
186 tmp = i + 1 + hc_up[i + 1];
187 max_p =
MIN2(max_p, tmp);
190 ptype_pq = ptype + pq;
193 for(p = i+1; p <= max_p; p++){
198 type_2 = rtype[(
unsigned char)*ptype_pq];
201 if (no_close||(type_2==3)||(type_2==4))
202 if ((p>i+1)||(q<j-1))
continue;
204 if((cp < 0) || ( ((i >= cp) || (p < cp)) && ((q >= cp) || (j < cp)))){
205 energy =
E_IntLoop(p_i, j_q, type, type_2, S_i1, S_j1, *S_p1, *S_q1, P);
208 si = ((i >= cp) || ((i + 1) < cp)) ? S_i1 : -1;
209 sj = (((j - 1) >= cp) || (j < cp)) ? S_j1 : -1;
210 energy = E_IntLoop_Co(rtype[type], rtype[type_2],
230 if((p==i+1) && (q == j-1))
254 if ((!no_close) && ((cp < 0) || ((i >= cp) || (j < cp)))) {
255 energy = E_GQuad_IntLoop(i, j, type, S, ggg, indx, P);
270 unsigned char type, type_2;
273 short *S = vc->sequence_encoding;
274 char *ptype = vc->
ptype;
277 int *rtype = &(md->rtype[0]);
278 int *indx = vc->jindx;
279 char *hard_constraints = vc->hc->
matrix;
287 type = (
unsigned char)ptype[ij];
288 type_2 = rtype[(
unsigned char)ptype[pq]];
291 if ((cp < 0) || (((i >= cp) || (p < cp)) && ((q >= cp) || (j < cp)))){
292 e = P->stack[type][type_2];
295 si = ((i >= cp) || ((i + 1) < cp)) ? S[i+1] : -1;
296 sj = (((j - 1) >= cp) || (j < cp)) ? S[j-1] : -1;
297 e = E_IntLoop_Co(rtype[type], rtype[type_2],
312 if((p==i+1) && (q == j-1))
338 int nl, ns, u, energy;
341 if (n1>n2) { nl=n1; ns=n2;}
345 return P->stack[type][type_2];
348 energy = (nl<=
MAXLOOP)?P->bulge[nl]:
349 (P->bulge[30]+(
int)(P->lxc*log(nl/30.)));
350 if (nl==1) energy += P->stack[type][type_2];
352 if (type>2) energy += P->TerminalAU;
353 if (type_2>2) energy += P->TerminalAU;
360 return P->int11[type][type_2][si1][sj1];
363 energy = P->int21[type][type_2][si1][sq1][sj1];
365 energy = P->int21[type_2][type][sq1][si1][sp1];
369 energy = (nl+1<=
MAXLOOP)?(P->internal_loop[nl+1]) : (P->internal_loop[30]+(int)(P->lxc*log((nl+1)/30.)));
370 energy +=
MIN2(MAX_NINIO, (nl-ns)*P->ninio[2]);
371 energy += P->mismatch1nI[type][si1][sj1] + P->mismatch1nI[type_2][sq1][sp1];
377 return P->int22[type][type_2][si1][sp1][sq1][sj1];}
379 energy = P->internal_loop[5]+P->ninio[2];
380 energy += P->mismatch23I[type][si1][sj1] + P->mismatch23I[type_2][sq1][sp1];
387 energy = (u <=
MAXLOOP) ? (P->internal_loop[u]) : (P->internal_loop[30]+(int)(P->lxc*log((u)/30.)));
389 energy +=
MIN2(MAX_NINIO, (nl-ns)*P->ninio[2]);
391 energy += P->mismatchI[type][si1][sj1] + P->mismatchI[type_2][sq1][sp1];
397 INLINE PRIVATE
double exp_E_IntLoop(
int u1,
int u2,
int type,
int type2,
short si1,
short sj1,
short sp1,
short sq1,
pf_paramT *P){
398 int ul, us, no_close = 0;
401 if ((
no_closingGU) && ((type2==3)||(type2==4)||(type==3)||(type==4)))
404 if (u1>u2) { ul=u1; us=u2;}
408 z = P->expstack[type][type2];
412 if (ul==1) z *= P->expstack[type][type2];
414 if (type>2) z *= P->expTermAU;
415 if (type2>2) z *= P->expTermAU;
421 return P->expint11[type][type2][si1][sj1];
425 return P->expint21[type][type2][si1][sq1][sj1];
427 return P->expint21[type2][type][sq1][si1][sp1];
430 z = P->expinternal[ul+us] * P->expmismatch1nI[type][si1][sj1] * P->expmismatch1nI[type2][sq1][sp1];
431 return z * P->expninio[2][ul-us];
436 return P->expint22[type][type2][si1][sp1][sq1][sj1];
438 z = P->expinternal[5]*P->expmismatch23I[type][si1][sj1]*P->expmismatch23I[type2][sq1][sp1];
439 return z * P->expninio[2][1];
443 z = P->expinternal[ul+us] * P->expmismatchI[type][si1][sj1] * P->expmismatchI[type2][sq1][sp1];
444 return z * P->expninio[2][ul-us];
451 E_IntLoop_Co(
int type,
465 int energy, ci, cj, cp, cq, d3, d5, d5_2, d3_2, tmm, tmm_2;
468 if(type > 2) energy += P->TerminalAU;
469 if(type_2 > 2) energy += P->TerminalAU;
471 if(!dangles)
return energy;
473 ci = (i>=cutpoint)||((i+1)<cutpoint);
474 cj = ((j-1)>=cutpoint)||(j<cutpoint);
475 cp = ((p-1)>=cutpoint)||(p<cutpoint);
476 cq = (q>=cutpoint)||((q+1)<cutpoint);
478 d3 = ci ? P->dangle3[type][si1] : 0;
479 d5 = cj ? P->dangle5[type][sj1] : 0;
480 d5_2 = cp ? P->dangle5[type_2][sp1] : 0;
481 d3_2 = cq ? P->dangle3[type_2][sq1] : 0;
483 tmm = (cj && ci) ? P->mismatchExt[type][sj1][si1] : d5 + d3;
484 tmm_2 = (cp && cq) ? P->mismatchExt[type_2][sp1][sq1] : d5_2 + d3_2;
486 if(dangles == 2)
return energy + tmm + tmm_2;
490 if(q+2 < j){ energy += tmm + tmm_2;}
491 else if(q+2 == j){ energy += (cj && cq) ?
MIN2(tmm + d5_2, tmm_2 + d3) : tmm + tmm_2;}
492 else energy += d3 + d5_2;
495 if(q+2 < j){ energy += (ci && cp) ?
MIN2(tmm + d3_2, tmm_2 + d5) : tmm + tmm_2;}
497 energy +=
MIN2(tmm,
MIN2(tmm_2,
MIN2(d5 + d5_2, d3 + d3_2)));
499 else energy +=
MIN2(d3, d5_2);
502 if(q+2 < j){ energy += d5 + d3_2;}
503 else if(q+2 == j){ energy +=
MIN2(d5, d3_2);}
The soft constraints data structure.
Definition: data_structures.h:323
#define MIN2(A, B)
Definition: utils.h:150
int dangles
Switch the energy model for dangling end contributions (0, 1, 2, 3)
int cutpoint
The position of the (cofold) cutpoint within the provided sequence. If there is no cutpoint...
Definition: data_structures.h:363
#define MAXLOOP
Definition: energy_const.h:28
int min_loop_size
Minimum size of hairpin loops.
Definition: model.h:231
int * en_stack
Pseudo Energy contribution per base pair involved in a stack.
Definition: data_structures.h:330
PRIVATE double exp_E_IntLoop(int u1, int u2, int type, int type2, short si1, short sj1, short sp1, short sq1, pf_paramT *P)
Definition: interior_loops.h:397
#define VRNA_HC_CONTEXT_INT_LOOP_ENC
Hard constraints flag, base pair encloses a multi branch loop.
Definition: constraints.h:206
The datastructure that contains temperature scaled energy parameters.
Definition: data_structures.h:180
model_detailsT model_details
Model details to be used in the recursions.
Definition: data_structures.h:218
The datastructure that contains temperature scaled Boltzmann weights of the energy parameters...
Definition: data_structures.h:225
int * up_int
A linear array that holds the number of allowed unpaired nucleotides in an interior loop...
Definition: data_structures.h:310
int * en_basepair
Energy contribution for base pairs.
Definition: data_structures.h:326
Definition: data_structures.h:359
int noGUclosure
Do not allow loops to be closed by GU pair.
Definition: model.h:218
#define INF
Definition: energy_const.h:16
PRIVATE int E_stack(int i, int j, vrna_fold_compound *vc)
Evaluate energy of a base pair stack closed by (i,j)
Definition: interior_loops.h:265
#define VRNA_HC_CONTEXT_INT_LOOP
Hard constraints flag, base pair encloses an interior loop.
Definition: constraints.h:192
int gquad
Include G-quadruplexes in structure prediction.
Definition: model.h:221
#define VRNA_DECOMP_PAIR_IL
Generalized constraint folding flag indicating interior loop decomposition step.
Definition: constraints.h:238
int dangles
Specifies the dangle model used in any energy evaluation (0,1,2 or 3)
Definition: model.h:209
void * data
A pointer to the data object necessary for for pseudo energy contribution functions.
Definition: data_structures.h:353
int(* f)(int, int, int, int, char, void *)
A function pointer used for pseudo energy contribution in MFE calculations.
Definition: data_structures.h:334
int no_closingGU
GU allowed only inside stacks if set to 1.
Various functions related to G-quadruplex computations.
char * ptype
Pair type array.
Definition: data_structures.h:371
char * matrix
Upper triangular matrix encoding where a base pair or unpaired nucleotide is allowed.
Definition: data_structures.h:301
Here all all declarations of the global variables used throughout RNAlib.
The data structure that contains the complete model details used throughout the calculations.
Definition: model.h:206
int ** free_energies
Energy contribution for unpaired sequence stretches.
Definition: data_structures.h:325
#define MAX2(A, B)
Definition: utils.h:154
PRIVATE int E_IntLoop(int n1, int n2, int type, int type_2, int si1, int sj1, int sp1, int sq1, paramT *P)
Definition: interior_loops.h:327