RNAlib-2.2.5
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 
88 PRIVATE INLINE FLT_OR_DBL
89 exp_E_Hairpin( int u,
90  int type,
91  short si1,
92  short sj1,
93  const char *string,
94  vrna_exp_param_t *P);
95 
96 
97 int
99  int i,
100  int j);
101 
102 int
104  int i,
105  int j);
106 
107 /*
108 #################################
109 # BEGIN OF FUNCTION DEFINITIONS #
110 #################################
111 */
112 
113 PRIVATE INLINE int
114 E_Hairpin(int size,
115  int type,
116  int si1,
117  int sj1,
118  const char *string,
119  vrna_param_t *P){
120 
121  int energy;
122 
123  if(size <= 30)
124  energy = P->hairpin[size];
125  else
126  energy = P->hairpin[30] + (int)(P->lxc*log((size)/30.));
127 
128  if(size < 3) return energy; /* should only be the case when folding alignments */
129 
130  if(P->model_details.special_hp){
131  if(size == 4){ /* check for tetraloop bonus */
132  char tl[7]={0}, *ts;
133  strncpy(tl, string, 6);
134  if ((ts=strstr(P->Tetraloops, tl)))
135  return (P->Tetraloop_E[(ts - P->Tetraloops)/7]);
136  }
137  else if(size == 6){
138  char tl[9]={0}, *ts;
139  strncpy(tl, string, 8);
140  if ((ts=strstr(P->Hexaloops, tl)))
141  return (energy = P->Hexaloop_E[(ts - P->Hexaloops)/9]);
142  }
143  else if(size == 3){
144  char tl[6]={0,0,0,0,0,0}, *ts;
145  strncpy(tl, string, 5);
146  if ((ts=strstr(P->Triloops, tl))) {
147  return (P->Triloop_E[(ts - P->Triloops)/6]);
148  }
149  return (energy + (type>2 ? P->TerminalAU : 0));
150  }
151  }
152  energy += P->mismatchH[type][si1][sj1];
153 
154  return energy;
155 }
156 
165 int
167  int i,
168  int j);
169 
178 int
180  int i,
181  int j);
182 
189 int
191  int i,
192  int j);
193 
207 int
209  int i,
210  int j);
211 
212 /*
213 *************************************
214 * Partition function variants below *
215 *************************************
216 */
217 
218 PRIVATE INLINE FLT_OR_DBL
220  int type,
221  short si1,
222  short sj1,
223  const char *string,
224  vrna_exp_param_t *P){
225 
226  double q, kT;
227  kT = P->kT; /* kT in cal/mol */
228 
229  if(u <= 30)
230  q = P->exphairpin[u];
231  else
232  q = P->exphairpin[30] * exp( -(P->lxc*log( u/30.))*10./kT);
233 
234  if(u < 3) return (FLT_OR_DBL)q; /* should only be the case when folding alignments */
235 
236  if(P->model_details.special_hp){
237  if(u==4){
238  char tl[7]={0,0,0,0,0,0,0}, *ts;
239  strncpy(tl, string, 6);
240  if ((ts=strstr(P->Tetraloops, tl))){
241  if(type != 7)
242  return (FLT_OR_DBL)(P->exptetra[(ts-P->Tetraloops)/7]);
243  else
244  q *= P->exptetra[(ts-P->Tetraloops)/7];
245  }
246  }
247  else if(u==6){
248  char tl[9]={0,0,0,0,0,0,0,0,0}, *ts;
249  strncpy(tl, string, 8);
250  if ((ts=strstr(P->Hexaloops, tl)))
251  return (FLT_OR_DBL)(P->exphex[(ts-P->Hexaloops)/9]);
252  }
253  else if(u==3){
254  char tl[6]={0,0,0,0,0,0}, *ts;
255  strncpy(tl, string, 5);
256  if ((ts=strstr(P->Triloops, tl)))
257  return (FLT_OR_DBL)(P->exptri[(ts-P->Triloops)/6]);
258  if (type>2)
259  return (FLT_OR_DBL)(q * P->expTermAU);
260  else
261  return (FLT_OR_DBL)q;
262  }
263  }
264  q *= P->expmismatchH[type][si1][sj1];
265 
266  return (FLT_OR_DBL)q;
267 }
268 
269 
281  int i,
282  int j);
283 
291 int
293  int i,
294  int j,
295  int en,
296  vrna_bp_stack_t *bp_stack,
297  int *stack_count);
298 
304 #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:114
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) ...
vrna_md_t model_details
Model details to be used in the recursions.
Definition: params.h:93
vrna_md_t model_details
Model details to be used in the recursions.
Definition: params.h:149
double FLT_OR_DBL
Typename for floating point number in partition function computations.
Definition: data_structures.h:44
The most basic data structure required by many functions throughout the RNAlib.
Definition: data_structures.h:397
The datastructure that contains temperature scaled energy parameters.
Definition: params.h:55
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:219
Functions to deal with sets of energy parameters.
The datastructure that contains temperature scaled Boltzmann weights of the energy parameters...
Definition: params.h:99
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 special_hp
Include special hairpin contributions for tri, tetra and hexaloops.
Definition: model.h:217
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 possible hard constraints.
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:199