RNAlib-2.6.3
 
Loading...
Searching...
No Matches
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>
11
12#ifdef VRNA_WARN_DEPRECATED
13# if defined(DEPRECATED)
14# undef DEPRECATED
15# endif
16# if defined(__clang__)
17# define DEPRECATED(func, msg) func __attribute__ ((deprecated("", msg)))
18# elif defined(__GNUC__)
19# define DEPRECATED(func, msg) func __attribute__ ((deprecated(msg)))
20# else
21# define DEPRECATED(func, msg) func
22# endif
23#else
24# define DEPRECATED(func, msg) func
25#endif
26
27#ifdef __GNUC__
28# define INLINE inline
29#else
30# define INLINE
31#endif
32
71int
73 int i,
74 int j);
75
76
85int
87 int i,
88 int j);
89
90
94int
96 int i,
97 int j);
98
99
111int
113 int i,
114 int j);
115
116
151PRIVATE INLINE int
152E_Hairpin(int size,
153 int type,
154 int si1,
155 int sj1,
156 const char *string,
157 vrna_param_t *P)
158{
159 int energy, salt_correction;
160
161 salt_correction = 0;
162
164 if (size<=MAXLOOP)
165 salt_correction = P->SaltLoop[size+1];
166 else
167 salt_correction = vrna_salt_loop_int(size+1, P->model_details.salt, P->temperature+K0, P->model_details.backbone_length);
168 }
169
170 if (size <= 30)
171 energy = P->hairpin[size];
172 else
173 energy = P->hairpin[30] + (int)(P->lxc * log((size) / 30.));
174
175 energy += salt_correction;
176
177 if (size < 3)
178 return energy; /* should only be the case when folding alignments */
179
180 if ((string) && (P->model_details.special_hp)) {
181 if (size == 4) {
182 /* check for tetraloop bonus */
183 char tl[7] = {
184 0
185 }, *ts;
186 memcpy(tl, string, sizeof(char) * 6);
187 tl[6] = '\0';
188 if ((ts = strstr(P->Tetraloops, tl)))
189 return P->Tetraloop_E[(ts - P->Tetraloops) / 7] + salt_correction;
190 } else if (size == 6) {
191 char tl[9] = {
192 0
193 }, *ts;
194 memcpy(tl, string, sizeof(char) * 8);
195 tl[8] = '\0';
196 if ((ts = strstr(P->Hexaloops, tl)))
197 return P->Hexaloop_E[(ts - P->Hexaloops) / 9] + salt_correction;
198 } else if (size == 3) {
199 char tl[6] = {
200 0
201 }, *ts;
202 memcpy(tl, string, sizeof(char) * 5);
203 tl[5] = '\0';
204 if ((ts = strstr(P->Triloops, tl)))
205 return P->Triloop_E[(ts - P->Triloops) / 6] + salt_correction;
206
207 return energy + (type > 2 ? P->TerminalAU : 0);
208 }
209 }
210
211 energy += P->mismatchH[type][si1][sj1];
212
213 return energy;
214}
215
216
217/* End basic interface */
245PRIVATE INLINE FLT_OR_DBL
247 int type,
248 short si1,
249 short sj1,
250 const char *string,
252{
253 double q, kT, salt_correction;
254
255 kT = P->kT; /* kT in cal/mol */
256 salt_correction = 1.;
257
259 if (u<=MAXLOOP)
260 salt_correction = P->expSaltLoop[u+1];
261 else
262 salt_correction = exp(-vrna_salt_loop_int(u+1, P->model_details.salt, P->temperature+K0, P->model_details.backbone_length) * 10. / kT);
263 }
264
265 if (u <= 30)
266 q = P->exphairpin[u];
267 else
268 q = P->exphairpin[30] * exp(-(P->lxc * log(u / 30.)) * 10. / kT);
269
270 q *= salt_correction;
271
272 if (u < 3)
273 return (FLT_OR_DBL)q; /* should only be the case when folding alignments */
274
275 if ((string) && (P->model_details.special_hp)) {
276 if (u == 4) {
277 char tl[7] = {
278 0
279 }, *ts;
280 memcpy(tl, string, sizeof(char) * 6);
281 tl[6] = '\0';
282 if ((ts = strstr(P->Tetraloops, tl))) {
283 if (type != 7)
284 return (FLT_OR_DBL)(P->exptetra[(ts - P->Tetraloops) / 7] * salt_correction);
285 else
286 q *= P->exptetra[(ts - P->Tetraloops) / 7];
287 }
288 } else if (u == 6) {
289 char tl[9] = {
290 0
291 }, *ts;
292 memcpy(tl, string, sizeof(char) * 8);
293 tl[8] = '\0';
294 if ((ts = strstr(P->Hexaloops, tl)))
295 return (FLT_OR_DBL)(P->exphex[(ts - P->Hexaloops) / 9] * salt_correction);
296 } else if (u == 3) {
297 char tl[6] = {
298 0
299 }, *ts;
300 memcpy(tl, string, sizeof(char) * 5);
301 tl[5] = '\0';
302 if ((ts = strstr(P->Triloops, tl)))
303 return (FLT_OR_DBL)(P->exptri[(ts - P->Triloops) / 6] * salt_correction);
304
305 if (type > 2)
306 return (FLT_OR_DBL)(q * P->expTermAU);
307 else
308 return (FLT_OR_DBL)q;
309 }
310 }
311
312 q *= P->expmismatchH[type][si1][sj1];
313
314 return (FLT_OR_DBL)q;
315}
316
317
329 int i,
330 int j);
331
332
333/* End partition function interface */
354int
356 int i,
357 int j,
358 int en,
359 vrna_bp_stack_t *bp_stack,
360 int *stack_count);
361
362
367#ifndef VRNA_DISABLE_BACKWARD_COMPATIBILITY
368
378#endif
379
380#endif
#define MAXLOOP
Definition constants.h:29
Various data structures and pre-processor macros.
The Basic Fold Compound API.
double FLT_OR_DBL
Typename for floating point number in partition function computations.
Definition basic.h:43
Base pair stack element.
Definition basic.h:143
double temperature
Temperature used for loop contribution scaling.
Definition basic.h:153
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:161
double temperature
Temperature used for loop contribution scaling.
Definition basic.h:94
int vrna_salt_loop_int(int L, double salt, double T, double backbonelen)
Get salt correction for a loop at a given salt concentration and temperature.
The data structure that contains temperature scaled Boltzmann weights of the energy parameters.
Definition basic.h:110
The datastructure that contains temperature scaled energy parameters.
Definition basic.h:57
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:246
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.
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_eval_hp_loop(vrna_fold_compound_t *fc, int i, int j)
Evaluate free energy of a hairpin loop.
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)
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:152
int vrna_eval_ext_hp_loop(vrna_fold_compound_t *fc, int i, int j)
Evaluate free energy of an exterior hairpin loop.
The most basic data structure required by many functions throughout the RNAlib.
Definition fold_compound.h:168
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 .
float backbone_length
Definition model.h:312
double salt
Salt (monovalent) concentration (M) in buffer.
Definition model.h:303
int special_hp
Include special hairpin contributions for tri, tetra and hexaloops.
Definition model.h:273
#define VRNA_MODEL_DEFAULT_SALT
Default model salt concentration (M)
Definition model.h:182
Functions to deal with sets of energy parameters.
Functions to compute salt correction.
General utility- and helper-functions used throughout the ViennaRNA Package.