1 #ifndef __VIENNA_RNA_PACKAGE_HAIRPIN_LOOPS_H__
2 #define __VIENNA_RNA_PACKAGE_HAIRPIN_LOOPS_H__
11 #include <ViennaRNA/energy_par.h>
12 #include <ViennaRNA/constraints.h>
16 # define INLINE inline
109 energy = P->hairpin[size];
111 energy = P->hairpin[30] + (int)(P->lxc*log((size)/30.));
113 if(size < 3)
return energy;
118 strncpy(tl,
string, 6);
119 if ((ts=strstr(P->Tetraloops, tl)))
120 return (P->Tetraloop_E[(ts - P->Tetraloops)/7]);
124 strncpy(tl,
string, 8);
125 if ((ts=strstr(P->Hexaloops, tl)))
126 return (energy = P->Hexaloop_E[(ts - P->Hexaloops)/9]);
129 char tl[6]={0,0,0,0,0,0}, *ts;
130 strncpy(tl,
string, 5);
131 if ((ts=strstr(P->Triloops, tl))) {
132 return (P->Triloop_E[(ts - P->Triloops)/6]);
134 return (energy + (type>2 ? P->TerminalAU : 0));
137 energy += P->mismatchH[type][si1][sj1];
155 short *S = vc->sequence_encoding;
156 int *idx = vc->jindx;
158 int *hc_up = vc->hc->
up_hp;
165 type = vc->
ptype[ij];
173 if((cp < 0) || ((i >= cp) || (j < cp))){
174 e =
E_Hairpin(u, type, S[i+1], S[j-1], vc->sequence+i-1, P);
177 si = ((i >= cp) || ((i + 1) < cp)) ? S[i+1] : -1;
178 sj = (((j - 1) >= cp) || (j < cp)) ? S[j-1] : -1;
180 e =
E_ExtLoop(md->rtype[type], sj, si, P);
182 e =
E_ExtLoop(md->rtype[type], -1, -1, P);
209 int n_seq = vc->n_seq;
210 int *idx = vc->jindx;
217 unsigned short **a2s = vc->a2s;
218 char hc = vc->hc->
matrix[idx[j]+i];
219 int *hc_up = vc->hc->
up_hp;
222 type = (
int *)
space(
sizeof(
int) * n_seq);
224 for (s=0; s<n_seq; s++) {
225 type[s] = md->pair[S[s][i]][S[s][j]];
226 if (type[s]==0) type[s]=7;
231 if(hc_up[i+1] >= j - i - 1){
232 for (e=s=0; s<n_seq; s++) {
233 u = a2s[s][j-1] - a2s[s][i];
235 else e +=
E_Hairpin(u, type[s], S3[s][i], S5[s][j], Ss[s]+(a2s[s][i-1]), P);
239 for(s = 0; s < n_seq; s++){
241 u = a2s[s][j-1]-a2s[s][i];
243 if(sc[s]->free_energies)
246 if(sc[s]->en_basepair)
270 INLINE PRIVATE
double
282 q = P->exphairpin[u];
284 q = P->exphairpin[30] * exp( -(P->lxc*log( u/30.))*10./kT);
290 char tl[7]={0,0,0,0,0,0,0}, *ts;
291 strncpy(tl,
string, 6);
292 if ((ts=strstr(P->Tetraloops, tl))){
294 return (P->exptetra[(ts-P->Tetraloops)/7]);
296 q *= P->exptetra[(ts-P->Tetraloops)/7];
300 char tl[9]={0,0,0,0,0,0,0,0,0}, *ts;
301 strncpy(tl,
string, 8);
302 if ((ts=strstr(P->Hexaloops, tl)))
303 return (P->exphex[(ts-P->Hexaloops)/9]);
306 char tl[6]={0,0,0,0,0,0}, *ts;
307 strncpy(tl,
string, 5);
308 if ((ts=strstr(P->Triloops, tl)))
309 return (P->exptri[(ts-P->Triloops)/6]);
311 return q * P->expTermAU;
316 q *= P->expmismatchH[type][si1][sj1];
326 INLINE PRIVATE
double
336 short *S = vc->sequence_encoding;
337 int *idx = vc->jindx;
339 int *hc_up = vc->hc->
up_hp;
342 FLT_OR_DBL *scale = vc->exp_matrices->scale;
347 type = vc->
ptype[ij];
351 if(hc & VRNA_HC_CONTEXT_HP_LOOP){
355 if((cp < 0) || ((i >= cp) || (j < cp))){
356 q =
exp_E_Hairpin(u, type, S[i+1], S[j-1], vc->sequence+i-1, P)
int * up_hp
A linear array that holds the number of allowed unpaired nucleotides in a hairpin loop...
Definition: data_structures.h:307
The soft constraints data structure.
Definition: data_structures.h:323
void * space(unsigned size)
Allocate space safely.
int cutpoint
The position of the (cofold) cutpoint within the provided sequence. If there is no cutpoint...
Definition: data_structures.h:363
double(* exp_f)(int, int, int, int, char, void *)
A function pointer used for pseudo energy contribution boltzmann factors in PF calculations.
Definition: data_structures.h:343
double ** boltzmann_factors
Boltzmann Factors of the energy contributions for unpaired sequence stretches.
Definition: data_structures.h:327
#define VRNA_HC_CONTEXT_HP_LOOP
Hard constraints flag, base pair encloses hairpin loop.
Definition: constraints.h:185
int special_hp
Include special hairpin contributions for tri, tetra and hexaloops.
Definition: model.h:215
The datastructure that contains temperature scaled energy parameters.
Definition: data_structures.h:180
PRIVATE double exp_E_Hairpin(int u, int type, short si1, short sj1, const char *string, pf_paramT *P)
Compute Boltzmann weight of a hairpin loop.
Definition: hairpin_loops.h:271
model_detailsT model_details
Model details to be used in the recursions.
Definition: data_structures.h:218
#define VRNA_DECOMP_PAIR_HP
Generalized constraint folding flag indicating hairpin loop decomposition step.
Definition: constraints.h:230
The datastructure that contains temperature scaled Boltzmann weights of the energy parameters...
Definition: data_structures.h:225
int * en_basepair
Energy contribution for base pairs.
Definition: data_structures.h:326
Definition: data_structures.h:359
PRIVATE int E_Hairpin(int size, int type, int si1, int sj1, const char *string, paramT *P)
Compute the Energy of a hairpin-loop.
Definition: hairpin_loops.h:99
#define INF
Definition: energy_const.h:16
PRIVATE int E_hp_loop(int i, int j, vrna_fold_compound *vc)
High-Level function for hairpin loop energy evaluation.
Definition: hairpin_loops.h:147
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
PRIVATE double exp_E_hp_loop(int i, int j, vrna_fold_compound *vc)
High-Level function for hairpin loop energy evaluation (partition function variant) ...
Definition: hairpin_loops.h:327
PRIVATE int E_ExtLoop(int type, int si1, int sj1, paramT *P)
Definition: exterior_loops.h:409
int(* f)(int, int, int, int, char, void *)
A function pointer used for pseudo energy contribution in MFE calculations.
Definition: data_structures.h:334
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
double * exp_en_basepair
Boltzmann Factors of the energy contribution for base pairs.
Definition: data_structures.h:328
model_detailsT model_details
Model details to be used in the recursions.
Definition: data_structures.h:273