\hypertarget{loop__energies_8h_source}{
\section{/homes/fmmarquesmadeira/Projects/jabaws/binaries/src/ViennaRNA/H/loop\_\-energies.h}
}


\begin{footnotesize}\begin{alltt}
00001 \textcolor{preprocessor}{#ifndef \_\_VIENNA\_RNA\_PACKAGE\_LOOP\_ENERGIES\_H\_\_}
00002 \textcolor{preprocessor}{}\textcolor{preprocessor}{#define \_\_VIENNA\_RNA\_PACKAGE\_LOOP\_ENERGIES\_H\_\_}
00003 \textcolor{preprocessor}{}
00004 \textcolor{preprocessor}{#include <stdio.h>}
00005 \textcolor{preprocessor}{#include <stdlib.h>}
00006 \textcolor{preprocessor}{#include <math.h>}
00007 \textcolor{preprocessor}{#include <ctype.h>}
00008 \textcolor{preprocessor}{#include <string.h>}
00009 \textcolor{preprocessor}{#include "\hyperlink{params_8h}{params.h}"}
00010 \textcolor{preprocessor}{#include "\hyperlink{fold__vars_8h}{fold_vars.h}"}
00011 \textcolor{preprocessor}{#include "energy\_par.h"}
00012 
00013 \textcolor{preprocessor}{#ifdef \_\_GNUC\_\_}
00014 \textcolor{preprocessor}{}\textcolor{preprocessor}{# define INLINE inline}
00015 \textcolor{preprocessor}{}\textcolor{preprocessor}{#else}
00016 \textcolor{preprocessor}{}\textcolor{preprocessor}{# define INLINE}
00017 \textcolor{preprocessor}{}\textcolor{preprocessor}{#endif}
00018 \textcolor{preprocessor}{}
00054 INLINE  PRIVATE \textcolor{keywordtype}{int} E\_MLstem( \textcolor{keywordtype}{int} type,
00055                               \textcolor{keywordtype}{int} si1,
00056                               \textcolor{keywordtype}{int} sj1,
00057                               \hyperlink{structparamT}{paramT} *P);
00058 
00065 INLINE  PRIVATE \textcolor{keywordtype}{double} exp\_E\_MLstem(\textcolor{keywordtype}{int} type,
00066                                     \textcolor{keywordtype}{int} si1,
00067                                     \textcolor{keywordtype}{int} sj1,
00068                                     \hyperlink{structpf__paramT}{pf_paramT} *P);
00069 
00089 INLINE  PRIVATE \textcolor{keywordtype}{int} E\_ExtLoop(\textcolor{keywordtype}{int} type,
00090                               \textcolor{keywordtype}{int} si1,
00091                               \textcolor{keywordtype}{int} sj1,
00092                               \hyperlink{structparamT}{paramT} *P);
00093 
00100 INLINE  PRIVATE \textcolor{keywordtype}{double} exp\_E\_ExtLoop( \textcolor{keywordtype}{int} type,
00101                                       \textcolor{keywordtype}{int} si1,
00102                                       \textcolor{keywordtype}{int} sj1,
00103                                       \hyperlink{structpf__paramT}{pf_paramT} *P);
00104 
00149 INLINE  PRIVATE \textcolor{keywordtype}{int} \hyperlink{loop__energies_8h_a3e5ad89f451254b1fe366d77aa8ff7bd}{E_IntLoop}(\textcolor{keywordtype}{int} n1,
00150                               \textcolor{keywordtype}{int} n2,
00151                               \textcolor{keywordtype}{int} type,
00152                               \textcolor{keywordtype}{int} type\_2,
00153                               \textcolor{keywordtype}{int} si1,
00154                               \textcolor{keywordtype}{int} sj1,
00155                               \textcolor{keywordtype}{int} sp1,
00156                               \textcolor{keywordtype}{int} sq1,
00157                               \hyperlink{structparamT}{paramT} *P);
00158 
00159 
00191 INLINE  PRIVATE \textcolor{keywordtype}{int} \hyperlink{loop__energies_8h_aa362183cf6db89a10cdb0f5c4bd180c6}{E_Hairpin}(\textcolor{keywordtype}{int} size,
00192                               \textcolor{keywordtype}{int} type,
00193                               \textcolor{keywordtype}{int} si1,
00194                               \textcolor{keywordtype}{int} sj1,
00195                               \textcolor{keyword}{const} \textcolor{keywordtype}{char} *\textcolor{keywordtype}{string},
00196                               \hyperlink{structparamT}{paramT} *P);
00197 
00243 INLINE  PRIVATE \textcolor{keywordtype}{int} \hyperlink{loop__energies_8h_af5a6594eba9b2622cb47076650c69819}{E_Stem}( \textcolor{keywordtype}{int} type,
00244                             \textcolor{keywordtype}{int} si1,
00245                             \textcolor{keywordtype}{int} sj1,
00246                             \textcolor{keywordtype}{int} extLoop,
00247                             \hyperlink{structparamT}{paramT} *P);
00248 
00257 INLINE  PRIVATE \textcolor{keywordtype}{double} \hyperlink{loop__energies_8h_a76cc24ec96199e04beddad13e7891e21}{exp_E_Stem}(\textcolor{keywordtype}{int} type,
00258                                   \textcolor{keywordtype}{int} si1,
00259                                   \textcolor{keywordtype}{int} sj1,
00260                                   \textcolor{keywordtype}{int} extLoop,
00261                                   \hyperlink{structpf__paramT}{pf_paramT} *P);
00262 
00280 INLINE  PRIVATE \textcolor{keywordtype}{double} \hyperlink{loop__energies_8h_a0e128184bb097dc2da33706f33b555a6}{exp_E_Hairpin}( \textcolor{keywordtype}{int} u,
00281                                       \textcolor{keywordtype}{int} type,
00282                                       \textcolor{keywordtype}{short} si1,
00283                                       \textcolor{keywordtype}{short} sj1,
00284                                       \textcolor{keyword}{const} \textcolor{keywordtype}{char} *\textcolor{keywordtype}{string},
00285                                       \hyperlink{structpf__paramT}{pf_paramT} *P);
00286 
00306 INLINE  PRIVATE \textcolor{keywordtype}{double}  \hyperlink{loop__energies_8h_aa5e98e524e2a41e290b942b09544bc9e}{exp_E_IntLoop}(\textcolor{keywordtype}{int} u1,
00307                                       \textcolor{keywordtype}{int} u2,
00308                                       \textcolor{keywordtype}{int} type,
00309                                       \textcolor{keywordtype}{int} type2,
00310                                       \textcolor{keywordtype}{short} si1,
00311                                       \textcolor{keywordtype}{short} sj1,
00312                                       \textcolor{keywordtype}{short} sp1,
00313                                       \textcolor{keywordtype}{short} sq1,
00314                                       \hyperlink{structpf__paramT}{pf_paramT} *P);
00315 
00316 
00317 \textcolor{comment}{/*}
00318 \textcolor{comment}{#################################}
00319 \textcolor{comment}{# BEGIN OF FUNCTION DEFINITIONS #}
00320 \textcolor{comment}{#################################}
00321 \textcolor{comment}{*/}
\hypertarget{loop__energies_8h_source_l00322}{}\hyperlink{loop__energies_8h_aa362183cf6db89a10cdb0f5c4bd180c6}{00322} INLINE  PRIVATE \textcolor{keywordtype}{int} \hyperlink{loop__energies_8h_aa362183cf6db89a10cdb0f5c4bd180c6}{E_Hairpin}(\textcolor{keywordtype}{int} size, \textcolor{keywordtype}{int} type, \textcolor{keywordtype}{int} si1, \textcolor{keywordtype}{int} sj1, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *\textcolor{keywordtype}{s
      tring}, \hyperlink{structparamT}{paramT} *P)\{
00323   \textcolor{keywordtype}{int} energy;
00324 
00325   energy = (size <= 30) ? P->hairpin[size] : P->hairpin[30]+(\textcolor{keywordtype}{int})(P->lxc*log((siz
      e)/30.));
00326   \textcolor{keywordflow}{if} (P->\hyperlink{structparamT_aeb912822ef912705bc202b14f9d71ad9}{model_details}.\hyperlink{structmodel__detailsT_a9d73fde17b0465311a80f607faa85617}{special_hp})\{
00327     \textcolor{keywordflow}{if} (size == 4) \{ \textcolor{comment}{/* check for tetraloop bonus */}
00328       \textcolor{keywordtype}{char} tl[7]=\{0\}, *ts;
00329       strncpy(tl, \textcolor{keywordtype}{string}, 6);
00330       \textcolor{keywordflow}{if} ((ts=strstr(P->Tetraloops, tl)))
00331         \textcolor{keywordflow}{return} (P->Tetraloop\_E[(ts - P->Tetraloops)/7]);
00332     \}
00333     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (size == 6) \{
00334       \textcolor{keywordtype}{char} tl[9]=\{0\}, *ts;
00335       strncpy(tl, \textcolor{keywordtype}{string}, 8);
00336       \textcolor{keywordflow}{if} ((ts=strstr(P->Hexaloops, tl)))
00337         \textcolor{keywordflow}{return} (energy = P->Hexaloop\_E[(ts - P->Hexaloops)/9]);
00338     \}
00339     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (size == 3) \{
00340       \textcolor{keywordtype}{char} tl[6]=\{0,0,0,0,0,0\}, *ts;
00341       strncpy(tl, \textcolor{keywordtype}{string}, 5);
00342       \textcolor{keywordflow}{if} ((ts=strstr(P->Triloops, tl))) \{
00343         \textcolor{keywordflow}{return} (P->Triloop\_E[(ts - P->Triloops)/6]);
00344       \}
00345       \textcolor{keywordflow}{return} (energy + (type>2 ? P->TerminalAU : 0));
00346     \}
00347   \}
00348   energy += P->mismatchH[type][si1][sj1];
00349 
00350   \textcolor{keywordflow}{return} energy;
00351 \}
00352 
\hypertarget{loop__energies_8h_source_l00353}{}\hyperlink{loop__energies_8h_a3e5ad89f451254b1fe366d77aa8ff7bd}{00353} INLINE  PRIVATE \textcolor{keywordtype}{int} \hyperlink{loop__energies_8h_a3e5ad89f451254b1fe366d77aa8ff7bd}{E_IntLoop}(\textcolor{keywordtype}{int} n1, \textcolor{keywordtype}{int} n2, \textcolor{keywordtype}{int} type, \textcolor{keywordtype}{int} type\_2, \textcolor{keywordtype}{int} si1, \textcolor{keywordtype}{int} 
      sj1, \textcolor{keywordtype}{int} sp1, \textcolor{keywordtype}{int} sq1, \hyperlink{structparamT}{paramT} *P)\{
00354   \textcolor{comment}{/* compute energy of degree 2 loop (stack bulge or interior) */}
00355   \textcolor{keywordtype}{int} nl, ns, energy;
00356   energy = \hyperlink{energy__const_8h_a12c2040f25d8e3a7b9e1c2024c618cb6}{INF};
00357 
00358   \textcolor{keywordflow}{if} (n1>n2) \{ nl=n1; ns=n2;\}
00359   \textcolor{keywordflow}{else} \{nl=n2; ns=n1;\}
00360 
00361   \textcolor{keywordflow}{if} (nl == 0)
00362     \textcolor{keywordflow}{return} P->stack[type][type\_2];  \textcolor{comment}{/* stack */}
00363 
00364   \textcolor{keywordflow}{if} (ns==0) \{                      \textcolor{comment}{/* bulge */}
00365     energy = (nl<=\hyperlink{energy__const_8h_ad1bd6eabac419670ddd3c9ed82145988}{MAXLOOP})?P->bulge[nl]:
00366       (P->bulge[30]+(\textcolor{keywordtype}{int})(P->lxc*log(nl/30.)));
00367     \textcolor{keywordflow}{if} (nl==1) energy += P->stack[type][type\_2];
00368     \textcolor{keywordflow}{else} \{
00369       \textcolor{keywordflow}{if} (type>2) energy += P->TerminalAU;
00370       \textcolor{keywordflow}{if} (type\_2>2) energy += P->TerminalAU;
00371     \}
00372     \textcolor{keywordflow}{return} energy;
00373   \}
00374   \textcolor{keywordflow}{else} \{                            \textcolor{comment}{/* interior loop */}
00375     \textcolor{keywordflow}{if} (ns==1) \{
00376       \textcolor{keywordflow}{if} (nl==1)                    \textcolor{comment}{/* 1x1 loop */}
00377         \textcolor{keywordflow}{return} P->int11[type][type\_2][si1][sj1];
00378       \textcolor{keywordflow}{if} (nl==2) \{                  \textcolor{comment}{/* 2x1 loop */}
00379         \textcolor{keywordflow}{if} (n1==1)
00380           energy = P->int21[type][type\_2][si1][sq1][sj1];
00381         \textcolor{keywordflow}{else}
00382           energy = P->int21[type\_2][type][sq1][si1][sp1];
00383         \textcolor{keywordflow}{return} energy;
00384       \}
00385       \textcolor{keywordflow}{else} \{  \textcolor{comment}{/* 1xn loop */}
00386         energy = (nl+1<=\hyperlink{energy__const_8h_ad1bd6eabac419670ddd3c9ed82145988}{MAXLOOP})?(P->internal\_loop[nl+1]) : (P->internal\_loop[30]
      +(int)(P->lxc*log((nl+1)/30.)));
00387         energy += \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(MAX\_NINIO, (nl-ns)*P->ninio[2]);
00388         energy += P->mismatch1nI[type][si1][sj1] + P->mismatch1nI[type\_2][sq1][sp
      1];
00389         \textcolor{keywordflow}{return} energy;
00390       \}
00391     \}
00392     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (ns==2) \{
00393       \textcolor{keywordflow}{if}(nl==2)      \{              \textcolor{comment}{/* 2x2 loop */}
00394         \textcolor{keywordflow}{return} P->int22[type][type\_2][si1][sp1][sq1][sj1];\}
00395       \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (nl==3)\{              \textcolor{comment}{/* 2x3 loop */}
00396         energy = P->internal\_loop[5]+P->ninio[2];
00397         energy += P->mismatch23I[type][si1][sj1] + P->mismatch23I[type\_2][sq1][sp
      1];
00398         \textcolor{keywordflow}{return} energy;
00399       \}
00400 
00401     \}
00402     \{ \textcolor{comment}{/* generic interior loop (no else here!)*/}
00403       energy = (n1+n2<=\hyperlink{energy__const_8h_ad1bd6eabac419670ddd3c9ed82145988}{MAXLOOP})?(P->internal\_loop[n1+n2]) : (P->internal\_loop[30]
      +(int)(P->lxc*log((n1+n2)/30.)));
00404 
00405       energy += \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(MAX\_NINIO, (nl-ns)*P->ninio[2]);
00406 
00407       energy += P->mismatchI[type][si1][sj1] + P->mismatchI[type\_2][sq1][sp1];
00408     \}
00409   \}
00410   \textcolor{keywordflow}{return} energy;
00411 \}
00412 
\hypertarget{loop__energies_8h_source_l00413}{}\hyperlink{loop__energies_8h_af5a6594eba9b2622cb47076650c69819}{00413} INLINE  PRIVATE \textcolor{keywordtype}{int} \hyperlink{loop__energies_8h_af5a6594eba9b2622cb47076650c69819}{E_Stem}(\textcolor{keywordtype}{int} type, \textcolor{keywordtype}{int} si1, \textcolor{keywordtype}{int} sj1, \textcolor{keywordtype}{int} extLoop, \hyperlink{structparamT}{paramT} *P)\{
00414   \textcolor{keywordtype}{int} energy = 0;
00415   \textcolor{keywordtype}{int} d5 = (si1 >= 0) ? P->dangle5[type][si1] : 0;
00416   \textcolor{keywordtype}{int} d3 = (sj1 >= 0) ? P->dangle3[type][sj1] : 0;
00417 
00418   \textcolor{keywordflow}{if}(type > 2)
00419     energy += P->TerminalAU;
00420 
00421   \textcolor{keywordflow}{if}(si1 >= 0 && sj1 >= 0)
00422     energy += (extLoop) ? P->mismatchExt[type][si1][sj1] : P->mismatchM[type][si1
      ][sj1];
00423   \textcolor{keywordflow}{else}
00424     energy += d5 + d3;
00425 
00426   \textcolor{keywordflow}{if}(!extLoop) energy += P->MLintern[type];
00427   \textcolor{keywordflow}{return} energy;
00428 \}
00429 
00430 INLINE  PRIVATE \textcolor{keywordtype}{int} E\_ExtLoop(\textcolor{keywordtype}{int} type, \textcolor{keywordtype}{int} si1, \textcolor{keywordtype}{int} sj1, \hyperlink{structparamT}{paramT} *P)\{
00431   \textcolor{keywordtype}{int} energy = 0;
00432   \textcolor{keywordflow}{if}(si1 >= 0 && sj1 >= 0)\{
00433     energy += P->mismatchExt[type][si1][sj1];
00434   \}
00435   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (si1 >= 0)\{
00436     energy += P->dangle5[type][si1];
00437   \}
00438   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (sj1 >= 0)\{
00439     energy += P->dangle3[type][sj1];
00440   \}
00441 
00442   \textcolor{keywordflow}{if}(type > 2)
00443     energy += P->TerminalAU;
00444 
00445   \textcolor{keywordflow}{return} energy;
00446 \}
00447 
00448 INLINE  PRIVATE \textcolor{keywordtype}{int} E\_MLstem(\textcolor{keywordtype}{int} type, \textcolor{keywordtype}{int} si1, \textcolor{keywordtype}{int} sj1, \hyperlink{structparamT}{paramT} *P)\{
00449   \textcolor{keywordtype}{int} energy = 0;
00450   \textcolor{keywordflow}{if}(si1 >= 0 && sj1 >= 0)\{
00451     energy += P->mismatchM[type][si1][sj1];
00452   \}
00453   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (si1 >= 0)\{
00454     energy += P->dangle5[type][si1];
00455   \}
00456   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (sj1 >= 0)\{
00457     energy += P->dangle3[type][sj1];
00458   \}
00459 
00460   \textcolor{keywordflow}{if}(type > 2)
00461     energy += P->TerminalAU;
00462 
00463   energy += P->MLintern[type];
00464 
00465   \textcolor{keywordflow}{return} energy;
00466 \}
00467 
\hypertarget{loop__energies_8h_source_l00468}{}\hyperlink{loop__energies_8h_a0e128184bb097dc2da33706f33b555a6}{00468} INLINE  PRIVATE \textcolor{keywordtype}{double} \hyperlink{loop__energies_8h_a0e128184bb097dc2da33706f33b555a6}{exp_E_Hairpin}(\textcolor{keywordtype}{int} u, \textcolor{keywordtype}{int} type, \textcolor{keywordtype}{short} si1, \textcolor{keywordtype}{short} sj1, \textcolor{keyword}{const
      } \textcolor{keywordtype}{char} *\textcolor{keywordtype}{string}, \hyperlink{structpf__paramT}{pf_paramT} *P)\{
00469   \textcolor{keywordtype}{double} q, kT;
00470   kT = P->kT;   \textcolor{comment}{/* kT in cal/mol  */}
00471 
00472   \textcolor{keywordflow}{if}(u <= 30)
00473     q = P->exphairpin[u];
00474   \textcolor{keywordflow}{else}
00475     q = P->exphairpin[30] * exp( -(P->lxc*log( u/30.))*10./kT);
00476 
00477   \textcolor{keywordflow}{if}(u < 3) \textcolor{keywordflow}{return} q; \textcolor{comment}{/* should only be the case when folding alignments */}
00478 
00479   \textcolor{keywordflow}{if} ((P->\hyperlink{structpf__paramT_a43ec875779c5e7c8bf5fa7e837ec6d09}{model_details}.\hyperlink{structmodel__detailsT_a9d73fde17b0465311a80f607faa85617}{special_hp})&&(u==4)) \{
00480     \textcolor{keywordtype}{char} tl[7]=\{0,0,0,0,0,0,0\}, *ts;
00481     strncpy(tl, \textcolor{keywordtype}{string}, 6);
00482     \textcolor{keywordflow}{if} ((ts=strstr(P->Tetraloops, tl)))\{
00483       \textcolor{keywordflow}{if}(type != 7)
00484         \textcolor{keywordflow}{return} (P->exptetra[(ts-P->Tetraloops)/7]);
00485       \textcolor{keywordflow}{else}
00486         q *= P->exptetra[(ts-P->Tetraloops)/7];
00487     \}
00488   \}
00489   \textcolor{keywordflow}{if} ((\hyperlink{fold__vars_8h_a4f6265bdf0ead7ff4628a360adbfd77e}{tetra_loop})&&(u==6)) \{
00490     \textcolor{keywordtype}{char} tl[9]=\{0,0,0,0,0,0,0,0,0\}, *ts;
00491     strncpy(tl, \textcolor{keywordtype}{string}, 6);
00492     \textcolor{keywordflow}{if} ((ts=strstr(P->Hexaloops, tl)))
00493       \textcolor{keywordflow}{return}  (P->exphex[(ts-P->Hexaloops)/9]);
00494   \}
00495   \textcolor{keywordflow}{if} (u==3) \{
00496     \textcolor{keywordtype}{char} tl[6]=\{0,0,0,0,0,0\}, *ts;
00497     strncpy(tl, \textcolor{keywordtype}{string}, 5);
00498     \textcolor{keywordflow}{if} ((ts=strstr(P->Triloops, tl)))
00499       \textcolor{keywordflow}{return} (P->exptri[(ts-P->Triloops)/6]);
00500     \textcolor{keywordflow}{if} (type>2)
00501       q *= P->expTermAU;
00502   \}
00503   \textcolor{keywordflow}{else} \textcolor{comment}{/* no mismatches for tri-loops */}
00504     q *= P->expmismatchH[type][si1][sj1];
00505 
00506   \textcolor{keywordflow}{return} q;
00507 \}
00508 
\hypertarget{loop__energies_8h_source_l00509}{}\hyperlink{loop__energies_8h_aa5e98e524e2a41e290b942b09544bc9e}{00509} INLINE  PRIVATE \textcolor{keywordtype}{double} \hyperlink{loop__energies_8h_aa5e98e524e2a41e290b942b09544bc9e}{exp_E_IntLoop}(\textcolor{keywordtype}{int} u1, \textcolor{keywordtype}{int} u2, \textcolor{keywordtype}{int} type, \textcolor{keywordtype}{int} type2, \textcolor{keywordtype}{short} s
      i1, \textcolor{keywordtype}{short} sj1, \textcolor{keywordtype}{short} sp1, \textcolor{keywordtype}{short} sq1, \hyperlink{structpf__paramT}{pf_paramT} *P)\{
00510   \textcolor{keywordtype}{int} ul, us, no\_close = 0;
00511   \textcolor{keywordtype}{double} z = 0.;
00512 
00513   \textcolor{keywordflow}{if} ((\hyperlink{fold__vars_8h_aa8d1c7b92489179e1eafa562b7bdd259}{no_closingGU}) && ((type2==3)||(type2==4)||(type==3)||(type==4)))
00514     no\_close = 1;
00515 
00516   \textcolor{keywordflow}{if} (u1>u2) \{ ul=u1; us=u2;\}
00517   \textcolor{keywordflow}{else} \{ul=u2; us=u1;\}
00518 
00519   \textcolor{keywordflow}{if} (ul==0) \textcolor{comment}{/* stack */}
00520     z = P->expstack[type][type2];
00521   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(!no\_close)\{
00522     \textcolor{keywordflow}{if} (us==0) \{                      \textcolor{comment}{/* bulge */}
00523       z = P->expbulge[ul];
00524       \textcolor{keywordflow}{if} (ul==1) z *= P->expstack[type][type2];
00525       \textcolor{keywordflow}{else} \{
00526         \textcolor{keywordflow}{if} (type>2) z *= P->expTermAU;
00527         \textcolor{keywordflow}{if} (type2>2) z *= P->expTermAU;
00528       \}
00529       \textcolor{keywordflow}{return} z;
00530     \}
00531     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (us==1) \{
00532       \textcolor{keywordflow}{if} (ul==1)\{                    \textcolor{comment}{/* 1x1 loop */}
00533         \textcolor{keywordflow}{return} P->expint11[type][type2][si1][sj1];
00534       \}
00535       \textcolor{keywordflow}{if} (ul==2) \{                  \textcolor{comment}{/* 2x1 loop */}
00536         \textcolor{keywordflow}{if} (u1==1)
00537           \textcolor{keywordflow}{return} P->expint21[type][type2][si1][sq1][sj1];
00538         \textcolor{keywordflow}{else}
00539           \textcolor{keywordflow}{return} P->expint21[type2][type][sq1][si1][sp1];
00540       \}
00541       \textcolor{keywordflow}{else} \{  \textcolor{comment}{/* 1xn loop */}
00542         z = P->expinternal[ul+us] * P->expmismatch1nI[type][si1][sj1] * P->expmis
      match1nI[type2][sq1][sp1];
00543         \textcolor{keywordflow}{return} z * P->expninio[2][ul-us];
00544       \}
00545     \}
00546     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (us==2) \{
00547       \textcolor{keywordflow}{if}(ul==2) \textcolor{comment}{/* 2x2 loop */}
00548         \textcolor{keywordflow}{return} P->expint22[type][type2][si1][sp1][sq1][sj1];
00549       \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(ul==3)\{              \textcolor{comment}{/* 2x3 loop */}
00550         z = P->expinternal[5]*P->expmismatch23I[type][si1][sj1]*P->expmismatch23I
      [type2][sq1][sp1];
00551         \textcolor{keywordflow}{return} z * P->expninio[2][1];
00552       \}
00553     \}
00554     \textcolor{comment}{/* generic interior loop (no else here!)*/}
00555     z = P->expinternal[ul+us] * P->expmismatchI[type][si1][sj1] * P->expmismatchI
      [type2][sq1][sp1];
00556     \textcolor{keywordflow}{return} z * P->expninio[2][ul-us];
00557 
00558   \}
00559   \textcolor{keywordflow}{return} z;
00560 \}
00561 
\hypertarget{loop__energies_8h_source_l00562}{}\hyperlink{loop__energies_8h_a76cc24ec96199e04beddad13e7891e21}{00562} INLINE  PRIVATE \textcolor{keywordtype}{double} \hyperlink{loop__energies_8h_a76cc24ec96199e04beddad13e7891e21}{exp_E_Stem}(\textcolor{keywordtype}{int} type, \textcolor{keywordtype}{int} si1, \textcolor{keywordtype}{int} sj1, \textcolor{keywordtype}{int} extLoop, 
      \hyperlink{structpf__paramT}{pf_paramT} *P)\{
00563   \textcolor{keywordtype}{double} energy = 1.0;
00564   \textcolor{keywordtype}{double} d5 = (si1 >= 0) ? P->expdangle5[type][si1] : 1.;
00565   \textcolor{keywordtype}{double} d3 = (sj1 >= 0) ? P->expdangle3[type][sj1] : 1.;
00566 
00567   \textcolor{keywordflow}{if}(type > 2)
00568     energy *= P->expTermAU;
00569 
00570   \textcolor{keywordflow}{if}(si1 >= 0 && sj1 >= 0)
00571     energy *= (extLoop) ? P->expmismatchExt[type][si1][sj1] : P->expmismatchM[typ
      e][si1][sj1];
00572   \textcolor{keywordflow}{else}
00573     energy *= d5 * d3;
00574 
00575   \textcolor{keywordflow}{if}(!extLoop) energy *= P->expMLintern[type];
00576   \textcolor{keywordflow}{return} energy;
00577 \}
00578 
00579 INLINE  PRIVATE \textcolor{keywordtype}{double} exp\_E\_MLstem(\textcolor{keywordtype}{int} type, \textcolor{keywordtype}{int} si1, \textcolor{keywordtype}{int} sj1, \hyperlink{structpf__paramT}{pf_paramT} *P)\{
00580   \textcolor{keywordtype}{double} energy = 1.0;
00581   \textcolor{keywordflow}{if}(si1 >= 0 && sj1 >= 0)\{
00582     energy *= P->expmismatchM[type][si1][sj1];
00583   \}
00584   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(si1 >= 0)\{
00585     energy *= P->expdangle5[type][si1];
00586   \}
00587   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(sj1 >= 0)\{
00588     energy *= P->expdangle3[type][sj1];
00589   \}
00590 
00591   \textcolor{keywordflow}{if}(type > 2)
00592     energy *= P->expTermAU;
00593 
00594   energy *= P->expMLintern[type];
00595   \textcolor{keywordflow}{return} energy;
00596 \}
00597 
00598 INLINE  PRIVATE \textcolor{keywordtype}{double} exp\_E\_ExtLoop(\textcolor{keywordtype}{int} type, \textcolor{keywordtype}{int} si1, \textcolor{keywordtype}{int} sj1, \hyperlink{structpf__paramT}{pf_paramT} *P)\{
00599   \textcolor{keywordtype}{double} energy = 1.0;
00600   \textcolor{keywordflow}{if}(si1 >= 0 && sj1 >= 0)\{
00601     energy *= P->expmismatchExt[type][si1][sj1];
00602   \}
00603   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(si1 >= 0)\{
00604     energy *= P->expdangle5[type][si1];
00605   \}
00606   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(sj1 >= 0)\{
00607     energy *= P->expdangle3[type][sj1];
00608   \}
00609 
00610   \textcolor{keywordflow}{if}(type > 2)
00611     energy *= P->expTermAU;
00612 
00613   \textcolor{keywordflow}{return} energy;
00614 \}
00615 
00616 INLINE  PRIVATE \textcolor{keywordtype}{int}     E\_IntLoop\_Co(\textcolor{keywordtype}{int} type, \textcolor{keywordtype}{int} type\_2, \textcolor{keywordtype}{int} i, \textcolor{keywordtype}{int} j, \textcolor{keywordtype}{int} p, \textcolor{keywordtype}{i
      nt} q, \textcolor{keywordtype}{int} cutpoint, \textcolor{keywordtype}{short} si1, \textcolor{keywordtype}{short} sj1, \textcolor{keywordtype}{short} sp1, \textcolor{keywordtype}{short} sq1, \textcolor{keywordtype}{int} dangles, 
      \hyperlink{structparamT}{paramT} *P)\{
00617   \textcolor{keywordtype}{int} energy = 0;
00618   \textcolor{keywordflow}{if}(type > 2)   energy += P->TerminalAU;
00619   \textcolor{keywordflow}{if}(type\_2 > 2) energy += P->TerminalAU;
00620 
00621   \textcolor{keywordflow}{if}(!dangles) \textcolor{keywordflow}{return} energy;
00622 
00623   \textcolor{keywordtype}{int} ci = (i>=cutpoint)||((i+1)<cutpoint);
00624   \textcolor{keywordtype}{int} cj = ((j-1)>=cutpoint)||(j<cutpoint);
00625   \textcolor{keywordtype}{int} cp = ((p-1)>=cutpoint)||(p<cutpoint);
00626   \textcolor{keywordtype}{int} cq = (q>=cutpoint)||((q+1)<cutpoint);
00627 
00628   \textcolor{keywordtype}{int} d3    = ci  ? P->dangle3[type][si1]   : 0;
00629   \textcolor{keywordtype}{int} d5    = cj  ? P->dangle5[type][sj1]   : 0;
00630   \textcolor{keywordtype}{int} d5\_2  = cp  ? P->dangle5[type\_2][sp1] : 0;
00631   \textcolor{keywordtype}{int} d3\_2  = cq  ? P->dangle3[type\_2][sq1] : 0;
00632 
00633   \textcolor{keywordtype}{int} tmm   = (cj && ci) ? P->mismatchExt[type][sj1][si1]   : d5 + d3;
00634   \textcolor{keywordtype}{int} tmm\_2 = (cp && cq) ? P->mismatchExt[type\_2][sp1][sq1] : d5\_2 + d3\_2;
00635 
00636   \textcolor{keywordflow}{if}(dangles == 2) \textcolor{keywordflow}{return} energy + tmm + tmm\_2;
00637 
00638   \textcolor{comment}{/* now we may have non-double dangles only */}
00639   \textcolor{keywordflow}{if}(i+2 < p)\{
00640     \textcolor{keywordflow}{if}(q+2 < j)\{ energy += tmm + tmm\_2;\}
00641     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(q+2 == j)\{ energy += (cj && cq) ? \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(tmm + d5\_2, tmm\_2 + d3) : tmm 
      + tmm\_2;\}
00642     \textcolor{keywordflow}{else} energy += d3 + d5\_2;
00643   \}
00644   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(i+2 == p)\{
00645     \textcolor{keywordflow}{if}(q+2 < j)\{ energy += (ci && cp) ? \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(tmm + d3\_2, tmm\_2 + d5) : tmm + tmm\_
      2;\}
00646     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(q+2 == j)\{
00647       energy += \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(tmm, \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(tmm\_2, \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(d5 + d5\_2, d3 + d3\_2)));
00648     \}
00649     \textcolor{keywordflow}{else} energy += \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(d3, d5\_2);
00650   \}
00651   \textcolor{keywordflow}{else}\{
00652     \textcolor{keywordflow}{if}(q+2 < j)\{ energy += d5 + d3\_2;\}
00653     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(q+2 == j)\{ energy += \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(d5, d3\_2);\}
00654   \}
00655   \textcolor{keywordflow}{return} energy;
00656 \}
00657 
00658 \textcolor{preprocessor}{#endif}
\end{alltt}\end{footnotesize}
