1 #ifndef __VIENNA_RNA_PACKAGE_EXTERIOR_LOOPS_H__
2 #define __VIENNA_RNA_PACKAGE_EXTERIOR_LOOPS_H__
11 #include <ViennaRNA/energy_par.h>
12 #include <ViennaRNA/constraints.h>
16 # define INLINE inline
104 INLINE PRIVATE
int E_Stem(
int type,
139 short *S = vc->sequence_encoding;
140 int *idx = vc->jindx;
141 char *ptype = vc->
ptype;
144 char *hard_constraints = vc->hc->
matrix;
150 if((cp < 0) || (((i)>=cp)||((j)<cp))){
155 case 2:
if(hard_constraints[ij] & VRNA_HC_CONTEXT_EXT_LOOP)
158 default:
if(hard_constraints[ij] & VRNA_HC_CONTEXT_EXT_LOOP)
161 if(hard_constraints[ij] & VRNA_HC_CONTEXT_EXT_LOOP){
162 type = vc->
ptype[ij];
167 if(hard_constraints[ij] & VRNA_HC_CONTEXT_EXT_LOOP){
168 type = vc->
ptype[ij];
183 int en, i, j, ij, type;
184 int length = (int)vc->length;
185 char *ptype = vc->
ptype;
186 short *S = vc->sequence_encoding;
187 int *indx = vc->jindx;
188 char *hc = vc->hc->
matrix;
189 int *hc_up = vc->hc->
up_ext;
191 int *f5 = vc->matrices->f5;
192 int *c = vc->matrices->c;
195 int *ggg = vc->matrices->ggg;
200 for(i = 1; i <= turn + 1; i++){
204 if(sc->free_energies)
205 f5[i] += sc->free_energies[i][1];
212 switch(dangle_model){
214 case 0:
for(j=turn+2; j<=length; j++){
219 if(sc->free_energies)
220 f5[j] += sc->free_energies[j][1];
222 for (i=j-turn-1; i>1; i--){
224 if(!(hc[ij] & VRNA_HC_CONTEXT_EXT_LOOP))
continue;
227 f5[j] =
MIN2(f5[j], f5[i-1] + ggg[indx[j]+i]);
230 en = f5[i-1] + c[ij] +
E_ExtLoop(ptype[ij], -1, -1, P);
231 f5[j] =
MIN2(f5[j], en);
234 if(!(hc[ij] & VRNA_HC_CONTEXT_EXT_LOOP))
continue;
237 f5[j] =
MIN2(f5[j], ggg[indx[j]+1]);
240 en = c[ij] +
E_ExtLoop(ptype[ij], -1, -1, P);
241 f5[j] =
MIN2(f5[j], en);
246 case 2:
for(j=turn+2; j<length; j++){
251 if(sc->free_energies)
252 f5[j] += sc->free_energies[j][1];
254 for (i=j-turn-1; i>1; i--){
256 if(!(hc[ij] & VRNA_HC_CONTEXT_EXT_LOOP))
continue;
259 f5[j] =
MIN2(f5[j], f5[i-1] + ggg[indx[j]+i]);
262 en = f5[i-1] + c[ij] +
E_ExtLoop(ptype[ij], S[i-1], S[j+1], P);
263 f5[j] =
MIN2(f5[j], en);
266 if(!(hc[ij] & VRNA_HC_CONTEXT_EXT_LOOP))
continue;
269 f5[j] =
MIN2(f5[j], ggg[indx[j]+1]);
272 en = c[ij] +
E_ExtLoop(ptype[ij], -1, S[j+1], P);
273 f5[j] =
MIN2(f5[j], en);
276 f5[length] = f5[length-1];
278 if(sc->free_energies)
279 f5[length] += sc->free_energies[length][1];
281 for (i=length-turn-1; i>1; i--){
282 ij = indx[length] + i;
283 if(!(hc[ij] & VRNA_HC_CONTEXT_EXT_LOOP))
continue;
286 f5[length] =
MIN2(f5[length], f5[i-1] + ggg[indx[length]+i]);
289 en = f5[i-1] + c[ij] +
E_ExtLoop(ptype[ij], S[i-1], -1, P);
290 f5[length] =
MIN2(f5[length], en);
292 ij = indx[length] + 1;
293 if(!(hc[ij] & VRNA_HC_CONTEXT_EXT_LOOP))
break;
296 f5[length] =
MIN2(f5[length], ggg[indx[length]+1]);
299 en = c[ij] +
E_ExtLoop(ptype[ij], -1, -1, P);
300 f5[length] =
MIN2(f5[length], en);
304 default:
for(j=turn+2; j<=length; j++){
309 if(sc->free_energies)
310 f5[j] += sc->free_energies[j][1];
312 for (i=j-turn-1; i>1; i--){
314 if(hc[ij] & VRNA_HC_CONTEXT_EXT_LOOP){
317 f5[j] =
MIN2(f5[j], f5[i-1] + ggg[indx[j]+i]);
321 en = f5[i-1] + c[ij] +
E_ExtLoop(type, -1, -1, P);
322 f5[j] =
MIN2(f5[j], en);
324 en = f5[i-2] + c[ij] +
E_ExtLoop(type, S[i-1], -1, P);
327 if(sc->free_energies)
328 en += sc->free_energies[i-1][1];
330 f5[j] =
MIN2(f5[j], en);
334 if(hc[ij] & VRNA_HC_CONTEXT_EXT_LOOP){
337 en = f5[i-1] + c[ij] +
E_ExtLoop(type, -1, S[j], P);
340 if(sc->free_energies)
341 en += sc->free_energies[j][1];
343 f5[j] =
MIN2(f5[j], en);
346 en = f5[i-2] + c[ij] +
E_ExtLoop(type, S[i-1], S[j], P);
349 if(sc->free_energies)
350 en += sc->free_energies[i-1][1] + sc->free_energies[j][1];
352 f5[j] =
MIN2(f5[j], en);
358 if(hc[ij] & VRNA_HC_CONTEXT_EXT_LOOP){
361 f5[j] =
MIN2(f5[j], ggg[indx[j]+1]);
366 f5[j] =
MIN2(f5[j], en);
369 if(hc[ij] & VRNA_HC_CONTEXT_EXT_LOOP){
372 en = c[ij] +
E_ExtLoop(type, -1, S[j], P);
375 if(sc->free_energies)
376 en += sc->free_energies[j][1];
378 f5[j] =
MIN2(f5[j], en);
393 int d5 = (si1 >= 0) ? P->dangle5[type][si1] : 0;
394 int d3 = (sj1 >= 0) ? P->dangle3[type][sj1] : 0;
397 energy += P->TerminalAU;
399 if(si1 >= 0 && sj1 >= 0)
400 energy += (extLoop) ? P->mismatchExt[type][si1][sj1] : P->mismatchM[type][si1][sj1];
404 if(!extLoop) energy += P->MLintern[type];
415 if(si1 >= 0 && sj1 >= 0){
416 energy += P->mismatchExt[type][si1][sj1];
419 energy += P->dangle5[type][si1];
422 energy += P->dangle3[type][sj1];
426 energy += P->TerminalAU;
431 INLINE PRIVATE
double
439 double d5 = (si1 >= 0) ? P->expdangle5[type][si1] : 1.;
440 double d3 = (sj1 >= 0) ? P->expdangle3[type][sj1] : 1.;
442 if(si1 >= 0 && sj1 >= 0)
443 energy = (extLoop) ? P->expmismatchExt[type][si1][sj1] : P->expmismatchM[type][si1][sj1];
448 energy *= P->expTermAU;
450 if(!extLoop) energy *= P->expMLintern[type];
454 INLINE PRIVATE
double
461 if(si1 >= 0 && sj1 >= 0){
462 energy = P->expmismatchExt[type][si1][sj1];
465 energy = P->expdangle5[type][si1];
468 energy = P->expdangle3[type][sj1];
472 energy *= P->expTermAU;
The soft constraints data structure.
Definition: data_structures.h:323
#define MIN2(A, B)
Definition: utils.h:150
int cutpoint
The position of the (cofold) cutpoint within the provided sequence. If there is no cutpoint...
Definition: data_structures.h:363
int min_loop_size
Minimum size of hairpin loops.
Definition: model.h:231
PRIVATE double exp_E_Stem(int type, int si1, int sj1, int extLoop, pf_paramT *P)
Definition: exterior_loops.h:432
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
PRIVATE double exp_E_ExtLoop(int type, int si1, int sj1, pf_paramT *P)
Definition: exterior_loops.h:455
Definition: data_structures.h:359
PRIVATE int E_Stem(int type, int si1, int sj1, int extLoop, paramT *P)
Definition: exterior_loops.h:386
#define INF
Definition: energy_const.h:16
int gquad
Include G-quadruplexes in structure prediction.
Definition: model.h:221
int dangles
Specifies the dangle model used in any energy evaluation (0,1,2 or 3)
Definition: model.h:209
int * up_ext
A linear array that holds the number of allowed unpaired nucleotides in an exterior loop...
Definition: data_structures.h:304
PRIVATE int E_ExtLoop(int type, int si1, int sj1, paramT *P)
Definition: exterior_loops.h:409
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
#define VRNA_HC_CONTEXT_EXT_LOOP
Hard constraints flag, base pair in the exterior loop.
Definition: constraints.h:178
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