hairpin_loops.h
Go to the documentation of this file.
#ifndef VIENNA_RNA_PACKAGE_HAIRPIN_LOOPS_H
#define VIENNA_RNA_PACKAGE_HAIRPIN_LOOPS_H
#include <math.h>
#include <string.h>
#include <ViennaRNA/utils.h>
#include <ViennaRNA/data_structures.h>
#include <ViennaRNA/params.h>
#ifdef __GNUC__
# define INLINE inline
#else
# define INLINE
#endif
PRIVATE INLINE int
E_Hairpin(int size,
int type,
int si1,
int sj1,
const char *string,
vrna_param_t *P);
PRIVATE INLINE FLT_OR_DBL
exp_E_Hairpin( int u,
int type,
short si1,
short sj1,
const char *string,
vrna_exp_param_t *P);
int
vrna_eval_hp_loop(vrna_fold_compound_t *vc,
int i,
int j);
int
vrna_eval_ext_hp_loop(vrna_fold_compound_t *vc,
int i,
int j);
/*
#################################
# BEGIN OF FUNCTION DEFINITIONS #
#################################
*/
PRIVATE INLINE int
E_Hairpin(int size,
int type,
int si1,
int sj1,
const char *string,
vrna_param_t *P){
int energy;
if(size <= 30)
energy = P->hairpin[size];
else
energy = P->hairpin[30] + (int)(P->lxc*log((size)/30.));
if(size < 3) return energy; /* should only be the case when folding alignments */
if(P->model_details.special_hp){
if(size == 4){ /* check for tetraloop bonus */
char tl[7]={0}, *ts;
strncpy(tl, string, 6);
if ((ts=strstr(P->Tetraloops, tl)))
return (P->Tetraloop_E[(ts - P->Tetraloops)/7]);
}
else if(size == 6){
char tl[9]={0}, *ts;
strncpy(tl, string, 8);
if ((ts=strstr(P->Hexaloops, tl)))
return (energy = P->Hexaloop_E[(ts - P->Hexaloops)/9]);
}
else if(size == 3){
char tl[6]={0,0,0,0,0,0}, *ts;
strncpy(tl, string, 5);
if ((ts=strstr(P->Triloops, tl))) {
return (P->Triloop_E[(ts - P->Triloops)/6]);
}
return (energy + (type>2 ? P->TerminalAU : 0));
}
}
energy += P->mismatchH[type][si1][sj1];
return energy;
}
int
vrna_E_hp_loop( vrna_fold_compound_t *vc,
int i,
int j);
int
vrna_E_ext_hp_loop( vrna_fold_compound_t *vc,
int i,
int j);
int
vrna_eval_ext_hp_loop(vrna_fold_compound_t *vc,
int i,
int j);
int
vrna_eval_hp_loop(vrna_fold_compound_t *vc,
int i,
int j);
/*
*************************************
* Partition function variants below *
*************************************
*/
PRIVATE INLINE FLT_OR_DBL
exp_E_Hairpin(int u,
int type,
short si1,
short sj1,
const char *string,
vrna_exp_param_t *P){
double q, kT;
kT = P->kT; /* kT in cal/mol */
if(u <= 30)
q = P->exphairpin[u];
else
q = P->exphairpin[30] * exp( -(P->lxc*log( u/30.))*10./kT);
if(u < 3) return (FLT_OR_DBL)q; /* should only be the case when folding alignments */
if(P->model_details.special_hp){
if(u==4){
char tl[7]={0,0,0,0,0,0,0}, *ts;
strncpy(tl, string, 6);
if ((ts=strstr(P->Tetraloops, tl))){
if(type != 7)
return (FLT_OR_DBL)(P->exptetra[(ts-P->Tetraloops)/7]);
else
q *= P->exptetra[(ts-P->Tetraloops)/7];
}
}
else if(u==6){
char tl[9]={0,0,0,0,0,0,0,0,0}, *ts;
strncpy(tl, string, 8);
if ((ts=strstr(P->Hexaloops, tl)))
return (FLT_OR_DBL)(P->exphex[(ts-P->Hexaloops)/9]);
}
else if(u==3){
char tl[6]={0,0,0,0,0,0}, *ts;
strncpy(tl, string, 5);
if ((ts=strstr(P->Triloops, tl)))
return (FLT_OR_DBL)(P->exptri[(ts-P->Triloops)/6]);
if (type>2)
return (FLT_OR_DBL)(q * P->expTermAU);
else
return (FLT_OR_DBL)q;
}
}
q *= P->expmismatchH[type][si1][sj1];
return (FLT_OR_DBL)q;
}
FLT_OR_DBL
vrna_exp_E_hp_loop( vrna_fold_compound_t *vc,
int i,
int j);
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);
#endif
vrna_eval_hp_loop
int vrna_eval_hp_loop(vrna_fold_compound_t *vc, int i, int j)
Evaluate free energy of a hairpin loop.
E_Hairpin
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
vrna_exp_E_hp_loop
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_s::special_hp
int special_hp
Include special hairpin contributions for tri, tetra and hexaloops.
Definition: model.h:214
vrna_param_s::model_details
vrna_md_t model_details
Model details to be used in the recursions.
Definition: params.h:88
vrna_exp_param_s::model_details
vrna_md_t model_details
Model details to be used in the recursions.
Definition: params.h:144
FLT_OR_DBL
double FLT_OR_DBL
Typename for floating point number in partition function computations.
Definition: data_structures.h:39
vrna_fc_s
The most basic data structure required by many functions throughout the RNAlib.
Definition: data_structures.h:390
vrna_param_s
The datastructure that contains temperature scaled energy parameters.
Definition: params.h:50
utils.h
General utility- and helper-functions used throughout the ViennaRNA Package.
data_structures.h
exp_E_Hairpin
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
params.h
vrna_exp_param_s
The datastructure that contains temperature scaled Boltzmann weights of the energy parameters...
Definition: params.h:94
vrna_BT_hp_loop
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 .
vrna_E_ext_hp_loop
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.
vrna_eval_ext_hp_loop
int vrna_eval_ext_hp_loop(vrna_fold_compound_t *vc, int i, int j)
Evaluate free energy of an exterior hairpin loop.
vrna_E_hp_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.
vrna_bp_stack_s
Base pair stack element.
Definition: data_structures.h:192