1 #ifndef VIENNA_RNA_PACKAGE_HAIRPIN_LOOPS_H
2 #define VIENNA_RNA_PACKAGE_HAIRPIN_LOOPS_H
10 #include <ViennaRNA/energy_par.h>
12 #include <ViennaRNA/constraints.h>
16 # define INLINE inline
123 energy = P->hairpin[size];
125 energy = P->hairpin[30] + (int)(P->lxc*log((size)/30.));
127 if(size < 3)
return energy;
132 strncpy(tl,
string, 6);
133 if ((ts=strstr(P->Tetraloops, tl)))
134 return (P->Tetraloop_E[(ts - P->Tetraloops)/7]);
138 strncpy(tl,
string, 8);
139 if ((ts=strstr(P->Hexaloops, tl)))
140 return (energy = P->Hexaloop_E[(ts - P->Hexaloops)/9]);
143 char tl[6]={0,0,0,0,0,0}, *ts;
144 strncpy(tl,
string, 5);
145 if ((ts=strstr(P->Triloops, tl))) {
146 return (P->Triloop_E[(ts - P->Triloops)/6]);
148 return (energy + (type>2 ? P->TerminalAU : 0));
151 energy += P->mismatchH[type][si1][sj1];
194 u = vc->
length - j + i - 1;
230 u = vc->
length - j + i - 1;
231 type = md->pair[S[j]][S[i]];
237 strcpy(loopseq , vc->
sequence + j - 1);
241 e =
E_Hairpin(u, type, S[j + 1], S[i - 1], loopseq, P);
270 int *idx = vc->
jindx;
278 type = md->pair[S[i]][S[j]];
283 if((cp < 0) || ((i >= cp) || (j < cp))){
287 si = ((i >= cp) || ((i + 1) < cp)) ? S[i+1] : -1;
288 sj = (((j - 1) >= cp) || (j < cp)) ? S[j-1] : -1;
290 e =
E_ExtLoop(md->rtype[type], sj, si, P);
292 e =
E_ExtLoop(md->rtype[type], -1, -1, P);
316 int n_seq = vc->
n_seq;
317 int *idx = vc->
jindx;
324 unsigned short **a2s = vc->a2s;
329 type = (
int *)
vrna_alloc(
sizeof(
int) * n_seq);
331 for (s=0; s<n_seq; s++) {
332 type[s] = md->pair[S[s][i]][S[s][j]];
333 if (type[s]==0) type[s]=7;
338 if(hc_up[i+1] >= j - i - 1){
339 for (e=s=0; s<n_seq; s++) {
340 u = a2s[s][j-1] - a2s[s][i];
342 else e +=
E_Hairpin(u, type[s], S3[s][i], S5[s][j], Ss[s]+(a2s[s][i-1]), P);
346 for(s = 0; s < n_seq; s++){
348 u = a2s[s][j-1]-a2s[s][i];
350 if(sc[s]->free_energies)
353 if(sc[s]->en_basepair)
377 INLINE PRIVATE
double
389 q = P->exphairpin[u];
391 q = P->exphairpin[30] * exp( -(P->lxc*log( u/30.))*10./kT);
397 char tl[7]={0,0,0,0,0,0,0}, *ts;
398 strncpy(tl,
string, 6);
399 if ((ts=strstr(P->Tetraloops, tl))){
401 return (P->exptetra[(ts-P->Tetraloops)/7]);
403 q *= P->exptetra[(ts-P->Tetraloops)/7];
407 char tl[9]={0,0,0,0,0,0,0,0,0}, *ts;
408 strncpy(tl,
string, 8);
409 if ((ts=strstr(P->Hexaloops, tl)))
410 return (P->exphex[(ts-P->Hexaloops)/9]);
413 char tl[6]={0,0,0,0,0,0}, *ts;
414 strncpy(tl,
string, 5);
415 if ((ts=strstr(P->Triloops, tl)))
416 return (P->exptri[(ts-P->Triloops)/6]);
418 return q * P->expTermAU;
423 q *= P->expmismatchH[type][si1][sj1];
433 INLINE PRIVATE
double
444 int *idx = vc->
jindx;
453 type = vc->
ptype[ij];
457 if(hc & VRNA_CONSTRAINT_CONTEXT_HP_LOOP){
461 if((cp < 0) || ((i >= cp) || (j < cp))){
void * vrna_alloc(unsigned size)
Allocate space safely.
int special_hp
Include special hairpin contributions for tri, tetra and hexaloops.
Definition: model.h:178
FLT_OR_DBL ** boltzmann_factors
Boltzmann Factors of the energy contributions for unpaired sequence stretches.
Definition: constraints.h:404
int * up_hp
A linear array that holds the number of allowed unpaired nucleotides in a hairpin loop...
Definition: constraints.h:385
PRIVATE int E_Hairpin(int size, int type, int si1, int sj1, const char *string, vrna_param_t *P)
Compute the Energy of a hairpin-loop.
Definition: hairpin_loops.h:113
struct vrna_hc_t * hc
The hard constraints data structure used for structure prediction.
Definition: data_structures.h:707
#define VRNA_DECOMP_PAIR_HP
Generalized constraint folding flag indicating hairpin loop decomposition step.
Definition: constraints.h:254
int cutpoint
The position of the (cofold) cutpoint within the provided sequence. If there is no cutpoint...
Definition: data_structures.h:703
short ** S5
S5[s][i] holds next base 5' of i in sequence s.
Definition: data_structures.h:788
PRIVATE int vrna_eval_ext_hp_loop(vrna_fold_compound *vc, int i, int j)
Evaluate free energy of an exterior hairpin loop.
Definition: hairpin_loops.h:215
PRIVATE int vrna_eval_hp_loop(vrna_fold_compound *vc, int i, int j)
Evaluate free energy of a hairpin loop.
Definition: hairpin_loops.h:262
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 ** free_energies
Energy contribution for unpaired sequence stretches.
Definition: constraints.h:402
vrna_md_t model_details
Model details to be used in the recursions.
Definition: params.h:79
short ** S3
Sl[s][i] holds next base 3' of i in sequence s.
Definition: data_structures.h:791
unsigned int n_seq
The number of sequences in the alignment.
Definition: data_structures.h:776
vrna_mx_pf_t * exp_matrices
The PF DP matrices.
Definition: data_structures.h:710
FLT_OR_DBL * exp_en_basepair
Boltzmann Factors of the energy contribution for base pairs.
Definition: constraints.h:405
PRIVATE int vrna_E_hp_loop(vrna_fold_compound *vc, int i, int j)
Evaluate the free energy of a hairpin loop and consider possible hard constraints.
Definition: hairpin_loops.h:161
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 INF
Definition: energy_const.h:16
vrna_md_t model_details
Model details to be used in the recursions.
Definition: params.h:136
short ** S
Numerical encoding of the sequences in the alignment.
Definition: data_structures.h:785
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
PRIVATE double vrna_exp_E_hp_loop(vrna_fold_compound *vc, int i, int j)
High-Level function for hairpin loop energy evaluation (partition function variant) ...
Definition: hairpin_loops.h:434
Various functions related to G-quadruplex computations.
char * ptype
Pair type array.
Definition: data_structures.h:740
struct vrna_exp_param_t * exp_params
The precomputed free energy contributions as Boltzmann factors.
Definition: data_structures.h:713
#define VRNA_CONSTRAINT_CONTEXT_HP_LOOP
Hard constraints flag, base pair encloses hairpin loop.
Definition: constraints.h:197
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
void * data
A pointer to the data object provided for for pseudo energy contribution functions of the generalized...
Definition: constraints.h:447
Here all all declarations of the global variables used throughout RNAlib.
PRIVATE double exp_E_Hairpin(int u, int type, short si1, short sj1, const char *string, vrna_exp_param_t *P)
Compute Boltzmann weight of a hairpin loop.
Definition: hairpin_loops.h:378
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
PRIVATE int vrna_E_ext_hp_loop(vrna_fold_compound *vc, int i, int j)
Evaluate the free energy of an exterior hairpin loop and consider possible hard constraints.
Definition: hairpin_loops.h:187
int * en_basepair
Energy contribution for base pairs.
Definition: constraints.h:403
The datastructure that contains temperature scaled Boltzmann weights of the energy parameters...
Definition: params.h:86
char * sequence
The input sequence string.
Definition: data_structures.h:732
FLT_OR_DBL(* exp_f)(int, int, int, int, char, void *)
A function pointer used for pseudo energy contribution boltzmann factors in PF calculations.
Definition: constraints.h:421
int(* f)(int, int, int, int, char, void *)
A function pointer used for pseudo energy contribution in MFE calculations.
Definition: constraints.h:411
struct vrna_sc_t ** scs
A set of soft constraints (for each sequence in the alignment)
Definition: data_structures.h:799