1 #ifndef VIENNA_RNA_PACKAGE_HAIRPIN_LOOPS_H
2 #define VIENNA_RNA_PACKAGE_HAIRPIN_LOOPS_H
10 #include <ViennaRNA/energy_par.h>
13 #include <ViennaRNA/constraints.h>
18 # define INLINE inline
27 #define ON_SAME_STRAND(I,J,C) (((I)>=(C))||((J)<(C)))
132 energy = P->hairpin[size];
134 energy = P->hairpin[30] + (int)(P->lxc*log((size)/30.));
136 if(size < 3)
return energy;
141 strncpy(tl,
string, 6);
142 if ((ts=strstr(P->Tetraloops, tl)))
143 return (P->Tetraloop_E[(ts - P->Tetraloops)/7]);
147 strncpy(tl,
string, 8);
148 if ((ts=strstr(P->Hexaloops, tl)))
149 return (energy = P->Hexaloop_E[(ts - P->Hexaloops)/9]);
152 char tl[6]={0,0,0,0,0,0}, *ts;
153 strncpy(tl,
string, 5);
154 if ((ts=strstr(P->Triloops, tl))) {
155 return (P->Triloop_E[(ts - P->Triloops)/6]);
157 return (energy + (type>2 ? P->TerminalAU : 0));
160 energy += P->mismatchH[type][si1][sj1];
207 u = vc->
length - j + i - 1;
243 u = vc->
length - j + i - 1;
244 type = md->pair[S[j]][S[i]];
250 strcpy(loopseq , vc->
sequence + j - 1);
254 e =
E_Hairpin(u, type, S[j + 1], S[i - 1], loopseq, P);
286 int u, e, s, ij, cp, type, *types, *idx, n_seq;
287 short *S, **SS, **S5, **S3;
289 unsigned short **a2s;
306 type = md->pair[S[i]][S[j]];
311 if((cp < 0) || ON_SAME_STRAND(i, j, cp)){
315 si = ON_SAME_STRAND(i, i + 1, cp) ? S[i+1] : -1;
316 sj = ON_SAME_STRAND(j - 1, j, cp) ? S[j-1] : -1;
318 e =
E_ExtLoop(md->rtype[type], sj, si, P);
320 e =
E_ExtLoop(md->rtype[type], -1, -1, P);
343 types = (
int *)
vrna_alloc(
sizeof(
int) * n_seq);
345 for (s=0; s<n_seq; s++) {
346 types[s] = md->pair[SS[s][i]][SS[s][j]];
347 if (types[s]==0) types[s]=7;
350 for(e = s = 0; s < n_seq; s++){
351 u = a2s[s][j-1] - a2s[s][i];
352 e += (u < 3) ? 600 :
E_Hairpin(u, types[s], S3[s][i], S5[s][j], Ss[s]+(a2s[s][i-1]), P);
357 for(s = 0; s < n_seq; s++){
359 u = a2s[s][j-1]-a2s[s][i];
361 if(scs[s]->free_energies)
364 if(scs[s]->en_basepair)
390 INLINE PRIVATE
double
402 q = P->exphairpin[u];
404 q = P->exphairpin[30] * exp( -(P->lxc*log( u/30.))*10./kT);
410 char tl[7]={0,0,0,0,0,0,0}, *ts;
411 strncpy(tl,
string, 6);
412 if ((ts=strstr(P->Tetraloops, tl))){
414 return (P->exptetra[(ts-P->Tetraloops)/7]);
416 q *= P->exptetra[(ts-P->Tetraloops)/7];
420 char tl[9]={0,0,0,0,0,0,0,0,0}, *ts;
421 strncpy(tl,
string, 8);
422 if ((ts=strstr(P->Hexaloops, tl)))
423 return (P->exphex[(ts-P->Hexaloops)/9]);
426 char tl[6]={0,0,0,0,0,0}, *ts;
427 strncpy(tl,
string, 5);
428 if ((ts=strstr(P->Triloops, tl)))
429 return (P->exptri[(ts-P->Triloops)/6]);
431 return q * P->expTermAU;
436 q *= P->expmismatchH[type][si1][sj1];
446 INLINE PRIVATE
double
457 int *idx = vc->
jindx;
466 type = vc->
ptype[ij];
474 if((cp < 0) || ON_SAME_STRAND(i, j, cp)){
532 for(ptr = aux_bps; ptr && ptr->i != -1; ptr++){
533 bp_stack[++(*stack_count)].i = ptr->i;
534 bp_stack[(*stack_count)].j = ptr->j;
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:416
int * up_hp
A linear array that holds the number of allowed unpaired nucleotides in a hairpin loop...
Definition: constraints.h:397
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:122
struct vrna_hc_t * hc
The hard constraints data structure used for structure prediction.
Definition: data_structures.h:716
#define VRNA_DECOMP_PAIR_HP
Generalized constraint folding flag indicating hairpin loop decomposition step.
Definition: constraints.h:266
int cutpoint
The position of the (cofold) cutpoint within the provided sequence. If there is no cutpoint...
Definition: data_structures.h:712
short ** S5
S5[s][i] holds next base 5' of i in sequence s.
Definition: data_structures.h:797
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:228
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:282
char * matrix
Upper triangular matrix encoding where a base pair or unpaired nucleotide is allowed.
Definition: constraints.h:391
struct vrna_param_t * params
The precomputed free energy contributions for each type of loop.
Definition: data_structures.h:721
PAIR *(* bt)(int, int, int, int, char, void *)
A function pointer used to obtain backtraced base pairs in loop regions that were altered by soft con...
Definition: constraints.h:433
int * jindx
DP matrix accessor.
Definition: data_structures.h:725
int ** free_energies
Energy contribution for unpaired sequence stretches.
Definition: constraints.h:414
Definition: data_structures.h:681
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:800
unsigned int n_seq
The number of sequences in the alignment.
Definition: data_structures.h:785
vrna_mx_pf_t * exp_matrices
The PF DP matrices.
Definition: data_structures.h:719
FLT_OR_DBL * exp_en_basepair
Boltzmann Factors of the energy contribution for base pairs.
Definition: constraints.h:417
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:174
The most basic data structure required by many functions throughout the RNAlib.
Definition: data_structures.h:698
PRIVATE int E_ExtLoop(int type, int si1, int sj1, vrna_param_t *P)
Definition: exterior_loops.h:460
#define INF
Definition: energy_const.h:16
Energy evaluation of exterior loops for MFE and partition function calculations.
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:794
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:711
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:447
vrna_vc_t type
The type of the vrna_fold_compound.
Definition: data_structures.h:704
Various functions related to G-quadruplex computations.
char * ptype
Pair type array.
Definition: data_structures.h:749
struct vrna_exp_param_t * exp_params
The precomputed free energy contributions as Boltzmann factors.
Definition: data_structures.h:722
Base pair.
Definition: data_structures.h:73
#define VRNA_CONSTRAINT_CONTEXT_HP_LOOP
Hard constraints flag, base pair encloses hairpin loop.
Definition: constraints.h:209
The datastructure that contains temperature scaled energy parameters.
Definition: params.h:41
Definition: data_structures.h:682
The soft constraints data structure.
Definition: constraints.h:413
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:470
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:391
Base pair data structure used in subopt.c.
Definition: data_structures.h:97
short * sequence_encoding
Numerical encoding of the input sequence.
Definition: data_structures.h:744
struct vrna_sc_t * sc
The soft constraints for usage in structure prediction and evaluation.
Definition: data_structures.h:763
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:200
int * en_basepair
Energy contribution for base pairs.
Definition: constraints.h:415
The datastructure that contains temperature scaled Boltzmann weights of the energy parameters...
Definition: params.h:86
PRIVATE int vrna_BT_hp_loop(vrna_fold_compound *vc, int i, int j, int en, bondT *bp_stack, int *stack_count)
Backtrack a hairpin loop closed by .
Definition: hairpin_loops.h:505
char * sequence
The input sequence string.
Definition: data_structures.h:741
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:444
int(* f)(int, int, int, int, char, void *)
A function pointer used for pseudo energy contribution in MFE calculations.
Definition: constraints.h:423
struct vrna_sc_t ** scs
A set of soft constraints (for each sequence in the alignment)
Definition: data_structures.h:808