RNAlib-2.2.7
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 
58 PRIVATE INLINE int
59 E_Hairpin(int size,
60  int type,
61  int si1,
62  int sj1,
63  const char *string,
64  vrna_param_t *P);
65 
84 PRIVATE INLINE FLT_OR_DBL
85 exp_E_Hairpin( int u,
86  int type,
87  short si1,
88  short sj1,
89  const char *string,
90  vrna_exp_param_t *P);
91 
92 
93 int
95  int i,
96  int j);
97 
98 int
100  int i,
101  int j);
102 
103 /*
104 #################################
105 # BEGIN OF FUNCTION DEFINITIONS #
106 #################################
107 */
108 
109 PRIVATE INLINE int
110 E_Hairpin(int size,
111  int type,
112  int si1,
113  int sj1,
114  const char *string,
115  vrna_param_t *P){
116 
117  int energy;
118 
119  if(size <= 30)
120  energy = P->hairpin[size];
121  else
122  energy = P->hairpin[30] + (int)(P->lxc*log((size)/30.));
123 
124  if(size < 3) return energy; /* should only be the case when folding alignments */
125 
126  if(P->model_details.special_hp){
127  if(size == 4){ /* check for tetraloop bonus */
128  char tl[7]={0}, *ts;
129  strncpy(tl, string, 6);
130  if ((ts=strstr(P->Tetraloops, tl)))
131  return (P->Tetraloop_E[(ts - P->Tetraloops)/7]);
132  }
133  else if(size == 6){
134  char tl[9]={0}, *ts;
135  strncpy(tl, string, 8);
136  if ((ts=strstr(P->Hexaloops, tl)))
137  return (energy = P->Hexaloop_E[(ts - P->Hexaloops)/9]);
138  }
139  else if(size == 3){
140  char tl[6]={0,0,0,0,0,0}, *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  energy += P->mismatchH[type][si1][sj1];
149 
150  return energy;
151 }
152 
161 int
163  int i,
164  int j);
165 
174 int
176  int i,
177  int j);
178 
185 int
187  int i,
188  int j);
189 
203 int
205  int i,
206  int j);
207 
208 /*
209 *************************************
210 * Partition function variants below *
211 *************************************
212 */
213 
214 PRIVATE INLINE FLT_OR_DBL
216  int type,
217  short si1,
218  short sj1,
219  const char *string,
220  vrna_exp_param_t *P){
221 
222  double q, kT;
223  kT = P->kT; /* kT in cal/mol */
224 
225  if(u <= 30)
226  q = P->exphairpin[u];
227  else
228  q = P->exphairpin[30] * exp( -(P->lxc*log( u/30.))*10./kT);
229 
230  if(u < 3) return (FLT_OR_DBL)q; /* should only be the case when folding alignments */
231 
232  if(P->model_details.special_hp){
233  if(u==4){
234  char tl[7]={0,0,0,0,0,0,0}, *ts;
235  strncpy(tl, string, 6);
236  if ((ts=strstr(P->Tetraloops, tl))){
237  if(type != 7)
238  return (FLT_OR_DBL)(P->exptetra[(ts-P->Tetraloops)/7]);
239  else
240  q *= P->exptetra[(ts-P->Tetraloops)/7];
241  }
242  }
243  else if(u==6){
244  char tl[9]={0,0,0,0,0,0,0,0,0}, *ts;
245  strncpy(tl, string, 8);
246  if ((ts=strstr(P->Hexaloops, tl)))
247  return (FLT_OR_DBL)(P->exphex[(ts-P->Hexaloops)/9]);
248  }
249  else if(u==3){
250  char tl[6]={0,0,0,0,0,0}, *ts;
251  strncpy(tl, string, 5);
252  if ((ts=strstr(P->Triloops, tl)))
253  return (FLT_OR_DBL)(P->exptri[(ts-P->Triloops)/6]);
254  if (type>2)
255  return (FLT_OR_DBL)(q * P->expTermAU);
256  else
257  return (FLT_OR_DBL)q;
258  }
259  }
260  q *= P->expmismatchH[type][si1][sj1];
261 
262  return (FLT_OR_DBL)q;
263 }
264 
265 
277  int i,
278  int j);
279 
287 int
289  int i,
290  int j,
291  int en,
292  vrna_bp_stack_t *bp_stack,
293  int *stack_count);
294 
300 #endif
int vrna_eval_hp_loop(vrna_fold_compound_t *vc, int i, int j)
Evaluate free energy of a hairpin loop.
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:110
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:214
vrna_md_t model_details
Model details to be used in the recursions.
Definition: params.h:88
vrna_md_t model_details
Model details to be used in the recursions.
Definition: params.h:144
double FLT_OR_DBL
Typename for floating point number in partition function computations.
Definition: data_structures.h:39
The most basic data structure required by many functions throughout the RNAlib.
Definition: data_structures.h:390
The datastructure that contains temperature scaled energy parameters.
Definition: params.h:50
General utility- and helper-functions used throughout the ViennaRNA Package.
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:215
The datastructure that contains temperature scaled Boltzmann weights of the energy parameters...
Definition: params.h:94
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_eval_ext_hp_loop(vrna_fold_compound_t *vc, int i, int j)
Evaluate free energy of an exterior hairpin loop.
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.
Base pair stack element.
Definition: data_structures.h:192