1 #ifndef VIENNA_RNA_PACKAGE_EXTERIOR_LOOPS_H
2 #define VIENNA_RNA_PACKAGE_EXTERIOR_LOOPS_H
10 #include <ViennaRNA/energy_par.h>
12 #include <ViennaRNA/constraints.h>
16 # define INLINE inline
108 INLINE PRIVATE
int E_Stem(
int type,
144 int *idx = vc->
jindx;
145 char *ptype = vc->
ptype;
148 char *hard_constraints = vc->
hc->
matrix;
154 if((cp < 0) || (((i)>=cp)||((j)<cp))){
159 case 2:
if(hard_constraints[ij] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP)
162 default:
if(hard_constraints[ij] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP)
165 if(hard_constraints[ij] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP){
166 type = vc->
ptype[ij];
171 if(hard_constraints[ij] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP){
172 type = vc->
ptype[ij];
187 int en, i, j, ij, type;
188 int length = (int)vc->
length;
189 char *ptype = vc->
ptype;
191 int *indx = vc->
jindx;
204 for(i = 1; i <= turn + 1; i++){
207 if(sc && (f5[i] !=
INF))
208 if(sc->free_energies)
209 f5[i] += sc->free_energies[i][1];
216 switch(dangle_model){
218 case 0:
for(j=turn+2; j<=length; j++){
222 if(sc && (f5[j] !=
INF))
223 if(sc->free_energies)
224 f5[j] += sc->free_energies[j][1];
226 for (i=j-turn-1; i>1; i--){
228 if(!(hc[ij] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP))
234 f5[j] =
MIN2(f5[j], f5[i-1] + ggg[indx[j]+i]);
238 en = f5[i-1] + c[ij] +
E_ExtLoop(ptype[ij], -1, -1, P);
239 f5[j] =
MIN2(f5[j], en);
244 if(!(hc[ij] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP))
248 f5[j] =
MIN2(f5[j], ggg[indx[j]+1]);
252 en = c[ij] +
E_ExtLoop(ptype[ij], -1, -1, P);
253 f5[j] =
MIN2(f5[j], en);
259 case 2:
for(j=turn+2; j<length; j++){
263 if(sc && (f5[j] !=
INF))
264 if(sc->free_energies)
265 f5[j] += sc->free_energies[j][1];
267 for (i=j-turn-1; i>1; i--){
269 if(!(hc[ij] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP))
275 f5[j] =
MIN2(f5[j], f5[i-1] + ggg[indx[j]+i]);
279 en = f5[i-1] + c[ij] +
E_ExtLoop(ptype[ij], S[i-1], S[j+1], P);
280 f5[j] =
MIN2(f5[j], en);
284 if(!(hc[ij] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP))
288 f5[j] =
MIN2(f5[j], ggg[indx[j]+1]);
292 en = c[ij] +
E_ExtLoop(ptype[ij], -1, S[j+1], P);
293 f5[j] =
MIN2(f5[j], en);
297 f5[length] = f5[length-1];
298 if(sc && (f5[length] !=
INF))
299 if(sc->free_energies)
300 f5[length] += sc->free_energies[length][1];
302 for (i=length-turn-1; i>1; i--){
303 ij = indx[length] + i;
304 if(!(hc[ij] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP))
310 f5[length] =
MIN2(f5[length], f5[i-1] + ggg[indx[length]+i]);
314 en = f5[i-1] + c[ij] +
E_ExtLoop(ptype[ij], S[i-1], -1, P);
315 f5[length] =
MIN2(f5[length], en);
318 ij = indx[length] + 1;
319 if(!(hc[ij] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP))
323 f5[length] =
MIN2(f5[length], ggg[indx[length]+1]);
327 en = c[ij] +
E_ExtLoop(ptype[ij], -1, -1, P);
328 f5[length] =
MIN2(f5[length], en);
333 default:
for(j=turn+2; j<=length; j++){
337 if(sc && (f5[j] !=
INF))
338 if(sc->free_energies)
339 f5[j] += sc->free_energies[j][1];
341 for (i=j-turn-1; i>1; i--){
343 if(hc[ij] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP){
347 f5[j] =
MIN2(f5[j], f5[i-1] + ggg[indx[j]+i]);
352 en = f5[i-1] + c[ij] +
E_ExtLoop(type, -1, -1, P);
353 f5[j] =
MIN2(f5[j], en);
357 if((f5[i-2] !=
INF) && c[ij] !=
INF){
358 en = f5[i-2] + c[ij] +
E_ExtLoop(type, S[i-1], -1, P);
361 if(sc->free_energies)
362 en += sc->free_energies[i-1][1];
364 f5[j] =
MIN2(f5[j], en);
369 if(hc[ij] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP){
373 if(f5[i - 1] !=
INF){
374 en = f5[i-1] + c[ij] +
E_ExtLoop(type, -1, S[j], P);
377 if(sc->free_energies)
378 en += sc->free_energies[j][1];
380 f5[j] =
MIN2(f5[j], en);
384 if(f5[i - 2] !=
INF){
385 en = f5[i-2] + c[ij] +
E_ExtLoop(type, S[i-1], S[j], P);
388 if(sc->free_energies)
389 en += sc->free_energies[i-1][1] + sc->free_energies[j][1];
391 f5[j] =
MIN2(f5[j], en);
399 if(hc[ij] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP){
402 f5[j] =
MIN2(f5[j], ggg[indx[j]+1]);
408 f5[j] =
MIN2(f5[j], en);
412 if(hc[ij] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP){
416 en = c[ij] +
E_ExtLoop(type, -1, S[j], P);
419 if(sc->free_energies)
420 en += sc->free_energies[j][1];
422 f5[j] =
MIN2(f5[j], en);
438 int d5 = (si1 >= 0) ? P->dangle5[type][si1] : 0;
439 int d3 = (sj1 >= 0) ? P->dangle3[type][sj1] : 0;
442 energy += P->TerminalAU;
444 if(si1 >= 0 && sj1 >= 0)
445 energy += (extLoop) ? P->mismatchExt[type][si1][sj1] : P->mismatchM[type][si1][sj1];
449 if(!extLoop) energy += P->MLintern[type];
460 if(si1 >= 0 && sj1 >= 0){
461 energy += P->mismatchExt[type][si1][sj1];
464 energy += P->dangle5[type][si1];
467 energy += P->dangle3[type][sj1];
471 energy += P->TerminalAU;
476 INLINE PRIVATE
double
484 double d5 = (si1 >= 0) ? P->expdangle5[type][si1] : 1.;
485 double d3 = (sj1 >= 0) ? P->expdangle3[type][sj1] : 1.;
487 if(si1 >= 0 && sj1 >= 0)
488 energy = (extLoop) ? P->expmismatchExt[type][si1][sj1] : P->expmismatchM[type][si1][sj1];
493 energy *= P->expTermAU;
495 if(!extLoop) energy *= P->expMLintern[type];
499 INLINE PRIVATE
double
506 if(si1 >= 0 && sj1 >= 0){
507 energy = P->expmismatchExt[type][si1][sj1];
510 energy = P->expdangle5[type][si1];
513 energy = P->expdangle3[type][sj1];
517 energy *= P->expTermAU;
PRIVATE double exp_E_Stem(int type, int si1, int sj1, int extLoop, vrna_exp_param_t *P)
Definition: exterior_loops.h:477
int * ggg
Energies of g-quadruplexes.
Definition: data_structures.h:429
int * c
Energy array, given that i-j pair.
Definition: data_structures.h:422
PRIVATE double exp_E_ExtLoop(int type, int si1, int sj1, vrna_exp_param_t *P)
Definition: exterior_loops.h:500
struct vrna_hc_t * hc
The hard constraints data structure used for structure prediction.
Definition: data_structures.h:707
int cutpoint
The position of the (cofold) cutpoint within the provided sequence. If there is no cutpoint...
Definition: data_structures.h:703
char * matrix
Upper triangular matrix encoding where a base pair or unpaired nucleotide is allowed.
Definition: constraints.h:379
struct vrna_param_t * params
The precomputed free energy contributions for each type of loop.
Definition: data_structures.h:712
int * jindx
DP matrix accessor.
Definition: data_structures.h:716
int gquad
Include G-quadruplexes in structure prediction.
Definition: model.h:184
PRIVATE int E_Stem(int type, int si1, int sj1, int extLoop, vrna_param_t *P)
Definition: exterior_loops.h:431
int * up_ext
A linear array that holds the number of allowed unpaired nucleotides in an exterior loop...
Definition: constraints.h:382
#define MIN2(A, B)
Get the minimum of two comparable values.
Definition: utils.h:118
vrna_md_t model_details
Model details to be used in the recursions.
Definition: params.h:79
The most basic data structure required by many functions throughout the RNAlib.
Definition: data_structures.h:689
PRIVATE int E_ExtLoop(int type, int si1, int sj1, vrna_param_t *P)
Definition: exterior_loops.h:454
#define VRNA_CONSTRAINT_CONTEXT_EXT_LOOP
Hard constraints flag, base pair in the exterior loop.
Definition: constraints.h:189
#define INF
Definition: energy_const.h:16
vrna_mx_mfe_t * matrices
The MFE DP matrices.
Definition: data_structures.h:709
int min_loop_size
Minimum size of hairpin loops.
Definition: model.h:194
int dangles
Specifies the dangle model used in any energy evaluation (0,1,2 or 3)
Definition: model.h:172
unsigned int length
The length of the sequence (or sequence alignment)
Definition: data_structures.h:702
Various functions related to G-quadruplex computations.
char * ptype
Pair type array.
Definition: data_structures.h:740
The datastructure that contains temperature scaled energy parameters.
Definition: params.h:41
The soft constraints data structure.
Definition: constraints.h:401
The data structure that contains the complete model details used throughout the calculations.
Definition: model.h:169
Here all all declarations of the global variables used throughout RNAlib.
short * sequence_encoding
Numerical encoding of the input sequence.
Definition: data_structures.h:735
struct vrna_sc_t * sc
The soft constraints for usage in structure prediction and evaluation.
Definition: data_structures.h:754
The datastructure that contains temperature scaled Boltzmann weights of the energy parameters...
Definition: params.h:86
int * f5
Energy of 5' end.
Definition: data_structures.h:423