\hypertarget{gquad_8h_source}{
\section{/homes/fmmarquesmadeira/Projects/jabaws/binaries/src/ViennaRNA/H/gquad.h}
}


\begin{footnotesize}\begin{alltt}
00001 \textcolor{preprocessor}{#ifndef \_\_VIENNA\_RNA\_PACKAGE\_GQUAD\_H\_\_}
00002 \textcolor{preprocessor}{}\textcolor{preprocessor}{#define \_\_VIENNA\_RNA\_PACKAGE\_GQUAD\_H\_\_}
00003 \textcolor{preprocessor}{}
00004 \textcolor{preprocessor}{#include "\hyperlink{data__structures_8h}{data_structures.h}"}
00005 
00006 \textcolor{preprocessor}{#ifndef INLINE}
00007 \textcolor{preprocessor}{}\textcolor{preprocessor}{#ifdef \_\_GNUC\_\_}
00008 \textcolor{preprocessor}{}\textcolor{preprocessor}{# define INLINE inline}
00009 \textcolor{preprocessor}{}\textcolor{preprocessor}{#else}
00010 \textcolor{preprocessor}{}\textcolor{preprocessor}{# define INLINE}
00011 \textcolor{preprocessor}{}\textcolor{preprocessor}{#endif}
00012 \textcolor{preprocessor}{}\textcolor{preprocessor}{#endif}
00013 \textcolor{preprocessor}{}
00020 \textcolor{keywordtype}{int}         E\_gquad(\textcolor{keywordtype}{int} L,
00021                     \textcolor{keywordtype}{int} l[3],
00022                     \hyperlink{structparamT}{paramT} *P);
00023 
00024 FLT\_OR\_DBL exp\_E\_gquad( \textcolor{keywordtype}{int} L,
00025                         \textcolor{keywordtype}{int} l[3],
00026                         \hyperlink{structpf__paramT}{pf_paramT} *pf);
00027 
00028 \textcolor{keywordtype}{int}         E\_gquad\_ali(\textcolor{keywordtype}{int} i,
00029                         \textcolor{keywordtype}{int} L,
00030                         \textcolor{keywordtype}{int} l[3],
00031                         \textcolor{keyword}{const} \textcolor{keywordtype}{short} **S,
00032                         \textcolor{keywordtype}{int} n\_seq,
00033                         \hyperlink{structparamT}{paramT} *P);
00034 
00035 
00036 \textcolor{keywordtype}{void}        E\_gquad\_ali\_en( \textcolor{keywordtype}{int} i,
00037                             \textcolor{keywordtype}{int} L,
00038                             \textcolor{keywordtype}{int} l[3],
00039                             \textcolor{keyword}{const} \textcolor{keywordtype}{short} **S,
00040                             \textcolor{keywordtype}{int} n\_seq,
00041                             \textcolor{keywordtype}{int} en[2],
00042                             \hyperlink{structparamT}{paramT} *P);
00043 
00060 \textcolor{keywordtype}{int}         *\hyperlink{gquad_8h_a8b0784c14fa1208d0aebbebdc1318b7a}{get_gquad_matrix}(\textcolor{keywordtype}{short} *S, \hyperlink{structparamT}{paramT} *P);
00061 
00062 \textcolor{keywordtype}{int}         *get\_gquad\_ali\_matrix(\textcolor{keywordtype}{short} *S\_cons,
00063                                   \textcolor{keywordtype}{short} **S,
00064                                   \textcolor{keywordtype}{int} n\_seq,
00065                                   \hyperlink{structparamT}{paramT} *P);
00066 
00067 FLT\_OR\_DBL  *get\_gquad\_pf\_matrix( \textcolor{keywordtype}{short} *S,
00068                                   FLT\_OR\_DBL *scale,
00069                                   \hyperlink{structpf__paramT}{pf_paramT} *pf);
00070 
00071 \textcolor{keywordtype}{int}         **get\_gquad\_L\_matrix( \textcolor{keywordtype}{short} *S,
00072                                   \textcolor{keywordtype}{int} start,
00073                                   \textcolor{keywordtype}{int} maxdist,
00074                                   \textcolor{keywordtype}{int} **g,
00075                                   \hyperlink{structparamT}{paramT} *P);
00076 
00077 \textcolor{keywordtype}{void}        get\_gquad\_pattern\_mfe(\textcolor{keywordtype}{short} *S,
00078                                   \textcolor{keywordtype}{int} i,
00079                                   \textcolor{keywordtype}{int} j,
00080                                   \hyperlink{structparamT}{paramT} *P,
00081                                   \textcolor{keywordtype}{int} *L,
00082                                   \textcolor{keywordtype}{int} l[3]);
00083 
00084 \textcolor{keywordtype}{void}        get\_gquad\_pattern\_pf( \textcolor{keywordtype}{short} *S,
00085                                   \textcolor{keywordtype}{int} i,
00086                                   \textcolor{keywordtype}{int} j,
00087                                   \hyperlink{structpf__paramT}{pf_paramT} *pf,
00088                                   \textcolor{keywordtype}{int} *L,
00089                                   \textcolor{keywordtype}{int} l[3]);
00090 
00091 \hyperlink{structplist}{plist}       *get\_plist\_gquad\_from\_pr( \textcolor{keywordtype}{short} *S,
00092                                       \textcolor{keywordtype}{int} gi,
00093                                       \textcolor{keywordtype}{int} gj,
00094                                       FLT\_OR\_DBL *G,
00095                                       FLT\_OR\_DBL *probs,
00096                                       FLT\_OR\_DBL *scale,
00097                                       \hyperlink{structpf__paramT}{pf_paramT} *pf);
00098 \hyperlink{structplist}{plist}       *get\_plist\_gquad\_from\_pr\_max(\textcolor{keywordtype}{short} *S,
00099                                       \textcolor{keywordtype}{int} gi,
00100                                       \textcolor{keywordtype}{int} gj,
00101                                       FLT\_OR\_DBL *G,
00102                                       FLT\_OR\_DBL *probs,
00103                                       FLT\_OR\_DBL *scale,
00104                                       \textcolor{keywordtype}{int} *L,
00105                                       \textcolor{keywordtype}{int} l[3],
00106                                       \hyperlink{structpf__paramT}{pf_paramT} *pf);
00107 
00108 \hyperlink{structplist}{plist}       *get\_plist\_gquad\_from\_db( \textcolor{keyword}{const} \textcolor{keywordtype}{char} *structure,
00109                                       \textcolor{keywordtype}{float} pr);
00110 
00121 \textcolor{keywordtype}{int}         \hyperlink{gquad_8h_ae41763215b9c64d2a7b67f0df8a28078}{parse_gquad}(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *struc, \textcolor{keywordtype}{int} *L, \textcolor{keywordtype}{int} l[3]);
00122 
00123 
00124 
\hypertarget{gquad_8h_source_l00142}{}\hyperlink{gquad_8h_a54475a8eb898fa1e8af8ab5f5375f3be}{00142} INLINE  PRIVATE \textcolor{keywordtype}{int} \hyperlink{gquad_8h_a54475a8eb898fa1e8af8ab5f5375f3be}{backtrack_GQuad_IntLoop}(\textcolor{keywordtype}{int} c,
00143                                             \textcolor{keywordtype}{int} i,
00144                                             \textcolor{keywordtype}{int} j,
00145                                             \textcolor{keywordtype}{int} type,
00146                                             \textcolor{keywordtype}{short} *S,
00147                                             \textcolor{keywordtype}{int} *ggg,
00148                                             \textcolor{keywordtype}{int} *index,
00149                                             \textcolor{keywordtype}{int} *p,
00150                                             \textcolor{keywordtype}{int} *q,
00151                                             \hyperlink{structparamT}{paramT} *P)\{
00152 
00153   \textcolor{keywordtype}{int} energy, \hyperlink{fold__vars_8h_a72b511ed1201f7e23ec437e468790d74}{dangles}, k, l, maxl, minl, c0, l1;
00154   \textcolor{keywordtype}{short} si, sj;
00155 
00156   dangles = P->\hyperlink{structparamT_aeb912822ef912705bc202b14f9d71ad9}{model_details}.\hyperlink{structmodel__detailsT_a89f9df217a4a7f4351a642655976376b}{dangles};
00157   si      = S[i + 1];
00158   sj      = S[j - 1];
00159   energy  = 0;
00160 
00161   \textcolor{keywordflow}{if}(dangles == 2)
00162     energy += P->mismatchI[type][si][sj];
00163 
00164   \textcolor{keywordflow}{if}(type > 2)
00165     energy += P->TerminalAU;
00166 
00167   k = i + 1;
00168   \textcolor{keywordflow}{if}(S[k] == 3)\{
00169     \textcolor{keywordflow}{if}(k < j - VRNA\_GQUAD\_MIN\_BOX\_SIZE)\{
00170       minl  = j - i + k - \hyperlink{energy__const_8h_ad1bd6eabac419670ddd3c9ed82145988}{MAXLOOP} - 2;
00171       c0    = k + VRNA\_GQUAD\_MIN\_BOX\_SIZE - 1;
00172       minl  = \hyperlink{utils_8h_a33297b3679c713b0c4d897cd0fe3b122}{MAX2}(c0, minl);
00173       c0    = j - 3;
00174       maxl  = k + VRNA\_GQUAD\_MAX\_BOX\_SIZE + 1;
00175       maxl  = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(c0, maxl);
00176       \textcolor{keywordflow}{for}(l = minl; l < maxl; l++)\{
00177         \textcolor{keywordflow}{if}(S[l] != 3) \textcolor{keywordflow}{continue};
00178         \textcolor{keywordflow}{if}(c == energy + ggg[index[l] + k] + P->internal\_loop[j - l - 1])\{
00179           *p = k; *q = l;
00180           \textcolor{keywordflow}{return} 1;
00181         \}
00182       \}
00183     \}
00184   \}
00185 
00186   \textcolor{keywordflow}{for}(k = i + 2;
00187       k < j - VRNA\_GQUAD\_MIN\_BOX\_SIZE;
00188       k++)\{
00189     l1    = k - i - 1;
00190     \textcolor{keywordflow}{if}(l1>\hyperlink{energy__const_8h_ad1bd6eabac419670ddd3c9ed82145988}{MAXLOOP}) \textcolor{keywordflow}{break};
00191     \textcolor{keywordflow}{if}(S[k] != 3) \textcolor{keywordflow}{continue};
00192     minl  = j - i + k - \hyperlink{energy__const_8h_ad1bd6eabac419670ddd3c9ed82145988}{MAXLOOP} - 2;
00193     c0    = k + VRNA\_GQUAD\_MIN\_BOX\_SIZE - 1;
00194     minl  = \hyperlink{utils_8h_a33297b3679c713b0c4d897cd0fe3b122}{MAX2}(c0, minl);
00195     c0    = j - 1;
00196     maxl  = k + VRNA\_GQUAD\_MAX\_BOX\_SIZE + 1;
00197     maxl  = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(c0, maxl);
00198     \textcolor{keywordflow}{for}(l = minl; l < maxl; l++)\{
00199       \textcolor{keywordflow}{if}(S[l] != 3) \textcolor{keywordflow}{continue};
00200       \textcolor{keywordflow}{if}(c == energy + ggg[index[l] + k] + P->internal\_loop[l1 + j - l - 1])\{
00201         *p = k; *q = l;
00202         \textcolor{keywordflow}{return} 1;
00203       \}
00204     \}
00205   \}
00206 
00207   l = j - 1;
00208   \textcolor{keywordflow}{if}(S[l] == 3)
00209     \textcolor{keywordflow}{for}(k = i + 4;
00210         k < j - VRNA\_GQUAD\_MIN\_BOX\_SIZE;
00211         k++)\{
00212       l1    = k - i - 1;
00213       \textcolor{keywordflow}{if}(l1>\hyperlink{energy__const_8h_ad1bd6eabac419670ddd3c9ed82145988}{MAXLOOP}) \textcolor{keywordflow}{break};
00214       \textcolor{keywordflow}{if}(S[k] != 3) \textcolor{keywordflow}{continue};
00215       \textcolor{keywordflow}{if}(c == energy + ggg[index[l] + k] + P->internal\_loop[l1])\{
00216         *p = k; *q = l;
00217         \textcolor{keywordflow}{return} 1;
00218       \}
00219     \}
00220 
00221   \textcolor{keywordflow}{return} 0;
00222 \}
00223 
\hypertarget{gquad_8h_source_l00240}{}\hyperlink{gquad_8h_a118ec7289f1936bd810be7fe50b98212}{00240} INLINE  PRIVATE \textcolor{keywordtype}{int} \hyperlink{gquad_8h_a118ec7289f1936bd810be7fe50b98212}{backtrack_GQuad_IntLoop_L}(\textcolor{keywordtype}{int} c,
00241                                               \textcolor{keywordtype}{int} i,
00242                                               \textcolor{keywordtype}{int} j,
00243                                               \textcolor{keywordtype}{int} type,
00244                                               \textcolor{keywordtype}{short} *S,
00245                                               \textcolor{keywordtype}{int} **ggg,
00246                                               \textcolor{keywordtype}{int} maxdist,
00247                                               \textcolor{keywordtype}{int} *p,
00248                                               \textcolor{keywordtype}{int} *q,
00249                                               \hyperlink{structparamT}{paramT} *P)\{
00250 
00251   \textcolor{keywordtype}{int} energy, \hyperlink{fold__vars_8h_a72b511ed1201f7e23ec437e468790d74}{dangles}, k, l, maxl, minl, c0, l1;
00252   \textcolor{keywordtype}{short} si, sj;
00253 
00254   dangles = P->\hyperlink{structparamT_aeb912822ef912705bc202b14f9d71ad9}{model_details}.\hyperlink{structmodel__detailsT_a89f9df217a4a7f4351a642655976376b}{dangles};
00255   si      = S[i + 1];
00256   sj      = S[j - 1];
00257   energy  = 0;
00258 
00259   \textcolor{keywordflow}{if}(dangles == 2)
00260     energy += P->mismatchI[type][si][sj];
00261 
00262   \textcolor{keywordflow}{if}(type > 2)
00263     energy += P->TerminalAU;
00264 
00265   k = i + 1;
00266   \textcolor{keywordflow}{if}(S[k] == 3)\{
00267     \textcolor{keywordflow}{if}(k < j - VRNA\_GQUAD\_MIN\_BOX\_SIZE)\{
00268       minl  = j - i + k - \hyperlink{energy__const_8h_ad1bd6eabac419670ddd3c9ed82145988}{MAXLOOP} - 2;
00269       c0    = k + VRNA\_GQUAD\_MIN\_BOX\_SIZE - 1;
00270       minl  = \hyperlink{utils_8h_a33297b3679c713b0c4d897cd0fe3b122}{MAX2}(c0, minl);
00271       c0    = j - 3;
00272       maxl  = k + VRNA\_GQUAD\_MAX\_BOX\_SIZE + 1;
00273       maxl  = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(c0, maxl);
00274       \textcolor{keywordflow}{for}(l = minl; l < maxl; l++)\{
00275         \textcolor{keywordflow}{if}(S[l] != 3) \textcolor{keywordflow}{continue};
00276         \textcolor{keywordflow}{if}(c == energy + ggg[k][l - k] + P->internal\_loop[j - l - 1])\{
00277           *p = k; *q = l;
00278           \textcolor{keywordflow}{return} 1;
00279         \}
00280       \}
00281     \}
00282   \}
00283 
00284   \textcolor{keywordflow}{for}(k = i + 2;
00285       k < j - VRNA\_GQUAD\_MIN\_BOX\_SIZE;
00286       k++)\{
00287     l1    = k - i - 1;
00288     \textcolor{keywordflow}{if}(l1>\hyperlink{energy__const_8h_ad1bd6eabac419670ddd3c9ed82145988}{MAXLOOP}) \textcolor{keywordflow}{break};
00289     \textcolor{keywordflow}{if}(S[k] != 3) \textcolor{keywordflow}{continue};
00290     minl  = j - i + k - \hyperlink{energy__const_8h_ad1bd6eabac419670ddd3c9ed82145988}{MAXLOOP} - 2;
00291     c0    = k + VRNA\_GQUAD\_MIN\_BOX\_SIZE - 1;
00292     minl  = \hyperlink{utils_8h_a33297b3679c713b0c4d897cd0fe3b122}{MAX2}(c0, minl);
00293     c0    = j - 1;
00294     maxl  = k + VRNA\_GQUAD\_MAX\_BOX\_SIZE + 1;
00295     maxl  = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(c0, maxl);
00296     \textcolor{keywordflow}{for}(l = minl; l < maxl; l++)\{
00297       \textcolor{keywordflow}{if}(S[l] != 3) \textcolor{keywordflow}{continue};
00298       \textcolor{keywordflow}{if}(c == energy + ggg[k][l - k] + P->internal\_loop[l1 + j - l - 1])\{
00299         *p = k; *q = l;
00300         \textcolor{keywordflow}{return} 1;
00301       \}
00302     \}
00303   \}
00304 
00305   l = j - 1;
00306   \textcolor{keywordflow}{if}(S[l] == 3)
00307     \textcolor{keywordflow}{for}(k = i + 4;
00308         k < j - VRNA\_GQUAD\_MIN\_BOX\_SIZE;
00309         k++)\{
00310       l1    = k - i - 1;
00311       \textcolor{keywordflow}{if}(l1>\hyperlink{energy__const_8h_ad1bd6eabac419670ddd3c9ed82145988}{MAXLOOP}) \textcolor{keywordflow}{break};
00312       \textcolor{keywordflow}{if}(S[k] != 3) \textcolor{keywordflow}{continue};
00313       \textcolor{keywordflow}{if}(c == energy + ggg[k][l - k] + P->internal\_loop[l1])\{
00314         *p = k; *q = l;
00315         \textcolor{keywordflow}{return} 1;
00316       \}
00317     \}
00318 
00319   \textcolor{keywordflow}{return} 0;
00320 \}
00321 
00322 INLINE PRIVATE
00323 \textcolor{keywordtype}{int}
00324 E\_GQuad\_IntLoop(\textcolor{keywordtype}{int} i,
00325                 \textcolor{keywordtype}{int} j,
00326                 \textcolor{keywordtype}{int} type,
00327                 \textcolor{keywordtype}{short} *S,
00328                 \textcolor{keywordtype}{int} *ggg,
00329                 \textcolor{keywordtype}{int} *index,
00330                 \hyperlink{structparamT}{paramT} *P)\{
00331 
00332   \textcolor{keywordtype}{int} energy, ge, en1, en2, \hyperlink{fold__vars_8h_a72b511ed1201f7e23ec437e468790d74}{dangles}, p, q, l1, minq, maxq;
00333   \textcolor{keywordtype}{int} c0, c1, c2, c3, up, d53, d5, d3;
00334   \textcolor{keywordtype}{short} si, sj;
00335 
00336   dangles = P->\hyperlink{structparamT_aeb912822ef912705bc202b14f9d71ad9}{model_details}.\hyperlink{structmodel__detailsT_a89f9df217a4a7f4351a642655976376b}{dangles};
00337   si      = S[i + 1];
00338   sj      = S[j - 1];
00339   energy  = 0;
00340 
00341   \textcolor{keywordflow}{if}(dangles == 2)
00342     energy += P->mismatchI[type][si][sj];
00343 
00344   \textcolor{keywordflow}{if}(type > 2)
00345     energy += P->TerminalAU;
00346 
00347   ge = \hyperlink{energy__const_8h_a12c2040f25d8e3a7b9e1c2024c618cb6}{INF};
00348 
00349   p = i + 1;
00350   \textcolor{keywordflow}{if}(S[p] == 3)\{
00351     \textcolor{keywordflow}{if}(p < j - VRNA\_GQUAD\_MIN\_BOX\_SIZE)\{
00352       minq  = j - i + p - \hyperlink{energy__const_8h_ad1bd6eabac419670ddd3c9ed82145988}{MAXLOOP} - 2;
00353       c0    = p + VRNA\_GQUAD\_MIN\_BOX\_SIZE - 1;
00354       minq  = \hyperlink{utils_8h_a33297b3679c713b0c4d897cd0fe3b122}{MAX2}(c0, minq);
00355       c0    = j - 3;
00356       maxq  = p + VRNA\_GQUAD\_MAX\_BOX\_SIZE + 1;
00357       maxq  = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(c0, maxq);
00358       \textcolor{keywordflow}{for}(q = minq; q < maxq; q++)\{
00359         \textcolor{keywordflow}{if}(S[q] != 3) \textcolor{keywordflow}{continue};
00360         c0  = energy + ggg[index[q] + p] + P->internal\_loop[j - q - 1];
00361         ge  = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(ge, c0);
00362       \}
00363     \}
00364   \}
00365 
00366   \textcolor{keywordflow}{for}(p = i + 2;
00367       p < j - VRNA\_GQUAD\_MIN\_BOX\_SIZE;
00368       p++)\{
00369     l1    = p - i - 1;
00370     \textcolor{keywordflow}{if}(l1>MAXLOOP) \textcolor{keywordflow}{break};
00371     \textcolor{keywordflow}{if}(S[p] != 3) \textcolor{keywordflow}{continue};
00372     minq  = j - i + p - MAXLOOP - 2;
00373     c0    = p + VRNA\_GQUAD\_MIN\_BOX\_SIZE - 1;
00374     minq  = \hyperlink{utils_8h_a33297b3679c713b0c4d897cd0fe3b122}{MAX2}(c0, minq);
00375     c0    = j - 1;
00376     maxq  = p + VRNA\_GQUAD\_MAX\_BOX\_SIZE + 1;
00377     maxq  = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(c0, maxq);
00378     \textcolor{keywordflow}{for}(q = minq; q < maxq; q++)\{
00379       \textcolor{keywordflow}{if}(S[q] != 3) \textcolor{keywordflow}{continue};
00380       c0  = energy + ggg[index[q] + p] + P->internal\_loop[l1 + j - q - 1];
00381       ge   = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(ge, c0);
00382     \}
00383   \}
00384 
00385   q = j - 1;
00386   \textcolor{keywordflow}{if}(S[q] == 3)
00387     \textcolor{keywordflow}{for}(p = i + 4;
00388         p < j - VRNA\_GQUAD\_MIN\_BOX\_SIZE;
00389         p++)\{
00390       l1    = p - i - 1;
00391       \textcolor{keywordflow}{if}(l1>MAXLOOP) \textcolor{keywordflow}{break};
00392       \textcolor{keywordflow}{if}(S[p] != 3) \textcolor{keywordflow}{continue};
00393       c0  = energy + ggg[index[q] + p] + P->internal\_loop[l1];
00394       ge  = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(ge, c0);
00395     \}
00396 
00397 \textcolor{preprocessor}{#if 0}
00398 \textcolor{preprocessor}{}  \textcolor{comment}{/* here comes the additional stuff for the odd dangle models */}
00399   \textcolor{keywordflow}{if}(dangles % 1)\{
00400     en1 = energy + P->dangle5[type][si];
00401     en2 = energy + P->dangle5[type][sj];
00402     en3 = energy + P->mismatchI[type][si][sj];
00403 
00404     \textcolor{comment}{/* first case with 5' dangle (i.e. j-1) onto enclosing pair */}
00405     p = i + 1;
00406     \textcolor{keywordflow}{if}(S[p] == 3)\{
00407       \textcolor{keywordflow}{if}(p < j - VRNA\_GQUAD\_MIN\_BOX\_SIZE)\{
00408         minq  = j - i + p - MAXLOOP - 2;
00409         c0    = p + VRNA\_GQUAD\_MIN\_BOX\_SIZE - 1;
00410         minq  = \hyperlink{utils_8h_a33297b3679c713b0c4d897cd0fe3b122}{MAX2}(c0, minq);
00411         c0    = j - 4;
00412         maxq  = p + VRNA\_GQUAD\_MAX\_BOX\_SIZE + 1;
00413         maxq  = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(c0, maxq);
00414         \textcolor{keywordflow}{for}(q = minq; q < maxq; q++)\{
00415           \textcolor{keywordflow}{if}(S[q] != 3) \textcolor{keywordflow}{continue};
00416           c0  = en1 + ggg[index[q] + p] + P->internal\_loop[j - q - 1];
00417           ge  = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(ge, c0);
00418         \}
00419       \}
00420     \}
00421 
00422     \textcolor{keywordflow}{for}(p = i + 2; p < j - VRNA\_GQUAD\_MIN\_BOX\_SIZE; p++)\{
00423       l1    = p - i - 1;
00424       \textcolor{keywordflow}{if}(l1>MAXLOOP) \textcolor{keywordflow}{break};
00425       \textcolor{keywordflow}{if}(S[p] != 3) \textcolor{keywordflow}{continue};
00426       minq  = j - i + p - MAXLOOP - 2;
00427       c0    = p + VRNA\_GQUAD\_MIN\_BOX\_SIZE - 1;
00428       minq  = \hyperlink{utils_8h_a33297b3679c713b0c4d897cd0fe3b122}{MAX2}(c0, minq);
00429       c0    = j - 2;
00430       maxq  = p + VRNA\_GQUAD\_MAX\_BOX\_SIZE + 1;
00431       maxq  = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(c0, maxq);
00432       \textcolor{keywordflow}{for}(q = minq; q < maxq; q++)\{
00433         \textcolor{keywordflow}{if}(S[q] != 3) \textcolor{keywordflow}{continue};
00434         c0  = en1 + ggg[index[q] + p] + P->internal\_loop[l1 + j - q - 1];
00435         ge   = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(ge, c0);
00436       \}
00437     \}
00438 
00439     q = j - 2;
00440     \textcolor{keywordflow}{if}(S[q] == 3)
00441       \textcolor{keywordflow}{for}(p = i + 4; p < j - VRNA\_GQUAD\_MIN\_BOX\_SIZE; p++)\{
00442         l1    = p - i - 1;
00443         \textcolor{keywordflow}{if}(l1>MAXLOOP) \textcolor{keywordflow}{break};
00444         \textcolor{keywordflow}{if}(S[p] != 3) \textcolor{keywordflow}{continue};
00445         c0  = en1 + ggg[index[q] + p] + P->internal\_loop[l1 + 1];
00446         ge  = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(ge, c0);
00447       \}
00448 
00449     \textcolor{comment}{/* second case with 3' dangle (i.e. i+1) onto enclosing pair */}
00450 
00451   \}
00452 \textcolor{preprocessor}{#endif}
00453 \textcolor{preprocessor}{}  \textcolor{keywordflow}{return} ge;
00454 \}
00455 
00456 INLINE PRIVATE
00457 \textcolor{keywordtype}{int}
00458 E\_GQuad\_IntLoop\_L(\textcolor{keywordtype}{int} i,
00459                   \textcolor{keywordtype}{int} j,
00460                   \textcolor{keywordtype}{int} type,
00461                   \textcolor{keywordtype}{short} *S,
00462                   \textcolor{keywordtype}{int} **ggg,
00463                   \textcolor{keywordtype}{int} maxdist,
00464                   \hyperlink{structparamT}{paramT} *P)\{
00465 
00466   \textcolor{keywordtype}{int} energy, ge, en1, en2, dangles, p, q, l1, minq, maxq;
00467   \textcolor{keywordtype}{int} c0, c1, c2, c3, up, d53, d5, d3;
00468   \textcolor{keywordtype}{short} si, sj;
00469 
00470   dangles = P->\hyperlink{structparamT_aeb912822ef912705bc202b14f9d71ad9}{model_details}.\hyperlink{structmodel__detailsT_a89f9df217a4a7f4351a642655976376b}{dangles};
00471   si      = S[i + 1];
00472   sj      = S[j - 1];
00473   energy  = 0;
00474 
00475   \textcolor{keywordflow}{if}(dangles == 2)
00476     energy += P->mismatchI[type][si][sj];
00477 
00478   \textcolor{keywordflow}{if}(type > 2)
00479     energy += P->TerminalAU;
00480 
00481   ge = \hyperlink{energy__const_8h_a12c2040f25d8e3a7b9e1c2024c618cb6}{INF};
00482 
00483   p = i + 1;
00484   \textcolor{keywordflow}{if}(S[p] == 3)\{
00485     \textcolor{keywordflow}{if}(p < j - VRNA\_GQUAD\_MIN\_BOX\_SIZE)\{
00486       minq  = j - i + p - MAXLOOP - 2;
00487       c0    = p + VRNA\_GQUAD\_MIN\_BOX\_SIZE - 1;
00488       minq  = \hyperlink{utils_8h_a33297b3679c713b0c4d897cd0fe3b122}{MAX2}(c0, minq);
00489       c0    = j - 3;
00490       maxq  = p + VRNA\_GQUAD\_MAX\_BOX\_SIZE + 1;
00491       maxq  = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(c0, maxq);
00492       \textcolor{keywordflow}{for}(q = minq; q < maxq; q++)\{
00493         \textcolor{keywordflow}{if}(S[q] != 3) \textcolor{keywordflow}{continue};
00494         c0  = energy + ggg[p][q-p] + P->internal\_loop[j - q - 1];
00495         ge  = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(ge, c0);
00496       \}
00497     \}
00498   \}
00499 
00500   \textcolor{keywordflow}{for}(p = i + 2;
00501       p < j - VRNA\_GQUAD\_MIN\_BOX\_SIZE;
00502       p++)\{
00503     l1    = p - i - 1;
00504     \textcolor{keywordflow}{if}(l1>MAXLOOP) \textcolor{keywordflow}{break};
00505     \textcolor{keywordflow}{if}(S[p] != 3) \textcolor{keywordflow}{continue};
00506     minq  = j - i + p - MAXLOOP - 2;
00507     c0    = p + VRNA\_GQUAD\_MIN\_BOX\_SIZE - 1;
00508     minq  = \hyperlink{utils_8h_a33297b3679c713b0c4d897cd0fe3b122}{MAX2}(c0, minq);
00509     c0    = j - 1;
00510     maxq  = p + VRNA\_GQUAD\_MAX\_BOX\_SIZE + 1;
00511     maxq  = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(c0, maxq);
00512     \textcolor{keywordflow}{for}(q = minq; q < maxq; q++)\{
00513       \textcolor{keywordflow}{if}(S[q] != 3) \textcolor{keywordflow}{continue};
00514       c0  = energy + ggg[p][q - p] + P->internal\_loop[l1 + j - q - 1];
00515       ge   = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(ge, c0);
00516     \}
00517   \}
00518 
00519   q = j - 1;
00520   \textcolor{keywordflow}{if}(S[q] == 3)
00521     \textcolor{keywordflow}{for}(p = i + 4;
00522         p < j - VRNA\_GQUAD\_MIN\_BOX\_SIZE;
00523         p++)\{
00524       l1    = p - i - 1;
00525       \textcolor{keywordflow}{if}(l1>MAXLOOP) \textcolor{keywordflow}{break};
00526       \textcolor{keywordflow}{if}(S[p] != 3) \textcolor{keywordflow}{continue};
00527       c0  = energy + ggg[p][q - p] + P->internal\_loop[l1];
00528       ge  = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(ge, c0);
00529     \}
00530 
00531   \textcolor{keywordflow}{return} ge;
00532 \}
00533 
00534 INLINE PRIVATE
00535 FLT\_OR\_DBL
00536 exp\_E\_GQuad\_IntLoop(\textcolor{keywordtype}{int} i,
00537                     \textcolor{keywordtype}{int} j,
00538                     \textcolor{keywordtype}{int} type,
00539                     \textcolor{keywordtype}{short} *S,
00540                     FLT\_OR\_DBL *G,
00541                     \textcolor{keywordtype}{int} *index,
00542                     \hyperlink{structpf__paramT}{pf_paramT} *pf)\{
00543 
00544   \textcolor{keywordtype}{int} k, l, minl, maxl, u, r;
00545   FLT\_OR\_DBL q, qe, *expintern;
00546   \textcolor{keywordtype}{short} si, sj;
00547 
00548   q         = 0;
00549   si        = S[i + 1];
00550   sj        = S[j - 1];
00551   qe        = pf->expmismatchI[type][si][sj];
00552   expintern = pf->expinternal;
00553 
00554   \textcolor{keywordflow}{if}(type > 2)
00555     qe *= pf->expTermAU;
00556 
00557   k = i + 1;
00558   \textcolor{keywordflow}{if}(S[k] == 3)\{
00559     \textcolor{keywordflow}{if}(k < j - VRNA\_GQUAD\_MIN\_BOX\_SIZE)\{
00560       minl  = j - i + k - MAXLOOP - 2;
00561       u     = k + VRNA\_GQUAD\_MIN\_BOX\_SIZE - 1;
00562       minl  = \hyperlink{utils_8h_a33297b3679c713b0c4d897cd0fe3b122}{MAX2}(u, minl);
00563       u     = j - 3;
00564       maxl  = k + VRNA\_GQUAD\_MAX\_BOX\_SIZE + 1;
00565       maxl  = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(u, maxl);
00566       \textcolor{keywordflow}{for}(l = minl; l < maxl; l++)\{
00567         \textcolor{keywordflow}{if}(S[l] != 3) \textcolor{keywordflow}{continue};
00568         q += qe * G[index[k]-l] * expintern[j - l - 1];
00569       \}
00570     \}
00571   \}
00572 
00573 
00574   \textcolor{keywordflow}{for}(k = i + 2;
00575       k <= j - VRNA\_GQUAD\_MIN\_BOX\_SIZE;
00576       k++)\{
00577     u = k - i - 1;
00578     \textcolor{keywordflow}{if}(u > MAXLOOP) \textcolor{keywordflow}{break};
00579     \textcolor{keywordflow}{if}(S[k] != 3) \textcolor{keywordflow}{continue};
00580     minl  = j - i + k - MAXLOOP - 2;
00581     r     = k + VRNA\_GQUAD\_MIN\_BOX\_SIZE - 1;
00582     minl  = \hyperlink{utils_8h_a33297b3679c713b0c4d897cd0fe3b122}{MAX2}(r, minl);
00583     maxl  = k + VRNA\_GQUAD\_MAX\_BOX\_SIZE + 1;
00584     r     = j - 1;
00585     maxl  = \hyperlink{utils_8h_ae0b9cd0ce090bd69b951aa73e8fa4f7d}{MIN2}(r, maxl);
00586     \textcolor{keywordflow}{for}(l = minl; l < maxl; l++)\{
00587       \textcolor{keywordflow}{if}(S[l] != 3) \textcolor{keywordflow}{continue};
00588       q += qe * G[index[k]-l] * expintern[u + j - l - 1];
00589     \}
00590   \}
00591 
00592   l = j - 1;
00593   \textcolor{keywordflow}{if}(S[l] == 3)
00594     \textcolor{keywordflow}{for}(k = i + 4; k < j - VRNA\_GQUAD\_MIN\_BOX\_SIZE; k++)\{
00595       u    = k - i - 1;
00596       \textcolor{keywordflow}{if}(u>MAXLOOP) \textcolor{keywordflow}{break};
00597       \textcolor{keywordflow}{if}(S[k] != 3) \textcolor{keywordflow}{continue};
00598       q += qe * G[index[k]-l] * expintern[u];
00599     \}
00600 
00601   \textcolor{keywordflow}{return} q;
00602 \}
00603 
00604 \textcolor{preprocessor}{#endif}
\end{alltt}\end{footnotesize}
