1 #ifndef __VIENNA_RNA_PACKAGE_LOOP_ENERGIES_H__
2 #define __VIENNA_RNA_PACKAGE_LOOP_ENERGIES_H__
11 #include "energy_par.h"
14 # define INLINE inline
54 INLINE PRIVATE
int E_MLstem(
int type,
65 INLINE PRIVATE
double exp_E_MLstem(
int type,
89 INLINE PRIVATE
int E_ExtLoop(
int type,
100 INLINE PRIVATE
double exp_E_ExtLoop(
int type,
243 INLINE PRIVATE
int E_Stem(
int type,
322 INLINE PRIVATE
int E_Hairpin(
int size,
int type,
int si1,
int sj1,
const char *
string,
paramT *P){
326 energy = (size <= 30) ? P->hairpin[size] : P->hairpin[30]+(
int)(P->lxc*log((size)/30.));
330 strncpy(tl,
string, 6);
331 if ((ts=strstr(P->Tetraloops, tl)))
332 return (P->Tetraloop_E[(ts - P->Tetraloops)/7]);
336 strncpy(tl,
string, 8);
337 if ((ts=strstr(P->Hexaloops, tl)))
338 return (energy = P->Hexaloop_E[(ts - P->Hexaloops)/9]);
341 char tl[6]={0,0,0,0,0,0}, *ts;
342 strncpy(tl,
string, 5);
343 if ((ts=strstr(P->Triloops, tl))) {
344 return (P->Triloop_E[(ts - P->Triloops)/6]);
346 return (energy + P->TerminalAU_t[type]);
349 }
else if (type > 16){
350 energy = (size <= 30) ? P->hairpin_D[size] : P->hairpin_D[30]+(
int)(P->lxc_D*log((size)/30.));
354 strncpy(tl,
string, 6);
355 if ((ts=strstr(P->Tetraloops_D, tl)))
356 return (P->Tetraloop_E_D[(ts - P->Tetraloops_D)/7]);
360 strncpy(tl,
string, 8);
361 if ((ts=strstr(P->Hexaloops_D, tl)))
362 return (energy = P->Hexaloop_E_D[(ts - P->Hexaloops_D)/9]);
365 char tl[6]={0,0,0,0,0,0}, *ts;
366 strncpy(tl,
string, 5);
367 if ((ts=strstr(P->Triloops_D, tl))) {
368 return (P->Triloop_E_D[(ts - P->Triloops_D)/6]);
370 return (energy + P->TerminalAU_t[type]);
375 energy += P->mismatchH[type][si1][sj1];
380 INLINE PRIVATE
int E_IntLoop(
int n1,
int n2,
int type,
int type_2,
int si1,
int sj1,
int sp1,
int sq1,
paramT *P){
385 if (n1>n2) { nl=n1; ns=n2;}
391 return P->stack[type][type_2];
395 energy = (nl<=
MAXLOOP) ? P->bulge[nl] : (P->bulge[30]+(
int)(P->lxc*log(nl/30.)));
396 }
else if(type < 16) {
397 energy = (nl<=
MAXLOOP) ? P->bulge_RD[nl] : (P->bulge_RD[30]+(
int)(P->lxc_RD*log(nl/30.)));
399 energy = (nl<=
MAXLOOP) ? P->bulge_D[nl] : (P->bulge_D[30]+(
int)(P->lxc_D*log(nl/30.)));
401 if (nl==1) energy += P->stack[type][type_2];
403 energy += P->TerminalAU_t[type];
404 energy += P->TerminalAU_t[type_2];
411 return P->int11[type][type_2][si1][sj1];
414 energy = P->int21[type][type_2][si1][sq1][sj1];
416 energy = P->int21[type_2][type][sq1][si1][sp1];
421 energy = (nl+1<=
MAXLOOP)?(P->internal_loop[nl+1]) : (P->internal_loop[30]+(int)(P->lxc*log((nl+1)/30.)));
422 energy +=
MIN2(MAX_NINIO, (nl-ns)*P->ninio[2]);
423 }
else if(type < 16){
424 energy = (nl+1<=
MAXLOOP)?(P->internal_loop_RD[nl+1]) : (P->internal_loop_RD[30]+(int)(P->lxc_RD*log((nl+1)/30.)));
425 energy +=
MIN2(MAX_NINIO_RD, (nl-ns)*P->ninio_RD[2]);
427 energy = (nl+1<=
MAXLOOP)?(P->internal_loop_D[nl+1]) : (P->internal_loop_D[30]+(int)(P->lxc_D*log((nl+1)/30.)));
428 energy +=
MIN2(MAX_NINIO_D, (nl-ns)*P->ninio_D[2]);
430 energy += P->mismatch1nI[type][si1][sj1] + P->mismatch1nI[type_2][sq1][sp1];
436 return P->int22[type][type_2][si1][sp1][sq1][sj1];}
439 energy = P->internal_loop[5]+P->ninio[2];
440 }
else if(type < 16){
441 energy = P->internal_loop_RD[5]+P->ninio_RD[2];
443 energy = P->internal_loop_D[5]+P->ninio_D[2];
445 energy += P->mismatch23I[type][si1][sj1] + P->mismatch23I[type_2][sq1][sp1];
452 energy = (n1+n2<=
MAXLOOP)?(P->internal_loop[n1+n2]) : (P->internal_loop[30]+(int)(P->lxc*log((n1+n2)/30.)));
453 energy +=
MIN2(MAX_NINIO, (nl-ns)*P->ninio[2]);
454 }
else if(type < 16){
455 energy = (n1+n2<=
MAXLOOP)?(P->internal_loop_RD[n1+n2]) : (P->internal_loop_RD[30]+(int)(P->lxc_RD*log((n1+n2)/30.)));
456 energy +=
MIN2(MAX_NINIO_RD, (nl-ns)*P->ninio_RD[2]);
458 energy = (n1+n2<=
MAXLOOP)?(P->internal_loop_D[n1+n2]) : (P->internal_loop_D[30]+(int)(P->lxc_D*log((n1+n2)/30.)));
459 energy +=
MIN2(MAX_NINIO_D, (nl-ns)*P->ninio_D[2]);
461 energy += P->mismatchI[type][si1][sj1] + P->mismatchI[type_2][sq1][sp1];
467 INLINE PRIVATE
int E_Stem(
int type,
int si1,
int sj1,
int extLoop,
paramT *P){
469 int d5 = (si1 >= 0) ? P->dangle5[type][si1] : 0;
470 int d3 = (sj1 >= 0) ? P->dangle3[type][sj1] : 0;
472 energy += P->TerminalAU_t[type];
474 if(si1 >= 0 && sj1 >= 0)
475 energy += (extLoop) ? P->mismatchExt[type][si1][sj1] : P->mismatchM[type][si1][sj1];
479 if(!extLoop) energy += P->MLintern[type];
483 INLINE PRIVATE
int E_ExtLoop(
int type,
int si1,
int sj1,
paramT *P){
485 if(si1 >= 0 && sj1 >= 0){
486 energy += P->mismatchExt[type][si1][sj1];
489 energy += P->dangle5[type][si1];
492 energy += P->dangle3[type][sj1];
495 energy += P->TerminalAU_t[type];
500 INLINE PRIVATE
int E_MLstem(
int type,
int si1,
int sj1,
paramT *P){
502 if(si1 >= 0 && sj1 >= 0){
503 energy += P->mismatchM[type][si1][sj1];
506 energy += P->dangle5[type][si1];
509 energy += P->dangle3[type][sj1];
512 energy += P->TerminalAU_t[type];
514 energy += P->MLintern[type];
524 q = (u <= 30) ? P->exphairpin[u] : P->exphairpin[30] * exp( -(P->lxc*log( u/30.))*10./kT);
530 char tl[7]={0,0,0,0,0,0,0}, *ts;
531 strncpy(tl,
string, 6);
532 if ((ts=strstr(P->Tetraloops, tl))){
534 return (P->exptetra[(ts-P->Tetraloops)/7]);
536 q *= P->exptetra[(ts-P->Tetraloops)/7];
540 char tl[9]={0,0,0,0,0,0,0,0,0}, *ts;
541 strncpy(tl,
string, 8);
542 if ((ts=strstr(P->Hexaloops, tl)))
543 return (P->exphex[(ts-P->Hexaloops)/9]);
546 char tl[6]={0,0,0,0,0,0}, *ts;
547 strncpy(tl,
string, 5);
548 if ((ts=strstr(P->Triloops, tl)))
549 return (P->exptri[(ts-P->Triloops)/6]);
551 return q * P->expTermAU_t[type];
555 }
else if (type > 16){
556 q = (u <= 30) ? P->exphairpin_D[u] : P->exphairpin_D[30] * exp( -(P->lxc_D*log( u/30.))*10./kT);
562 char tl[7]={0,0,0,0,0,0,0}, *ts;
563 strncpy(tl,
string, 6);
564 if ((ts=strstr(P->Tetraloops_D, tl))){
566 return (P->exptetra_D[(ts-P->Tetraloops_D)/7]);
568 q *= P->exptetra_D[(ts-P->Tetraloops_D)/7];
572 char tl[9]={0,0,0,0,0,0,0,0,0}, *ts;
573 strncpy(tl,
string, 8);
574 if ((ts=strstr(P->Hexaloops_D, tl)))
575 return (P->exphex_D[(ts-P->Hexaloops_D)/9]);
578 char tl[6]={0,0,0,0,0,0}, *ts;
579 strncpy(tl,
string, 5);
580 if ((ts=strstr(P->Triloops_D, tl)))
581 return (P->exptri_D[(ts-P->Triloops_D)/6]);
582 return (q * P->expTermAU_t[type]);
587 q *= P->expmismatchH[type][si1][sj1];
592 INLINE PRIVATE
double exp_E_IntLoop(
int u1,
int u2,
int type,
int type2,
short si1,
short sj1,
short sp1,
short sq1,
pf_paramT *P){
593 int ul, us, no_close = 0;
596 if ((
no_closingGU) && ((type2==3)||(type2==4)||(type==3)||(type==4)))
599 if (u1>u2) { ul=u1; us=u2;}
603 z = P->expstack[type][type2];
608 }
else if (type < 16){
609 z = P->expbulge_RD[ul];
611 z = P->expbulge_D[ul];
613 if (ul==1) z *= P->expstack[type][type2];
615 if (type>2) z *= P->expTermAU_t[type];
616 if (type2>2) z *= P->expTermAU_t[type2];
622 return P->expint11[type][type2][si1][sj1];
626 return P->expint21[type][type2][si1][sq1][sj1];
628 return P->expint21[type2][type][sq1][si1][sp1];
632 z = P->expinternal[ul+us] * P->expmismatch1nI[type][si1][sj1] * P->expmismatch1nI[type2][sq1][sp1];
633 return z * P->expninio[2][ul-us];
634 }
else if (type < 16){
635 z = P->expinternal_RD[ul+us] * P->expmismatch1nI[type][si1][sj1] * P->expmismatch1nI[type2][sq1][sp1];
636 return z * P->expninio_RD[2][ul-us];
638 z = P->expinternal_D[ul+us] * P->expmismatch1nI[type][si1][sj1] * P->expmismatch1nI[type2][sq1][sp1];
639 return z * P->expninio_D[2][ul-us];
645 return P->expint22[type][type2][si1][sp1][sq1][sj1];
648 z = P->expinternal[5]*P->expmismatch23I[type][si1][sj1]*P->expmismatch23I[type2][sq1][sp1];
649 return z * P->expninio[2][1];
650 }
else if (type < 16){
651 z = P->expinternal_RD[5]*P->expmismatch23I[type][si1][sj1]*P->expmismatch23I[type2][sq1][sp1];
652 return z * P->expninio_RD[2][1];
654 z = P->expinternal_D[5]*P->expmismatch23I[type][si1][sj1]*P->expmismatch23I[type2][sq1][sp1];
655 return z * P->expninio_D[2][1];
661 z = P->expinternal[ul+us] * P->expmismatchI[type][si1][sj1] * P->expmismatchI[type2][sq1][sp1];
662 return z * P->expninio[2][ul-us];
663 }
else if (type < 16){
664 z = P->expinternal_RD[ul+us] * P->expmismatchI[type][si1][sj1] * P->expmismatchI[type2][sq1][sp1];
665 return z * P->expninio_RD[2][ul-us];
667 z = P->expinternal_D[ul+us] * P->expmismatchI[type][si1][sj1] * P->expmismatchI[type2][sq1][sp1];
668 return z * P->expninio_D[2][ul-us];
676 double d5 = (si1 >= 0) ? P->expdangle5[type][si1] : 1.;
677 double d3 = (sj1 >= 0) ? P->expdangle3[type][sj1] : 1.;
680 energy *= P->expTermAU_t[type];
682 if(si1 >= 0 && sj1 >= 0)
683 energy *= (extLoop) ? P->expmismatchExt[type][si1][sj1] : P->expmismatchM[type][si1][sj1];
687 if(!extLoop) energy *= P->expMLintern[type];
691 INLINE PRIVATE
double exp_E_MLstem(
int type,
int si1,
int sj1,
pf_paramT *P){
693 if(si1 >= 0 && sj1 >= 0){
694 energy *= P->expmismatchM[type][si1][sj1];
697 energy *= P->expdangle5[type][si1];
700 energy *= P->expdangle3[type][sj1];
704 energy *= P->expTermAU_t[type];
706 energy *= P->expMLintern[type];
710 INLINE PRIVATE
double exp_E_ExtLoop(
int type,
int si1,
int sj1,
pf_paramT *P){
712 if(si1 >= 0 && sj1 >= 0){
713 energy *= P->expmismatchExt[type][si1][sj1];
716 energy *= P->expdangle5[type][si1];
719 energy *= P->expdangle3[type][sj1];
723 energy *= P->expTermAU_t[type];
728 INLINE PRIVATE
int E_IntLoop_Co(
int type,
int type_2,
int i,
int j,
int p,
int q,
int cutpoint,
short si1,
short sj1,
short sp1,
short sq1,
int dangles,
paramT *P){
730 energy += P->TerminalAU_t[type];
731 energy += P->TerminalAU_t[type_2];
733 if(!dangles)
return energy;
735 int ci = (i>=cutpoint)||((i+1)<cutpoint);
736 int cj = ((j-1)>=cutpoint)||(j<cutpoint);
737 int cp = ((p-1)>=cutpoint)||(p<cutpoint);
738 int cq = (q>=cutpoint)||((q+1)<cutpoint);
740 int d3 = ci ? P->dangle3[type][si1] : 0;
741 int d5 = cj ? P->dangle5[type][sj1] : 0;
742 int d5_2 = cp ? P->dangle5[type_2][sp1] : 0;
743 int d3_2 = cq ? P->dangle3[type_2][sq1] : 0;
745 int tmm = (cj && ci) ? P->mismatchExt[type][sj1][si1] : d5 + d3;
746 int tmm_2 = (cp && cq) ? P->mismatchExt[type_2][sp1][sq1] : d5_2 + d3_2;
748 if(dangles == 2)
return energy + tmm + tmm_2;
752 if(q+2 < j){ energy += tmm + tmm_2;}
753 else if(q+2 == j){ energy += (cj && cq) ?
MIN2(tmm + d5_2, tmm_2 + d3) : tmm + tmm_2;}
754 else energy += d3 + d5_2;
757 if(q+2 < j){ energy += (ci && cp) ?
MIN2(tmm + d3_2, tmm_2 + d5) : tmm + tmm_2;}
759 energy +=
MIN2(tmm,
MIN2(tmm_2,
MIN2(d5 + d5_2, d3 + d3_2)));
761 else energy +=
MIN2(d3, d5_2);
764 if(q+2 < j){ energy += d5 + d3_2;}
765 else if(q+2 == j){ energy +=
MIN2(d5, d3_2);}
#define MIN2(A, B)
Definition: utils.h:134
PRIVATE int E_Hairpin(int size, int type, int si1, int sj1, const char *string, paramT *P)
Definition: loop_energies.h:322
PRIVATE double exp_E_IntLoop(int u1, int u2, int type, int type2, short si1, short sj1, short sp1, short sq1, pf_paramT *P)
Definition: loop_energies.h:592
#define MAXLOOP
Definition: energy_const.h:28
int special_hp
Include special hairpin contributions for tri, tetra and hexaloops.
Definition: data_structures.h:109
The datastructure that contains temperature scaled energy parameters.
Definition: data_structures.h:122
model_detailsT model_details
Model details to be used in the recursions.
Definition: data_structures.h:196
The datastructure that contains temperature scaled Boltzmann weights of the energy parameters...
Definition: data_structures.h:203
PRIVATE int E_Stem(int type, int si1, int sj1, int extLoop, paramT *P)
Definition: loop_energies.h:467
PRIVATE double exp_E_Hairpin(int u, int type, short si1, short sj1, const char *string, pf_paramT *P)
Definition: loop_energies.h:519
#define INF
Definition: energy_const.h:16
PRIVATE int E_IntLoop(int n1, int n2, int type, int type_2, int si1, int sj1, int sp1, int sq1, paramT *P)
Definition: loop_energies.h:380
Here all all declarations of the global variables used throughout RNAlib.
int no_closingGU
GU allowed only inside stacks if set to 1.
int dangles
Switch the energy model for dangling end contributions (0, 1, 2, 3)
model_detailsT model_details
Model details to be used in the recursions.
Definition: data_structures.h:286
PRIVATE double exp_E_Stem(int type, int si1, int sj1, int extLoop, pf_paramT *P)
Definition: loop_energies.h:674