RNAlib-2.4.14
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>
10 
11 #ifdef VRNA_WARN_DEPRECATED
12 # if defined(DEPRECATED)
13 # undef DEPRECATED
14 # endif
15 # if defined(__clang__)
16 # define DEPRECATED(func, msg) func __attribute__ ((deprecated("", msg)))
17 # elif defined(__GNUC__)
18 # define DEPRECATED(func, msg) func __attribute__ ((deprecated(msg)))
19 # else
20 # define DEPRECATED(func, msg) func
21 # endif
22 #else
23 # define DEPRECATED(func, msg) func
24 #endif
25 
26 #ifdef __GNUC__
27 # define INLINE inline
28 #else
29 # define INLINE
30 #endif
31 
70 int
72  int i,
73  int j);
74 
75 
84 int
86  int i,
87  int j);
88 
89 
93 int
95  int i,
96  int j);
97 
98 
110 int
112  int i,
113  int j);
114 
115 
148 PRIVATE INLINE int
149 E_Hairpin(int size,
150  int type,
151  int si1,
152  int sj1,
153  const char *string,
154  vrna_param_t *P)
155 {
156  int energy;
157 
158  if (size <= 30)
159  energy = P->hairpin[size];
160  else
161  energy = P->hairpin[30] + (int)(P->lxc * log((size) / 30.));
162 
163  if (size < 3)
164  return energy; /* should only be the case when folding alignments */
165 
166  if ((string) && (P->model_details.special_hp)) {
167  if (size == 4) {
168  /* check for tetraloop bonus */
169  char tl[7] = {
170  0
171  }, *ts;
172  memcpy(tl, string, sizeof(char) * 6);
173  tl[6] = '\0';
174  if ((ts = strstr(P->Tetraloops, tl)))
175  return P->Tetraloop_E[(ts - P->Tetraloops) / 7];
176  } else if (size == 6) {
177  char tl[9] = {
178  0
179  }, *ts;
180  memcpy(tl, string, sizeof(char) * 8);
181  tl[8] = '\0';
182  if ((ts = strstr(P->Hexaloops, tl)))
183  return energy = P->Hexaloop_E[(ts - P->Hexaloops) / 9];
184  } else if (size == 3) {
185  char tl[6] = {
186  0
187  }, *ts;
188  memcpy(tl, string, sizeof(char) * 5);
189  tl[5] = '\0';
190  if ((ts = strstr(P->Triloops, tl)))
191  return P->Triloop_E[(ts - P->Triloops) / 6];
192 
193  return energy + (type > 2 ? P->TerminalAU : 0);
194  }
195  }
196 
197  energy += P->mismatchH[type][si1][sj1];
198 
199  return energy;
200 }
201 
202 
203 /* End basic interface */
231 PRIVATE INLINE FLT_OR_DBL
233  int type,
234  short si1,
235  short sj1,
236  const char *string,
237  vrna_exp_param_t *P)
238 {
239  double q, kT;
240 
241  kT = P->kT; /* kT in cal/mol */
242 
243  if (u <= 30)
244  q = P->exphairpin[u];
245  else
246  q = P->exphairpin[30] * exp(-(P->lxc * log(u / 30.)) * 10. / kT);
247 
248  if (u < 3)
249  return (FLT_OR_DBL)q; /* should only be the case when folding alignments */
250 
251  if ((string) && (P->model_details.special_hp)) {
252  if (u == 4) {
253  char tl[7] = {
254  0
255  }, *ts;
256  memcpy(tl, string, sizeof(char) * 6);
257  tl[6] = '\0';
258  if ((ts = strstr(P->Tetraloops, tl))) {
259  if (type != 7)
260  return (FLT_OR_DBL)(P->exptetra[(ts - P->Tetraloops) / 7]);
261  else
262  q *= P->exptetra[(ts - P->Tetraloops) / 7];
263  }
264  } else if (u == 6) {
265  char tl[9] = {
266  0
267  }, *ts;
268  memcpy(tl, string, sizeof(char) * 8);
269  tl[8] = '\0';
270  if ((ts = strstr(P->Hexaloops, tl)))
271  return (FLT_OR_DBL)(P->exphex[(ts - P->Hexaloops) / 9]);
272  } else if (u == 3) {
273  char tl[6] = {
274  0
275  }, *ts;
276  memcpy(tl, string, sizeof(char) * 5);
277  tl[5] = '\0';
278  if ((ts = strstr(P->Triloops, tl)))
279  return (FLT_OR_DBL)(P->exptri[(ts - P->Triloops) / 6]);
280 
281  if (type > 2)
282  return (FLT_OR_DBL)(q * P->expTermAU);
283  else
284  return (FLT_OR_DBL)q;
285  }
286  }
287 
288  q *= P->expmismatchH[type][si1][sj1];
289 
290  return (FLT_OR_DBL)q;
291 }
292 
293 
305  int i,
306  int j);
307 
308 
309 /* End partition function interface */
330 int
332  int i,
333  int j,
334  int en,
335  vrna_bp_stack_t *bp_stack,
336  int *stack_count);
337 
338 
343 #ifndef VRNA_DISABLE_BACKWARD_COMPATIBILITY
344 
354 #endif
355 
356 #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:149
int special_hp
Include special hairpin contributions for tri, tetra and hexaloops.
Definition: model.h:208
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:96
vrna_md_t model_details
Model details to be used in the recursions.
Definition: basic.h:154
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:57
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:103
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:143
Functions to deal with sets of energy parameters.
The Basic Fold Compound API.
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:232
General utility- and helper-functions used throughout the ViennaRNA Package.