RNAlib-2.2.9
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 
170 int
172  int i,
173  int j);
174 
183 int
185  int i,
186  int j);
187 
194 int
196  int i,
197  int j);
198 
212 int
214  int i,
215  int j);
216 
217 /*
218 *************************************
219 * Partition function variants below *
220 *************************************
221 */
222 
223 PRIVATE INLINE FLT_OR_DBL
225  int type,
226  short si1,
227  short sj1,
228  const char *string,
229  vrna_exp_param_t *P){
230 
231  double q, kT;
232  kT = P->kT; /* kT in cal/mol */
233 
234  if(u <= 30)
235  q = P->exphairpin[u];
236  else
237  q = P->exphairpin[30] * exp( -(P->lxc*log( u/30.))*10./kT);
238 
239  if(u < 3) return (FLT_OR_DBL)q; /* should only be the case when folding alignments */
240 
241  if(P->model_details.special_hp){
242  if(u==4){
243  char tl[7]={0,0,0,0,0,0,0}, *ts;
244  strncpy(tl, string, 6);
245  if ((ts=strstr(P->Tetraloops, tl))){
246  if(type != 7)
247  return (FLT_OR_DBL)(P->exptetra[(ts-P->Tetraloops)/7]);
248  else
249  q *= P->exptetra[(ts-P->Tetraloops)/7];
250  }
251  }
252  else if(u==6){
253  char tl[9]={0,0,0,0,0,0,0,0,0}, *ts;
254  strncpy(tl, string, 8);
255  if ((ts=strstr(P->Hexaloops, tl)))
256  return (FLT_OR_DBL)(P->exphex[(ts-P->Hexaloops)/9]);
257  }
258  else if(u==3){
259  char tl[6]={0,0,0,0,0,0}, *ts;
260  strncpy(tl, string, 5);
261  if ((ts=strstr(P->Triloops, tl)))
262  return (FLT_OR_DBL)(P->exptri[(ts-P->Triloops)/6]);
263  if (type>2)
264  return (FLT_OR_DBL)(q * P->expTermAU);
265  else
266  return (FLT_OR_DBL)q;
267  }
268  }
269  q *= P->expmismatchH[type][si1][sj1];
270 
271  return (FLT_OR_DBL)q;
272 }
273 
274 
286  int i,
287  int j);
288 
296 int
298  int i,
299  int j,
300  int en,
301  vrna_bp_stack_t *bp_stack,
302  int *stack_count);
303 
309 #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:215
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:424
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:224
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 hard constraints if they apply.
Base pair stack element.
Definition: data_structures.h:192