RNAlib-2.6.0b
 
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
149PRIVATE INLINE int
150E_Hairpin(int size,
151 int type,
152 int si1,
153 int sj1,
154 const char *string,
155 vrna_param_t *P)
156{
157 int energy, salt_correction;
158
159 salt_correction = 0;
160
162 if (size<=MAXLOOP)
163 salt_correction = P->SaltLoop[size+1];
164 else
165 salt_correction = vrna_salt_loop_int(size+1, P->model_details.salt, P->temperature+K0);
166 }
167
168 if (size <= 30)
169 energy = P->hairpin[size];
170 else
171 energy = P->hairpin[30] + (int)(P->lxc * log((size) / 30.));
172
173 energy += salt_correction;
174
175 if (size < 3)
176 return energy; /* should only be the case when folding alignments */
177
178 if ((string) && (P->model_details.special_hp)) {
179 if (size == 4) {
180 /* check for tetraloop bonus */
181 char tl[7] = {
182 0
183 }, *ts;
184 memcpy(tl, string, sizeof(char) * 6);
185 tl[6] = '\0';
186 if ((ts = strstr(P->Tetraloops, tl)))
187 return P->Tetraloop_E[(ts - P->Tetraloops) / 7] + salt_correction;
188 } else if (size == 6) {
189 char tl[9] = {
190 0
191 }, *ts;
192 memcpy(tl, string, sizeof(char) * 8);
193 tl[8] = '\0';
194 if ((ts = strstr(P->Hexaloops, tl)))
195 return P->Hexaloop_E[(ts - P->Hexaloops) / 9] + salt_correction;
196 } else if (size == 3) {
197 char tl[6] = {
198 0
199 }, *ts;
200 memcpy(tl, string, sizeof(char) * 5);
201 tl[5] = '\0';
202 if ((ts = strstr(P->Triloops, tl)))
203 return P->Triloop_E[(ts - P->Triloops) / 6] + salt_correction;
204
205 return energy + (type > 2 ? P->TerminalAU : 0);
206 }
207 }
208
209 energy += P->mismatchH[type][si1][sj1];
210
211 return energy;
212}
213
214
215/* End basic interface */
243PRIVATE INLINE FLT_OR_DBL
245 int type,
246 short si1,
247 short sj1,
248 const char *string,
250{
251 double q, kT, salt_correction;
252
253 kT = P->kT; /* kT in cal/mol */
254 salt_correction = 1.;
255
257 if (u<=MAXLOOP)
258 salt_correction = P->expSaltLoop[u+1];
259 else
260 salt_correction = exp(-vrna_salt_loop_int(u+1, P->model_details.salt, P->temperature+K0) * 10. / kT);
261 }
262
263 if (u <= 30)
264 q = P->exphairpin[u];
265 else
266 q = P->exphairpin[30] * exp(-(P->lxc * log(u / 30.)) * 10. / kT);
267
268 q *= salt_correction;
269
270 if (u < 3)
271 return (FLT_OR_DBL)q; /* should only be the case when folding alignments */
272
273 if ((string) && (P->model_details.special_hp)) {
274 if (u == 4) {
275 char tl[7] = {
276 0
277 }, *ts;
278 memcpy(tl, string, sizeof(char) * 6);
279 tl[6] = '\0';
280 if ((ts = strstr(P->Tetraloops, tl))) {
281 if (type != 7)
282 return (FLT_OR_DBL)(P->exptetra[(ts - P->Tetraloops) / 7] * salt_correction);
283 else
284 q *= P->exptetra[(ts - P->Tetraloops) / 7];
285 }
286 } else if (u == 6) {
287 char tl[9] = {
288 0
289 }, *ts;
290 memcpy(tl, string, sizeof(char) * 8);
291 tl[8] = '\0';
292 if ((ts = strstr(P->Hexaloops, tl)))
293 return (FLT_OR_DBL)(P->exphex[(ts - P->Hexaloops) / 9] * salt_correction);
294 } else if (u == 3) {
295 char tl[6] = {
296 0
297 }, *ts;
298 memcpy(tl, string, sizeof(char) * 5);
299 tl[5] = '\0';
300 if ((ts = strstr(P->Triloops, tl)))
301 return (FLT_OR_DBL)(P->exptri[(ts - P->Triloops) / 6] * salt_correction);
302
303 if (type > 2)
304 return (FLT_OR_DBL)(q * P->expTermAU);
305 else
306 return (FLT_OR_DBL)q;
307 }
308 }
309
310 q *= P->expmismatchH[type][si1][sj1];
311
312 return (FLT_OR_DBL)q;
313}
314
315
327 int i,
328 int j);
329
330
331/* End partition function interface */
352int
354 int i,
355 int j,
356 int en,
357 vrna_bp_stack_t *bp_stack,
358 int *stack_count);
359
360
365#ifndef VRNA_DISABLE_BACKWARD_COMPATIBILITY
366
376#endif
377
378#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)
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:244
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:150
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:156
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 .
double salt
Salt (monovalent) concentration (M) in buffer.
Definition: model.h:260
int special_hp
Include special hairpin contributions for tri, tetra and hexaloops.
Definition: model.h:231
#define VRNA_MODEL_DEFAULT_SALT
Default model salt concentration (M)
Definition: model.h:162
Functions to deal with sets of energy parameters.
Functions to compute salt correction.
General utility- and helper-functions used throughout the ViennaRNA Package.