RNAlib-2.3.1
hairpin_loops.h
Go to the documentation of this file.
1 #ifndef VIENNA_RNA_PACKAGE_HAIRPIN_LOOPS_H
2 #define VIENNA_RNA_PACKAGE_HAIRPIN_LOOPS_H
3 
4 #include <math.h>
5 #include <string.h>
6 #include <ViennaRNA/utils.h>
8 #include <ViennaRNA/params.h>
9 
10 #ifdef __GNUC__
11 # define INLINE inline
12 #else
13 # define INLINE
14 #endif
15 
62 PRIVATE INLINE int
63 E_Hairpin(int size,
64  int type,
65  int si1,
66  int sj1,
67  const char *string,
68  vrna_param_t *P);
69 
88 PRIVATE INLINE FLT_OR_DBL
89 exp_E_Hairpin( int u,
90  int type,
91  short si1,
92  short sj1,
93  const char *string,
94  vrna_exp_param_t *P);
95 
96 
97 /*
98 #################################
99 # BEGIN OF FUNCTION DEFINITIONS #
100 #################################
101 */
102 
103 PRIVATE INLINE int
104 E_Hairpin(int size,
105  int type,
106  int si1,
107  int sj1,
108  const char *string,
109  vrna_param_t *P){
110 
111  int energy;
112 
113  if(size <= 30)
114  energy = P->hairpin[size];
115  else
116  energy = P->hairpin[30] + (int)(P->lxc*log((size)/30.));
117 
118  if(size < 3) return energy; /* should only be the case when folding alignments */
119 
120  if(P->model_details.special_hp){
121  if(size == 4){ /* check for tetraloop bonus */
122  char tl[7]={0}, *ts;
123  strncpy(tl, string, 6);
124  if ((ts=strstr(P->Tetraloops, tl)))
125  return (P->Tetraloop_E[(ts - P->Tetraloops)/7]);
126  }
127  else if(size == 6){
128  char tl[9]={0}, *ts;
129  strncpy(tl, string, 8);
130  if ((ts=strstr(P->Hexaloops, tl)))
131  return (energy = P->Hexaloop_E[(ts - P->Hexaloops)/9]);
132  }
133  else if(size == 3){
134  char tl[6]={0,0,0,0,0,0}, *ts;
135  strncpy(tl, string, 5);
136  if ((ts=strstr(P->Triloops, tl))) {
137  return (P->Triloop_E[(ts - P->Triloops)/6]);
138  }
139  return (energy + (type>2 ? P->TerminalAU : 0));
140  }
141  }
142  energy += P->mismatchH[type][si1][sj1];
143 
144  return energy;
145 }
146 
164 int
166  int i,
167  int j);
168 
177 int
179  int i,
180  int j);
181 
188 int
190  int i,
191  int j);
192 
206 int
208  int i,
209  int j);
210 
211 /*
212 *************************************
213 * Partition function variants below *
214 *************************************
215 */
216 
217 PRIVATE INLINE FLT_OR_DBL
219  int type,
220  short si1,
221  short sj1,
222  const char *string,
223  vrna_exp_param_t *P){
224 
225  double q, kT;
226  kT = P->kT; /* kT in cal/mol */
227 
228  if(u <= 30)
229  q = P->exphairpin[u];
230  else
231  q = P->exphairpin[30] * exp( -(P->lxc*log( u/30.))*10./kT);
232 
233  if(u < 3) return (FLT_OR_DBL)q; /* should only be the case when folding alignments */
234 
235  if(P->model_details.special_hp){
236  if(u==4){
237  char tl[7]={0,0,0,0,0,0,0}, *ts;
238  strncpy(tl, string, 6);
239  if ((ts=strstr(P->Tetraloops, tl))){
240  if(type != 7)
241  return (FLT_OR_DBL)(P->exptetra[(ts-P->Tetraloops)/7]);
242  else
243  q *= P->exptetra[(ts-P->Tetraloops)/7];
244  }
245  }
246  else if(u==6){
247  char tl[9]={0,0,0,0,0,0,0,0,0}, *ts;
248  strncpy(tl, string, 8);
249  if ((ts=strstr(P->Hexaloops, tl)))
250  return (FLT_OR_DBL)(P->exphex[(ts-P->Hexaloops)/9]);
251  }
252  else if(u==3){
253  char tl[6]={0,0,0,0,0,0}, *ts;
254  strncpy(tl, string, 5);
255  if ((ts=strstr(P->Triloops, tl)))
256  return (FLT_OR_DBL)(P->exptri[(ts-P->Triloops)/6]);
257  if (type>2)
258  return (FLT_OR_DBL)(q * P->expTermAU);
259  else
260  return (FLT_OR_DBL)q;
261  }
262  }
263  q *= P->expmismatchH[type][si1][sj1];
264 
265  return (FLT_OR_DBL)q;
266 }
267 
268 
280  int i,
281  int j);
282 
290 int
292  int i,
293  int j,
294  int en,
295  vrna_bp_stack_t *bp_stack,
296  int *stack_count);
297 
303 #endif
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:104
FLT_OR_DBL vrna_exp_E_hp_loop(vrna_fold_compound_t *vc, int i, int j)
High-Level function for hairpin loop energy evaluation (partition function variant) ...
vrna_md_t model_details
Model details to be used in the recursions.
Definition: params.h:93
vrna_md_t model_details
Model details to be used in the recursions.
Definition: params.h:149
double FLT_OR_DBL
Typename for floating point number in partition function computations.
Definition: data_structures.h:48
The most basic data structure required by many functions throughout the RNAlib.
Definition: data_structures.h:454
The datastructure that contains temperature scaled energy parameters.
Definition: params.h:55
General utility- and helper-functions used throughout the ViennaRNA Package.
Various data structures and pre-processor macros.
int vrna_eval_hp_loop(vrna_fold_compound_t *vc, int i, int j)
Evaluate free energy of a hairpin loop.
PRIVATE FLT_OR_DBL 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:218
Functions to deal with sets of energy parameters.
The data structure that contains temperature scaled Boltzmann weights of the energy parameters...
Definition: params.h:99
int vrna_BT_hp_loop(vrna_fold_compound_t *vc, int i, int j, int en, vrna_bp_stack_t *bp_stack, int *stack_count)
Backtrack a hairpin loop closed by .
int special_hp
Include special hairpin contributions for tri, tetra and hexaloops.
Definition: model.h:218
int vrna_E_ext_hp_loop(vrna_fold_compound_t *vc, int i, int j)
Evaluate the free energy of an exterior hairpin loop and consider possible hard constraints.
int vrna_E_hp_loop(vrna_fold_compound_t *vc, int i, int j)
Evaluate the free energy of a hairpin loop and consider hard constraints if they apply.
int vrna_eval_ext_hp_loop(vrna_fold_compound_t *vc, int i, int j)
Evaluate free energy of an exterior hairpin loop.
Base pair stack element.
Definition: data_structures.h:222