Add missing doc files
[jabaws.git] / binaries / src / ViennaRNA / doc / latex / loop__energies_8h_source.tex
1 \hypertarget{loop__energies_8h}{\section{loop\-\_\-energies.\-h}
2 \label{loop__energies_8h}\index{/home/asherstnev/\-Projects/\-Java.\-projects/jabaws/secure-\/git/develop/binaries/src/\-Vienna\-R\-N\-A/\-H/loop\-\_\-energies.\-h@{/home/asherstnev/\-Projects/\-Java.\-projects/jabaws/secure-\/git/develop/binaries/src/\-Vienna\-R\-N\-A/\-H/loop\-\_\-energies.\-h}}
3 }
4
5 \begin{DoxyCode}
6 00001 \textcolor{preprocessor}{#ifndef \_\_VIENNA\_RNA\_PACKAGE\_LOOP\_ENERGIES\_H\_\_}
7 00002 \textcolor{preprocessor}{}\textcolor{preprocessor}{#define \_\_VIENNA\_RNA\_PACKAGE\_LOOP\_ENERGIES\_H\_\_}
8 00003 \textcolor{preprocessor}{}
9 00004 \textcolor{preprocessor}{#include <stdio.h>}
10 00005 \textcolor{preprocessor}{#include <stdlib.h>}
11 00006 \textcolor{preprocessor}{#include <math.h>}
12 00007 \textcolor{preprocessor}{#include <ctype.h>}
13 00008 \textcolor{preprocessor}{#include <string.h>}
14 00009 \textcolor{preprocessor}{#include "\hyperlink{params_8h}{params.h}"}
15 00010 \textcolor{preprocessor}{#include "\hyperlink{fold__vars_8h}{fold\_vars.h}"}
16 00011 \textcolor{preprocessor}{#include "energy\_par.h"}
17 00012 
18 00013 \textcolor{preprocessor}{#ifdef \_\_GNUC\_\_}
19 00014 \textcolor{preprocessor}{}\textcolor{preprocessor}{# define INLINE inline}
20 00015 \textcolor{preprocessor}{}\textcolor{preprocessor}{#else}
21 00016 \textcolor{preprocessor}{}\textcolor{preprocessor}{# define INLINE}
22 00017 \textcolor{preprocessor}{}\textcolor{preprocessor}{#endif}
23 00018 \textcolor{preprocessor}{}
24 00054 INLINE  PRIVATE \textcolor{keywordtype}{int} E\_MLstem( \textcolor{keywordtype}{int} type,
25 00055                               \textcolor{keywordtype}{int} si1,
26 00056                               \textcolor{keywordtype}{int} sj1,
27 00057                               \hyperlink{structparamT}{paramT} *P);
28 00058 
29 00065 INLINE  PRIVATE \textcolor{keywordtype}{double} exp\_E\_MLstem(\textcolor{keywordtype}{int} type,
30 00066                                     \textcolor{keywordtype}{int} si1,
31 00067                                     \textcolor{keywordtype}{int} sj1,
32 00068                                     \hyperlink{structpf__paramT}{pf\_paramT} *P);
33 00069 
34 00089 INLINE  PRIVATE \textcolor{keywordtype}{int} E\_ExtLoop(\textcolor{keywordtype}{int} type,
35 00090                               \textcolor{keywordtype}{int} si1,
36 00091                               \textcolor{keywordtype}{int} sj1,
37 00092                               \hyperlink{structparamT}{paramT} *P);
38 00093 
39 00100 INLINE  PRIVATE \textcolor{keywordtype}{double} exp\_E\_ExtLoop( \textcolor{keywordtype}{int} type,
40 00101                                       \textcolor{keywordtype}{int} si1,
41 00102                                       \textcolor{keywordtype}{int} sj1,
42 00103                                       \hyperlink{structpf__paramT}{pf\_paramT} *P);
43 00104 
44 00149 INLINE  PRIVATE \textcolor{keywordtype}{int} \hyperlink{loop__energies_8h_a3e5ad89f451254b1fe366d77aa8ff7bd}{E\_IntLoop}(\textcolor{keywordtype}{int} n1,
45 00150                               \textcolor{keywordtype}{int} n2,
46 00151                               \textcolor{keywordtype}{int} type,
47 00152                               \textcolor{keywordtype}{int} type\_2,
48 00153                               \textcolor{keywordtype}{int} si1,
49 00154                               \textcolor{keywordtype}{int} sj1,
50 00155                               \textcolor{keywordtype}{int} sp1,
51 00156                               \textcolor{keywordtype}{int} sq1,
52 00157                               \hyperlink{structparamT}{paramT} *P);
53 00158 
54 00159 
55 00191 INLINE  PRIVATE \textcolor{keywordtype}{int} \hyperlink{loop__energies_8h_aa362183cf6db89a10cdb0f5c4bd180c6}{E\_Hairpin}(\textcolor{keywordtype}{int} size,
56 00192                               \textcolor{keywordtype}{int} type,
57 00193                               \textcolor{keywordtype}{int} si1,
58 00194                               \textcolor{keywordtype}{int} sj1,
59 00195                               \textcolor{keyword}{const} \textcolor{keywordtype}{char} *\textcolor{keywordtype}{string},
60 00196                               \hyperlink{structparamT}{paramT} *P);
61 00197 
62 00243 INLINE  PRIVATE \textcolor{keywordtype}{int} \hyperlink{loop__energies_8h_af5a6594eba9b2622cb47076650c69819}{E\_Stem}( \textcolor{keywordtype}{int} type,
63 00244                             \textcolor{keywordtype}{int} si1,
64 00245                             \textcolor{keywordtype}{int} sj1,
65 00246                             \textcolor{keywordtype}{int} extLoop,
66 00247                             \hyperlink{structparamT}{paramT} *P);
67 00248 
68 00257 INLINE  PRIVATE \textcolor{keywordtype}{double} \hyperlink{loop__energies_8h_a76cc24ec96199e04beddad13e7891e21}{exp\_E\_Stem}(\textcolor{keywordtype}{int} type,
69 00258                                   \textcolor{keywordtype}{int} si1,
70 00259                                   \textcolor{keywordtype}{int} sj1,
71 00260                                   \textcolor{keywordtype}{int} extLoop,
72 00261                                   \hyperlink{structpf__paramT}{pf\_paramT} *P);
73 00262 
74 00280 INLINE  PRIVATE \textcolor{keywordtype}{double} \hyperlink{loop__energies_8h_a0e128184bb097dc2da33706f33b555a6}{exp\_E\_Hairpin}( \textcolor{keywordtype}{int} u,
75 00281                                       \textcolor{keywordtype}{int} type,
76 00282                                       \textcolor{keywordtype}{short} si1,
77 00283                                       \textcolor{keywordtype}{short} sj1,
78 00284                                       \textcolor{keyword}{const} \textcolor{keywordtype}{char} *\textcolor{keywordtype}{string},
79 00285                                       \hyperlink{structpf__paramT}{pf\_paramT} *P);
80 00286 
81 00306 INLINE  PRIVATE \textcolor{keywordtype}{double}  \hyperlink{loop__energies_8h_aa5e98e524e2a41e290b942b09544bc9e}{exp\_E\_IntLoop}(\textcolor{keywordtype}{int} u1,
82 00307                                       \textcolor{keywordtype}{int} u2,
83 00308                                       \textcolor{keywordtype}{int} type,
84 00309                                       \textcolor{keywordtype}{int} type2,
85 00310                                       \textcolor{keywordtype}{short} si1,
86 00311                                       \textcolor{keywordtype}{short} sj1,
87 00312                                       \textcolor{keywordtype}{short} sp1,
88 00313                                       \textcolor{keywordtype}{short} sq1,
89 00314                                       \hyperlink{structpf__paramT}{pf\_paramT} *P);
90 00315 
91 00316 
92 00317 \textcolor{comment}{/*}
93 00318 \textcolor{comment}{#################################}
94 00319 \textcolor{comment}{# BEGIN OF FUNCTION DEFINITIONS #}
95 00320 \textcolor{comment}{#################################}
96 00321 \textcolor{comment}{*/}
97 \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}{string}, 
98       \hyperlink{structparamT}{paramT} *P)\{
99 00323   \textcolor{keywordtype}{int} energy;
100 00324 
101 00325   energy = (size <= 30) ? P->hairpin[size] : P->hairpin[30]+(\textcolor{keywordtype}{int})(P->lxc*log((size)/30.));
102 00326   \textcolor{keywordflow}{if} (P->\hyperlink{structparamT_aeb912822ef912705bc202b14f9d71ad9}{model\_details}.\hyperlink{structmodel__detailsT_a9d73fde17b0465311a80f607faa85617}{special\_hp})\{
103 00327     \textcolor{keywordflow}{if} (size == 4) \{ \textcolor{comment}{/* check for tetraloop bonus */}
104 00328       \textcolor{keywordtype}{char} tl[7]=\{0\}, *ts;
105 00329       strncpy(tl, \textcolor{keywordtype}{string}, 6);
106 00330       \textcolor{keywordflow}{if} ((ts=strstr(P->Tetraloops, tl)))
107 00331         \textcolor{keywordflow}{return} (P->Tetraloop\_E[(ts - P->Tetraloops)/7]);
108 00332     \}
109 00333     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (size == 6) \{
110 00334       \textcolor{keywordtype}{char} tl[9]=\{0\}, *ts;
111 00335       strncpy(tl, \textcolor{keywordtype}{string}, 8);
112 00336       \textcolor{keywordflow}{if} ((ts=strstr(P->Hexaloops, tl)))
113 00337         \textcolor{keywordflow}{return} (energy = P->Hexaloop\_E[(ts - P->Hexaloops)/9]);
114 00338     \}
115 00339     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (size == 3) \{
116 00340       \textcolor{keywordtype}{char} tl[6]=\{0,0,0,0,0,0\}, *ts;
117 00341       strncpy(tl, \textcolor{keywordtype}{string}, 5);
118 00342       \textcolor{keywordflow}{if} ((ts=strstr(P->Triloops, tl))) \{
119 00343         \textcolor{keywordflow}{return} (P->Triloop\_E[(ts - P->Triloops)/6]);
120 00344       \}
121 00345       \textcolor{keywordflow}{return} (energy + (type>2 ? P->TerminalAU : 0));
122 00346     \}
123 00347   \}
124 00348   energy += P->mismatchH[type][si1][sj1];
125 00349 
126 00350   \textcolor{keywordflow}{return} energy;
127 00351 \}
128 00352 
129 \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}
130        sq1, \hyperlink{structparamT}{paramT} *P)\{
131 00354   \textcolor{comment}{/* compute energy of degree 2 loop (stack bulge or interior) */}
132 00355   \textcolor{keywordtype}{int} nl, ns, energy;
133 00356   energy = \hyperlink{energy__const_8h_a12c2040f25d8e3a7b9e1c2024c618cb6}{INF};
134 00357 
135 00358   \textcolor{keywordflow}{if} (n1>n2) \{ nl=n1; ns=n2;\}
136 00359   \textcolor{keywordflow}{else} \{nl=n2; ns=n1;\}
137 00360 
138 00361   \textcolor{keywordflow}{if} (nl == 0)
139 00362     \textcolor{keywordflow}{return} P->stack[type][type\_2];  \textcolor{comment}{/* stack */}
140 00363 
141 00364   \textcolor{keywordflow}{if} (ns==0) \{                      \textcolor{comment}{/* bulge */}
142 00365     energy = (nl<=\hyperlink{energy__const_8h_ad1bd6eabac419670ddd3c9ed82145988}{MAXLOOP})?P->bulge[nl]:
143 00366       (P->bulge[30]+(\textcolor{keywordtype}{int})(P->lxc*log(nl/30.)));
144 00367     \textcolor{keywordflow}{if} (nl==1) energy += P->stack[type][type\_2];
145 00368     \textcolor{keywordflow}{else} \{
146 00369       \textcolor{keywordflow}{if} (type>2) energy += P->TerminalAU;
147 00370       \textcolor{keywordflow}{if} (type\_2>2) energy += P->TerminalAU;
148 00371     \}
149 00372     \textcolor{keywordflow}{return} energy;
150 00373   \}
151 00374   \textcolor{keywordflow}{else} \{                            \textcolor{comment}{/* interior loop */}
152 00375     \textcolor{keywordflow}{if} (ns==1) \{
153 00376       \textcolor{keywordflow}{if} (nl==1)                    \textcolor{comment}{/* 1x1 loop */}
154 00377         \textcolor{keywordflow}{return} P->int11[type][type\_2][si1][sj1];
155 00378       \textcolor{keywordflow}{if} (nl==2) \{                  \textcolor{comment}{/* 2x1 loop */}
156 00379         \textcolor{keywordflow}{if} (n1==1)
157 00380           energy = P->int21[type][type\_2][si1][sq1][sj1];
158 00381         \textcolor{keywordflow}{else}
159 00382           energy = P->int21[type\_2][type][sq1][si1][sp1];
160 00383         \textcolor{keywordflow}{return} energy;
161 00384       \}
162 00385       \textcolor{keywordflow}{else} \{  \textcolor{comment}{/* 1xn loop */}
163 00386         energy = (nl+1<=\hyperlink{energy__const_8h_ad1bd6eabac419670ddd3c9ed82145988}{MAXLOOP})?(P->internal\_loop[nl+1]) : (P->internal\_loop[30]+(int)(P->lxc*log((
164       nl+1)/30.)));
165 00387         energy += \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(MAX\_NINIO, (nl-ns)*P->ninio[2]);
166 00388         energy += P->mismatch1nI[type][si1][sj1] + P->mismatch1nI[type\_2][sq1][sp1];
167 00389         \textcolor{keywordflow}{return} energy;
168 00390       \}
169 00391     \}
170 00392     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (ns==2) \{
171 00393       \textcolor{keywordflow}{if}(nl==2)      \{              \textcolor{comment}{/* 2x2 loop */}
172 00394         \textcolor{keywordflow}{return} P->int22[type][type\_2][si1][sp1][sq1][sj1];\}
173 00395       \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (nl==3)\{              \textcolor{comment}{/* 2x3 loop */}
174 00396         energy = P->internal\_loop[5]+P->ninio[2];
175 00397         energy += P->mismatch23I[type][si1][sj1] + P->mismatch23I[type\_2][sq1][sp1];
176 00398         \textcolor{keywordflow}{return} energy;
177 00399       \}
178 00400 
179 00401     \}
180 00402     \{ \textcolor{comment}{/* generic interior loop (no else here!)*/}
181 00403       energy = (n1+n2<=\hyperlink{energy__const_8h_ad1bd6eabac419670ddd3c9ed82145988}{MAXLOOP})?(P->internal\_loop[n1+n2]) : (P->internal\_loop[30]+(int)(P->lxc*log((
182       n1+n2)/30.)));
183 00404 
184 00405       energy += \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(MAX\_NINIO, (nl-ns)*P->ninio[2]);
185 00406 
186 00407       energy += P->mismatchI[type][si1][sj1] + P->mismatchI[type\_2][sq1][sp1];
187 00408     \}
188 00409   \}
189 00410   \textcolor{keywordflow}{return} energy;
190 00411 \}
191 00412 
192 \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)\{
193 00414   \textcolor{keywordtype}{int} energy = 0;
194 00415   \textcolor{keywordtype}{int} d5 = (si1 >= 0) ? P->dangle5[type][si1] : 0;
195 00416   \textcolor{keywordtype}{int} d3 = (sj1 >= 0) ? P->dangle3[type][sj1] : 0;
196 00417 
197 00418   \textcolor{keywordflow}{if}(type > 2)
198 00419     energy += P->TerminalAU;
199 00420 
200 00421   \textcolor{keywordflow}{if}(si1 >= 0 && sj1 >= 0)
201 00422     energy += (extLoop) ? P->mismatchExt[type][si1][sj1] : P->mismatchM[type][si1][sj1];
202 00423   \textcolor{keywordflow}{else}
203 00424     energy += d5 + d3;
204 00425 
205 00426   \textcolor{keywordflow}{if}(!extLoop) energy += P->MLintern[type];
206 00427   \textcolor{keywordflow}{return} energy;
207 00428 \}
208 00429 
209 00430 INLINE  PRIVATE \textcolor{keywordtype}{int} E\_ExtLoop(\textcolor{keywordtype}{int} type, \textcolor{keywordtype}{int} si1, \textcolor{keywordtype}{int} sj1, \hyperlink{structparamT}{paramT} *P)\{
210 00431   \textcolor{keywordtype}{int} energy = 0;
211 00432   \textcolor{keywordflow}{if}(si1 >= 0 && sj1 >= 0)\{
212 00433     energy += P->mismatchExt[type][si1][sj1];
213 00434   \}
214 00435   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (si1 >= 0)\{
215 00436     energy += P->dangle5[type][si1];
216 00437   \}
217 00438   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (sj1 >= 0)\{
218 00439     energy += P->dangle3[type][sj1];
219 00440   \}
220 00441 
221 00442   \textcolor{keywordflow}{if}(type > 2)
222 00443     energy += P->TerminalAU;
223 00444 
224 00445   \textcolor{keywordflow}{return} energy;
225 00446 \}
226 00447 
227 00448 INLINE  PRIVATE \textcolor{keywordtype}{int} E\_MLstem(\textcolor{keywordtype}{int} type, \textcolor{keywordtype}{int} si1, \textcolor{keywordtype}{int} sj1, \hyperlink{structparamT}{paramT} *P)\{
228 00449   \textcolor{keywordtype}{int} energy = 0;
229 00450   \textcolor{keywordflow}{if}(si1 >= 0 && sj1 >= 0)\{
230 00451     energy += P->mismatchM[type][si1][sj1];
231 00452   \}
232 00453   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (si1 >= 0)\{
233 00454     energy += P->dangle5[type][si1];
234 00455   \}
235 00456   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (sj1 >= 0)\{
236 00457     energy += P->dangle3[type][sj1];
237 00458   \}
238 00459 
239 00460   \textcolor{keywordflow}{if}(type > 2)
240 00461     energy += P->TerminalAU;
241 00462 
242 00463   energy += P->MLintern[type];
243 00464 
244 00465   \textcolor{keywordflow}{return} energy;
245 00466 \}
246 00467 
247 \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}
248       , \hyperlink{structpf__paramT}{pf\_paramT} *P)\{
249 00469   \textcolor{keywordtype}{double} q, kT;
250 00470   kT = P->kT;   \textcolor{comment}{/* kT in cal/mol  */}
251 00471 
252 00472   \textcolor{keywordflow}{if}(u <= 30)
253 00473     q = P->exphairpin[u];
254 00474   \textcolor{keywordflow}{else}
255 00475     q = P->exphairpin[30] * exp( -(P->lxc*log( u/30.))*10./kT);
256 00476 
257 00477   \textcolor{keywordflow}{if}(u < 3) \textcolor{keywordflow}{return} q; \textcolor{comment}{/* should only be the case when folding alignments */}
258 00478 
259 00479   \textcolor{keywordflow}{if} ((P->\hyperlink{structpf__paramT_a43ec875779c5e7c8bf5fa7e837ec6d09}{model\_details}.\hyperlink{structmodel__detailsT_a9d73fde17b0465311a80f607faa85617}{special\_hp})&&(u==4)) \{
260 00480     \textcolor{keywordtype}{char} tl[7]=\{0,0,0,0,0,0,0\}, *ts;
261 00481     strncpy(tl, \textcolor{keywordtype}{string}, 6);
262 00482     \textcolor{keywordflow}{if} ((ts=strstr(P->Tetraloops, tl)))\{
263 00483       \textcolor{keywordflow}{if}(type != 7)
264 00484         \textcolor{keywordflow}{return} (P->exptetra[(ts-P->Tetraloops)/7]);
265 00485       \textcolor{keywordflow}{else}
266 00486         q *= P->exptetra[(ts-P->Tetraloops)/7];
267 00487     \}
268 00488   \}
269 00489   \textcolor{keywordflow}{if} ((\hyperlink{fold__vars_8h_a4f6265bdf0ead7ff4628a360adbfd77e}{tetra\_loop})&&(u==6)) \{
270 00490     \textcolor{keywordtype}{char} tl[9]=\{0,0,0,0,0,0,0,0,0\}, *ts;
271 00491     strncpy(tl, \textcolor{keywordtype}{string}, 6);
272 00492     \textcolor{keywordflow}{if} ((ts=strstr(P->Hexaloops, tl)))
273 00493       \textcolor{keywordflow}{return}  (P->exphex[(ts-P->Hexaloops)/9]);
274 00494   \}
275 00495   \textcolor{keywordflow}{if} (u==3) \{
276 00496     \textcolor{keywordtype}{char} tl[6]=\{0,0,0,0,0,0\}, *ts;
277 00497     strncpy(tl, \textcolor{keywordtype}{string}, 5);
278 00498     \textcolor{keywordflow}{if} ((ts=strstr(P->Triloops, tl)))
279 00499       \textcolor{keywordflow}{return} (P->exptri[(ts-P->Triloops)/6]);
280 00500     \textcolor{keywordflow}{if} (type>2)
281 00501       q *= P->expTermAU;
282 00502   \}
283 00503   \textcolor{keywordflow}{else} \textcolor{comment}{/* no mismatches for tri-loops */}
284 00504     q *= P->expmismatchH[type][si1][sj1];
285 00505 
286 00506   \textcolor{keywordflow}{return} q;
287 00507 \}
288 00508 
289 \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} si1, \textcolor{keywordtype}{short} sj1
290       , \textcolor{keywordtype}{short} sp1, \textcolor{keywordtype}{short} sq1, \hyperlink{structpf__paramT}{pf\_paramT} *P)\{
291 00510   \textcolor{keywordtype}{int} ul, us, no\_close = 0;
292 00511   \textcolor{keywordtype}{double} z = 0.;
293 00512 
294 00513   \textcolor{keywordflow}{if} ((\hyperlink{fold__vars_8h_aa8d1c7b92489179e1eafa562b7bdd259}{no\_closingGU}) && ((type2==3)||(type2==4)||(type==3)||(type==4)))
295 00514     no\_close = 1;
296 00515 
297 00516   \textcolor{keywordflow}{if} (u1>u2) \{ ul=u1; us=u2;\}
298 00517   \textcolor{keywordflow}{else} \{ul=u2; us=u1;\}
299 00518 
300 00519   \textcolor{keywordflow}{if} (ul==0) \textcolor{comment}{/* stack */}
301 00520     z = P->expstack[type][type2];
302 00521   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(!no\_close)\{
303 00522     \textcolor{keywordflow}{if} (us==0) \{                      \textcolor{comment}{/* bulge */}
304 00523       z = P->expbulge[ul];
305 00524       \textcolor{keywordflow}{if} (ul==1) z *= P->expstack[type][type2];
306 00525       \textcolor{keywordflow}{else} \{
307 00526         \textcolor{keywordflow}{if} (type>2) z *= P->expTermAU;
308 00527         \textcolor{keywordflow}{if} (type2>2) z *= P->expTermAU;
309 00528       \}
310 00529       \textcolor{keywordflow}{return} z;
311 00530     \}
312 00531     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (us==1) \{
313 00532       \textcolor{keywordflow}{if} (ul==1)\{                    \textcolor{comment}{/* 1x1 loop */}
314 00533         \textcolor{keywordflow}{return} P->expint11[type][type2][si1][sj1];
315 00534       \}
316 00535       \textcolor{keywordflow}{if} (ul==2) \{                  \textcolor{comment}{/* 2x1 loop */}
317 00536         \textcolor{keywordflow}{if} (u1==1)
318 00537           \textcolor{keywordflow}{return} P->expint21[type][type2][si1][sq1][sj1];
319 00538         \textcolor{keywordflow}{else}
320 00539           \textcolor{keywordflow}{return} P->expint21[type2][type][sq1][si1][sp1];
321 00540       \}
322 00541       \textcolor{keywordflow}{else} \{  \textcolor{comment}{/* 1xn loop */}
323 00542         z = P->expinternal[ul+us] * P->expmismatch1nI[type][si1][sj1] * P->expmismatch1nI[type2][sq1][sp1];
324 00543         \textcolor{keywordflow}{return} z * P->expninio[2][ul-us];
325 00544       \}
326 00545     \}
327 00546     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (us==2) \{
328 00547       \textcolor{keywordflow}{if}(ul==2) \textcolor{comment}{/* 2x2 loop */}
329 00548         \textcolor{keywordflow}{return} P->expint22[type][type2][si1][sp1][sq1][sj1];
330 00549       \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(ul==3)\{              \textcolor{comment}{/* 2x3 loop */}
331 00550         z = P->expinternal[5]*P->expmismatch23I[type][si1][sj1]*P->expmismatch23I[type2][sq1][sp1];
332 00551         \textcolor{keywordflow}{return} z * P->expninio[2][1];
333 00552       \}
334 00553     \}
335 00554     \textcolor{comment}{/* generic interior loop (no else here!)*/}
336 00555     z = P->expinternal[ul+us] * P->expmismatchI[type][si1][sj1] * P->expmismatchI[type2][sq1][sp1];
337 00556     \textcolor{keywordflow}{return} z * P->expninio[2][ul-us];
338 00557 
339 00558   \}
340 00559   \textcolor{keywordflow}{return} z;
341 00560 \}
342 00561 
343 \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, 
344       \hyperlink{structpf__paramT}{pf\_paramT} *P)\{
345 00563   \textcolor{keywordtype}{double} energy = 1.0;
346 00564   \textcolor{keywordtype}{double} d5 = (si1 >= 0) ? P->expdangle5[type][si1] : 1.;
347 00565   \textcolor{keywordtype}{double} d3 = (sj1 >= 0) ? P->expdangle3[type][sj1] : 1.;
348 00566 
349 00567   \textcolor{keywordflow}{if}(type > 2)
350 00568     energy *= P->expTermAU;
351 00569 
352 00570   \textcolor{keywordflow}{if}(si1 >= 0 && sj1 >= 0)
353 00571     energy *= (extLoop) ? P->expmismatchExt[type][si1][sj1] : P->expmismatchM[type][si1][sj1];
354 00572   \textcolor{keywordflow}{else}
355 00573     energy *= d5 * d3;
356 00574 
357 00575   \textcolor{keywordflow}{if}(!extLoop) energy *= P->expMLintern[type];
358 00576   \textcolor{keywordflow}{return} energy;
359 00577 \}
360 00578 
361 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)\{
362 00580   \textcolor{keywordtype}{double} energy = 1.0;
363 00581   \textcolor{keywordflow}{if}(si1 >= 0 && sj1 >= 0)\{
364 00582     energy *= P->expmismatchM[type][si1][sj1];
365 00583   \}
366 00584   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(si1 >= 0)\{
367 00585     energy *= P->expdangle5[type][si1];
368 00586   \}
369 00587   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(sj1 >= 0)\{
370 00588     energy *= P->expdangle3[type][sj1];
371 00589   \}
372 00590 
373 00591   \textcolor{keywordflow}{if}(type > 2)
374 00592     energy *= P->expTermAU;
375 00593 
376 00594   energy *= P->expMLintern[type];
377 00595   \textcolor{keywordflow}{return} energy;
378 00596 \}
379 00597 
380 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)\{
381 00599   \textcolor{keywordtype}{double} energy = 1.0;
382 00600   \textcolor{keywordflow}{if}(si1 >= 0 && sj1 >= 0)\{
383 00601     energy *= P->expmismatchExt[type][si1][sj1];
384 00602   \}
385 00603   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(si1 >= 0)\{
386 00604     energy *= P->expdangle5[type][si1];
387 00605   \}
388 00606   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(sj1 >= 0)\{
389 00607     energy *= P->expdangle3[type][sj1];
390 00608   \}
391 00609 
392 00610   \textcolor{keywordflow}{if}(type > 2)
393 00611     energy *= P->expTermAU;
394 00612 
395 00613   \textcolor{keywordflow}{return} energy;
396 00614 \}
397 00615 
398 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}{int} q, \textcolor{keywordtype}{int} cutpoint, \textcolor{keywordtype}{short} 
399       si1, \textcolor{keywordtype}{short} sj1, \textcolor{keywordtype}{short} sp1, \textcolor{keywordtype}{short} sq1, \textcolor{keywordtype}{int} dangles, \hyperlink{structparamT}{paramT} *P)\{
400 00617   \textcolor{keywordtype}{int} energy = 0;
401 00618   \textcolor{keywordflow}{if}(type > 2)   energy += P->TerminalAU;
402 00619   \textcolor{keywordflow}{if}(type\_2 > 2) energy += P->TerminalAU;
403 00620 
404 00621   \textcolor{keywordflow}{if}(!dangles) \textcolor{keywordflow}{return} energy;
405 00622 
406 00623   \textcolor{keywordtype}{int} ci = (i>=cutpoint)||((i+1)<cutpoint);
407 00624   \textcolor{keywordtype}{int} cj = ((j-1)>=cutpoint)||(j<cutpoint);
408 00625   \textcolor{keywordtype}{int} cp = ((p-1)>=cutpoint)||(p<cutpoint);
409 00626   \textcolor{keywordtype}{int} cq = (q>=cutpoint)||((q+1)<cutpoint);
410 00627 
411 00628   \textcolor{keywordtype}{int} d3    = ci  ? P->dangle3[type][si1]   : 0;
412 00629   \textcolor{keywordtype}{int} d5    = cj  ? P->dangle5[type][sj1]   : 0;
413 00630   \textcolor{keywordtype}{int} d5\_2  = cp  ? P->dangle5[type\_2][sp1] : 0;
414 00631   \textcolor{keywordtype}{int} d3\_2  = cq  ? P->dangle3[type\_2][sq1] : 0;
415 00632 
416 00633   \textcolor{keywordtype}{int} tmm   = (cj && ci) ? P->mismatchExt[type][sj1][si1]   : d5 + d3;
417 00634   \textcolor{keywordtype}{int} tmm\_2 = (cp && cq) ? P->mismatchExt[type\_2][sp1][sq1] : d5\_2 + d3\_2;
418 00635 
419 00636   \textcolor{keywordflow}{if}(dangles == 2) \textcolor{keywordflow}{return} energy + tmm + tmm\_2;
420 00637 
421 00638   \textcolor{comment}{/* now we may have non-double dangles only */}
422 00639   \textcolor{keywordflow}{if}(i+2 < p)\{
423 00640     \textcolor{keywordflow}{if}(q+2 < j)\{ energy += tmm + tmm\_2;\}
424 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;\}
425 00642     \textcolor{keywordflow}{else} energy += d3 + d5\_2;
426 00643   \}
427 00644   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(i+2 == p)\{
428 00645     \textcolor{keywordflow}{if}(q+2 < j)\{ energy += (ci && cp) ? \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(tmm + d3\_2, tmm\_2 + d5) : tmm + tmm\_2;\}
429 00646     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(q+2 == j)\{
430 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)));
431 00648     \}
432 00649     \textcolor{keywordflow}{else} energy += \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(d3, d5\_2);
433 00650   \}
434 00651   \textcolor{keywordflow}{else}\{
435 00652     \textcolor{keywordflow}{if}(q+2 < j)\{ energy += d5 + d3\_2;\}
436 00653     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(q+2 == j)\{ energy += \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(d5, d3\_2);\}
437 00654   \}
438 00655   \textcolor{keywordflow}{return} energy;
439 00656 \}
440 00657 
441 00658 \textcolor{preprocessor}{#endif}
442 \end{DoxyCode}