RNAlib-2.4.8
hairpin.h
Go to the documentation of this file.
1 #ifndef VIENNA_RNA_PACKAGE_LOOPS_HAIRPIN_H
2 #define VIENNA_RNA_PACKAGE_LOOPS_HAIRPIN_H
3 
4 #include <math.h>
5 #include <string.h>
9 
10 #ifdef VRNA_WARN_DEPRECATED
11 # if defined(DEPRECATED)
12 # undef DEPRECATED
13 # endif
14 # if defined(__clang__)
15 # define DEPRECATED(func, msg) func __attribute__ ((deprecated("", msg)))
16 # elif defined(__GNUC__)
17 # define DEPRECATED(func, msg) func __attribute__ ((deprecated(msg)))
18 # else
19 # define DEPRECATED(func, msg) func
20 # endif
21 #else
22 # define DEPRECATED(func, msg) func
23 #endif
24 
25 #ifdef __GNUC__
26 # define INLINE inline
27 #else
28 # define INLINE
29 #endif
30 
69 int
71  int i,
72  int j);
73 
74 
83 int
85  int i,
86  int j);
87 
88 
92 int
94  int i,
95  int j);
96 
97 
109 int
111  int i,
112  int j);
113 
114 
147 PRIVATE INLINE int
148 E_Hairpin(int size,
149  int type,
150  int si1,
151  int sj1,
152  const char *string,
153  vrna_param_t *P)
154 {
155  int energy;
156 
157  if (size <= 30)
158  energy = P->hairpin[size];
159  else
160  energy = P->hairpin[30] + (int)(P->lxc * log((size) / 30.));
161 
162  if (size < 3)
163  return energy; /* should only be the case when folding alignments */
164 
165  if ((string) && (P->model_details.special_hp)) {
166  if (size == 4) {
167  /* check for tetraloop bonus */
168  char tl[7] = {
169  0
170  }, *ts;
171  memcpy(tl, string, sizeof(char) * 6);
172  tl[6] = '\0';
173  if ((ts = strstr(P->Tetraloops, tl)))
174  return P->Tetraloop_E[(ts - P->Tetraloops) / 7];
175  } else if (size == 6) {
176  char tl[9] = {
177  0
178  }, *ts;
179  memcpy(tl, string, sizeof(char) * 8);
180  tl[8] = '\0';
181  if ((ts = strstr(P->Hexaloops, tl)))
182  return energy = P->Hexaloop_E[(ts - P->Hexaloops) / 9];
183  } else if (size == 3) {
184  char tl[6] = {
185  0
186  }, *ts;
187  memcpy(tl, string, sizeof(char) * 5);
188  tl[5] = '\0';
189  if ((ts = strstr(P->Triloops, tl)))
190  return P->Triloop_E[(ts - P->Triloops) / 6];
191 
192  return energy + (type > 2 ? P->TerminalAU : 0);
193  }
194  }
195 
196  energy += P->mismatchH[type][si1][sj1];
197 
198  return energy;
199 }
200 
201 
202 /* End basic interface */
230 PRIVATE INLINE FLT_OR_DBL
232  int type,
233  short si1,
234  short sj1,
235  const char *string,
236  vrna_exp_param_t *P)
237 {
238  double q, kT;
239 
240  kT = P->kT; /* kT in cal/mol */
241 
242  if (u <= 30)
243  q = P->exphairpin[u];
244  else
245  q = P->exphairpin[30] * exp(-(P->lxc * log(u / 30.)) * 10. / kT);
246 
247  if (u < 3)
248  return (FLT_OR_DBL)q; /* should only be the case when folding alignments */
249 
250  if ((string) && (P->model_details.special_hp)) {
251  if (u == 4) {
252  char tl[7] = {
253  0
254  }, *ts;
255  memcpy(tl, string, sizeof(char) * 6);
256  tl[6] = '\0';
257  if ((ts = strstr(P->Tetraloops, tl))) {
258  if (type != 7)
259  return (FLT_OR_DBL)(P->exptetra[(ts - P->Tetraloops) / 7]);
260  else
261  q *= P->exptetra[(ts - P->Tetraloops) / 7];
262  }
263  } else if (u == 6) {
264  char tl[9] = {
265  0
266  }, *ts;
267  memcpy(tl, string, sizeof(char) * 8);
268  tl[8] = '\0';
269  if ((ts = strstr(P->Hexaloops, tl)))
270  return (FLT_OR_DBL)(P->exphex[(ts - P->Hexaloops) / 9]);
271  } else if (u == 3) {
272  char tl[6] = {
273  0
274  }, *ts;
275  memcpy(tl, string, sizeof(char) * 5);
276  tl[5] = '\0';
277  if ((ts = strstr(P->Triloops, tl)))
278  return (FLT_OR_DBL)(P->exptri[(ts - P->Triloops) / 6]);
279 
280  if (type > 2)
281  return (FLT_OR_DBL)(q * P->expTermAU);
282  else
283  return (FLT_OR_DBL)q;
284  }
285  }
286 
287  q *= P->expmismatchH[type][si1][sj1];
288 
289  return (FLT_OR_DBL)q;
290 }
291 
292 
304  int i,
305  int j);
306 
307 
308 /* End partition function interface */
329 int
331  int i,
332  int j,
333  int en,
334  vrna_bp_stack_t *bp_stack,
335  int *stack_count);
336 
337 
342 #ifndef VRNA_DISABLE_BACKWARD_COMPATIBILITY
343 
353 #endif
354 
355 #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.h:148
int special_hp
Include special hairpin contributions for tri, tetra and hexaloops.
Definition: model.h:204
int vrna_E_ext_hp_loop(vrna_fold_compound_t *fc, int i, int j)
Evaluate the free energy of an exterior hairpin loop and consider possible hard constraints.
int vrna_BT_hp_loop(vrna_fold_compound_t *fc, int i, int j, int en, vrna_bp_stack_t *bp_stack, int *stack_count)
Backtrack a hairpin loop closed by .
vrna_md_t model_details
Model details to be used in the recursions.
Definition: basic.h:94
vrna_md_t model_details
Model details to be used in the recursions.
Definition: basic.h:151
double FLT_OR_DBL
Typename for floating point number in partition function computations.
Definition: basic.h:43
The most basic data structure required by many functions throughout the RNAlib.
Definition: fold_compound.h:132
int vrna_E_hp_loop(vrna_fold_compound_t *fc, int i, int j)
Evaluate the free energy of a hairpin loop and consider hard constraints if they apply.
The datastructure that contains temperature scaled energy parameters.
Definition: basic.h:56
Various data structures and pre-processor macros.
FLT_OR_DBL vrna_exp_E_hp_loop(vrna_fold_compound_t *fc, int i, int j)
High-Level function for hairpin loop energy evaluation (partition function variant) ...
The data structure that contains temperature scaled Boltzmann weights of the energy parameters...
Definition: basic.h:101
int vrna_eval_ext_hp_loop(vrna_fold_compound_t *fc, int i, int j)
Evaluate free energy of an exterior hairpin loop.
int vrna_eval_hp_loop(vrna_fold_compound_t *fc, int i, int j)
Evaluate free energy of a hairpin loop.
Base pair stack element.
Definition: basic.h:142
Functions to deal with sets of energy parameters.
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.h:231
General utility- and helper-functions used throughout the ViennaRNA Package.