RNAlib-2.4.4
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 
70 
89 PRIVATE INLINE FLT_OR_DBL
90 exp_E_Hairpin(int u,
91  int type,
92  short si1,
93  short sj1,
94  const char *string,
95  vrna_exp_param_t *P);
96 
97 
98 /*
99  #################################
100  # BEGIN OF FUNCTION DEFINITIONS #
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)
119  return energy; /* should only be the case when folding alignments */
120 
121  if (P->model_details.special_hp) {
122  if (size == 4) {
123  /* check for tetraloop bonus */
124  char tl[7] = {
125  0
126  }, *ts;
127  strncpy(tl, string, 6);
128  if ((ts = strstr(P->Tetraloops, tl)))
129  return P->Tetraloop_E[(ts - P->Tetraloops) / 7];
130  } else if (size == 6) {
131  char tl[9] = {
132  0
133  }, *ts;
134  strncpy(tl, string, 8);
135  if ((ts = strstr(P->Hexaloops, tl)))
136  return energy = P->Hexaloop_E[(ts - P->Hexaloops) / 9];
137  } else if (size == 3) {
138  char tl[6] = {
139  0, 0, 0, 0, 0, 0
140  }, *ts;
141  strncpy(tl, string, 5);
142  if ((ts = strstr(P->Triloops, tl)))
143  return P->Triloop_E[(ts - P->Triloops) / 6];
144 
145  return energy + (type > 2 ? P->TerminalAU : 0);
146  }
147  }
148 
149  energy += P->mismatchH[type][si1][sj1];
150 
151  return energy;
152 }
153 
154 
172 int
174  int i,
175  int j);
176 
177 
186 int
188  int i,
189  int j);
190 
191 
198 int
200  int i,
201  int j);
202 
203 
217 int
219  int i,
220  int j);
221 
222 
223 /*
224  *************************************
225  * Partition function variants below *
226  *************************************
227  */
228 PRIVATE INLINE FLT_OR_DBL
230  int type,
231  short si1,
232  short sj1,
233  const char *string,
234  vrna_exp_param_t *P)
235 {
236  double q, kT;
237 
238  kT = P->kT; /* kT in cal/mol */
239 
240  if (u <= 30)
241  q = P->exphairpin[u];
242  else
243  q = P->exphairpin[30] * exp(-(P->lxc * log(u / 30.)) * 10. / kT);
244 
245  if (u < 3)
246  return (FLT_OR_DBL)q; /* should only be the case when folding alignments */
247 
248  if (P->model_details.special_hp) {
249  if (u == 4) {
250  char tl[7] = {
251  0, 0, 0, 0, 0, 0, 0
252  }, *ts;
253  strncpy(tl, string, 6);
254  if ((ts = strstr(P->Tetraloops, tl))) {
255  if (type != 7)
256  return (FLT_OR_DBL)(P->exptetra[(ts - P->Tetraloops) / 7]);
257  else
258  q *= P->exptetra[(ts - P->Tetraloops) / 7];
259  }
260  } else if (u == 6) {
261  char tl[9] = {
262  0, 0, 0, 0, 0, 0, 0, 0, 0
263  }, *ts;
264  strncpy(tl, string, 8);
265  if ((ts = strstr(P->Hexaloops, tl)))
266  return (FLT_OR_DBL)(P->exphex[(ts - P->Hexaloops) / 9]);
267  } else if (u == 3) {
268  char tl[6] = {
269  0, 0, 0, 0, 0, 0
270  }, *ts;
271  strncpy(tl, string, 5);
272  if ((ts = strstr(P->Triloops, tl)))
273  return (FLT_OR_DBL)(P->exptri[(ts - P->Triloops) / 6]);
274 
275  if (type > 2)
276  return (FLT_OR_DBL)(q * P->expTermAU);
277  else
278  return (FLT_OR_DBL)q;
279  }
280  }
281 
282  q *= P->expmismatchH[type][si1][sj1];
283 
284  return (FLT_OR_DBL)q;
285 }
286 
287 
299  int i,
300  int j);
301 
302 
310 int
312  int i,
313  int j,
314  int en,
315  vrna_bp_stack_t *bp_stack,
316  int *stack_count);
317 
318 
324 #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) ...
int special_hp
Include special hairpin contributions for tri, tetra and hexaloops.
Definition: model.h:204
vrna_md_t model_details
Model details to be used in the recursions.
Definition: params.h:94
vrna_md_t model_details
Model details to be used in the recursions.
Definition: params.h:151
double FLT_OR_DBL
Typename for floating point number in partition function computations.
Definition: data_structures.h:43
The most basic data structure required by many functions throughout the RNAlib.
Definition: fold_compound.h:131
The datastructure that contains temperature scaled energy parameters.
Definition: params.h:56
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:229
Functions to deal with sets of energy parameters.
The data structure that contains temperature scaled Boltzmann weights of the energy parameters...
Definition: params.h:101
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 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:141