1 #ifndef VIENNA_RNA_PACKAGE_MULTIBRANCH_LOOPS_H
2 #define VIENNA_RNA_PACKAGE_MULTIBRANCH_LOOPS_H
10 #include <ViennaRNA/energy_par.h>
12 #include <ViennaRNA/constraints.h>
17 # define INLINE inline
26 #define ON_SAME_STRAND(I,J,C) (((I)>=(C))||((J)<(C)))
56 INLINE PRIVATE
int E_MLstem(
int type,
67 INLINE PRIVATE
double exp_E_MLstem(
int type,
113 E_mb_loop_fast(
int i,
120 unsigned char type, tt;
124 char *ptype = vc->
ptype;
126 int *indx = vc->
jindx;
133 int ij = indx[j] + i;
134 int hc_decompose = hc[ij];
139 type = (
unsigned char)ptype[ij];
145 S_i1 = ON_SAME_STRAND(i, i + 1, cp) ? S[i+1] : -1;
146 S_j1 = ON_SAME_STRAND(j - 1, j, cp) ? S[j-1] : -1;
150 if((S_i1 >= 0) && (S_j1 >= 0)){
153 switch(dangle_model){
155 case 0:
if(decomp !=
INF){
156 decomp += E_MLstem(tt, -1, -1, P);
165 case 2: decomp += E_MLstem(tt, S_j1, S_i1, P);
173 default:
if(decomp !=
INF){
174 decomp += E_MLstem(tt, -1, -1, P);
181 if(dmli2[j-1] !=
INF){
182 en = dmli2[j-1] + E_MLstem(tt, -1, S_i1, P) + P->MLbase;
190 decomp =
MIN2(decomp, en);
193 if(hc_up[j-1] && hc_up[i+1]){
194 if(dmli2[j-2] !=
INF){
195 en = dmli2[j-2] + E_MLstem(tt, S_j1, S_i1, P) + 2*P->MLbase;
204 decomp =
MIN2(decomp, en);
208 if(dmli1[j-2] !=
INF){
209 en = dmli1[j-2] + E_MLstem(tt, S_j1, -1, P) + P->MLbase;
217 decomp =
MIN2(decomp, en);
223 e = decomp + P->MLclosing;
226 if(!ON_SAME_STRAND(i, j, cp)){
227 decomp = fc[i+1] + fc[j-1];
229 switch(dangle_model){
230 case 0: decomp +=
E_ExtLoop(tt, -1, -1, P);
232 case 2: decomp +=
E_ExtLoop(tt, S_j1, S_i1, P);
234 default: decomp +=
E_ExtLoop(tt, -1, -1, P);
235 if((hc_up[i+1]) && (hc_up[j-1])){
236 en = fc[i+2] + fc[j-2] +
E_ExtLoop(tt, S_j1, S_i1, P);
237 decomp =
MIN2(decomp, en);
240 en = fc[i+2] + fc[j-1] +
E_ExtLoop(tt, -1, S_i1, P);
241 decomp =
MIN2(decomp, en);
244 en = fc[i+1] + fc[j-2] +
E_ExtLoop(tt, S_j1, -1, P);
245 decomp =
MIN2(decomp, en);
260 int e, decomp, en, i1k, k1j1, ij, k;
261 unsigned char type, type_2;
263 int *indx = vc->
jindx;
270 char *ptype = vc->
ptype;
271 int *rtype = &(md->rtype[0]);
278 if(hc[ij] & VRNA_CONSTRAINT_CONTEXT_MB_LOOP){
280 k1j1 = indx[j-1] + i + 2 + turn + 1;
281 for (k = i+2+turn; k < j-2-turn; k++, k1j1++){
282 i1k = indx[k] + i + 1;
284 type_2 = rtype[(
unsigned char)ptype[i1k]];
285 en = c[i1k]+P->stack[type][type_2]+fML[k1j1];
286 decomp =
MIN2(decomp, en);
288 if(hc[k1j1] & VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC){
289 type_2 = rtype[(
unsigned char)ptype[k1j1]];
290 en = c[k1j1]+P->stack[type][type_2]+fML[i1k];
291 decomp =
MIN2(decomp, en);
295 decomp += 2*P->MLintern[1] + P->MLclosing;
307 E_ml_rightmost_stem(
int i,
315 int *indx = vc->
jindx;
322 int ij = indx[j] + i;
323 int type = vc->
ptype[ij];
324 int hc_decompose = hc[ij];
330 if(ON_SAME_STRAND(i - 1, i, cp)){
331 if(ON_SAME_STRAND(j, j + 1, cp)){
335 switch(dangle_model){
336 case 2: e += E_MLstem(type, (i==1) ? S[length] : S[i-1], S[j+1], P);
338 default: e += E_MLstem(type, -1, -1, P);
345 if(ON_SAME_STRAND(i, j, cp)){
346 en = ggg[ij] + E_MLstem(0, -1, -1, P);
352 if(ON_SAME_STRAND(j - 1, j, cp))
354 if(fm[indx[j - 1] + i] !=
INF){
355 en = fm[indx[j - 1] + i] + P->MLbase;
368 E_ml_stems_fast(
int i,
374 int k, en, decomp, mm5, mm3, type_2, k1j, stop;
376 int length = (int)vc->
length;
377 char *ptype = vc->
ptype;
379 int *indx = vc->
jindx;
386 int ij = indx[j] + i;
389 int type = ptype[ij];
398 e = E_ml_rightmost_stem(i,j,vc);
404 if(ON_SAME_STRAND(i - 1, i, cp)){
405 switch(dangle_model){
410 case 2:
if(ON_SAME_STRAND(i, i + 1, cp))
412 if(fm[ij + 1] !=
INF){
413 en = fm[ij + 1] + P->MLbase;
423 default: mm5 = ((i>1) || circular) ? S[i] : -1;
424 mm3 = ((j<length) || circular) ? S[j] : -1;
425 if(ON_SAME_STRAND(i, i + 1, cp))
428 en = fm[ij+1] + P->MLbase;
434 if(hc[ij+1] & VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC){
437 en = c[ij+1] + E_MLstem(type, mm5, -1, P) + P->MLbase;
446 if(ON_SAME_STRAND(j - 1, j, cp))
448 if(hc[indx[j-1]+i] & VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC){
449 if(c[indx[j-1]+i] !=
INF){
450 type = ptype[indx[j-1]+i];
451 en = c[indx[j-1]+i] + E_MLstem(type, -1, mm3, P) + P->MLbase;
460 if(ON_SAME_STRAND(j - 1, j, cp) && ON_SAME_STRAND(i, i + 1, cp))
461 if(hc[indx[j-1]+i+1] & VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC){
462 if(hc_up[i] && hc_up[j]){
463 if(c[indx[j-1]+i+1] !=
INF){
464 type = ptype[indx[j-1]+i+1];
465 en = c[indx[j-1]+i+1] + E_MLstem(type, mm5, mm3, P) + 2*P->MLbase;
478 k1j = indx[j] + i + turn + 2;
479 stop = (cp > 0) ? (cp - 1) : (j - 2 - turn);
480 for (decomp =
INF, k = i + 1 + turn; k <= stop; k++, k1j++){
481 if((fmi[k] !=
INF ) && (fm[k1j] !=
INF)){
482 en = fmi[k] + fm[k1j];
483 decomp =
MIN2(decomp, en);
487 for (;k <= j - 2 - turn; k++, k1j++){
488 if((fmi[k] !=
INF) && (fm[k1j] !=
INF)){
489 en = fmi[k] + fm[k1j];
490 decomp =
MIN2(decomp, en);
498 if (dangle_model==3) {
501 k1j = indx[j]+i+turn+2;
502 for (decomp =
INF, k = i + 1 + turn; k <= stop; k++, k1j++){
504 if((hc[ik] & VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC) && (hc[k1j] & VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC)){
505 type = rtype[(
unsigned char)ptype[ik]];
506 type_2 = rtype[(
unsigned char)ptype[k1j]];
507 en = c[ik] + c[k1j] + P->stack[type][type_2];
508 decomp =
MIN2(decomp, en);
512 for (; k <= j-2-turn; k++, k1j++){
514 if((hc[ik] & VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC) && (hc[k1j] & VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC)){
515 type = rtype[(
unsigned char)ptype[ik]];
516 type_2 = rtype[(
unsigned char)ptype[k1j]];
517 en = c[ik] + c[k1j] + P->stack[type][type_2];
518 decomp =
MIN2(decomp, en);
522 decomp += 2*P->MLintern[1];
526 DMLi[j] =
MIN2(DMLi[j], decomp);
527 DMLi[j] =
MIN2(DMLi[j], DMLi[j-1]+P->MLbase);
528 DMLi[j] =
MIN2(DMLi[j], DMLi1[j]+P->MLbase);
529 new_fML =
MIN2(new_fML, DMLi[j]);
541 INLINE PRIVATE
int E_MLstem(
int type,
int si1,
int sj1,
vrna_param_t *P){
543 if(si1 >= 0 && sj1 >= 0){
544 energy += P->mismatchM[type][si1][sj1];
547 energy += P->dangle5[type][si1];
550 energy += P->dangle3[type][sj1];
554 energy += P->TerminalAU;
556 energy += P->MLintern[type];
563 INLINE PRIVATE
double
564 exp_E_MLstem(
int type,
570 if(si1 >= 0 && sj1 >= 0){
571 energy = P->expmismatchM[type][si1][sj1];
574 energy = P->expdangle5[type][si1];
577 energy = P->expdangle3[type][sj1];
581 energy *= P->expTermAU;
583 energy *= P->expMLintern[type];
601 int length, ii, jj, k, en, cp, fij, fi, *my_c, *my_fc, *my_ggg, *idx, with_gquad, dangle_model, turn;
623 with_gquad = md->
gquad;
634 fi = (hc->
up_ext[ii]) ? my_fc[ii + 1] :
INF;
647 if (jj < ii + turn + 2){
652 mm5 = (ii > 1 && ON_SAME_STRAND(ii - 1, ii, cp)) ? S1[ii - 1] : -1;
655 switch(dangle_model){
656 case 0:
for(k = ii + turn + 1; k <= jj; k++){
658 type = (
unsigned char)ptype[idx[k] + ii];
659 if(fij == my_fc[k + 1] + my_c[idx[k] + ii] +
E_ExtLoop(type, -1, -1, P)){
660 bp_stack[++(*stack_count)].i = ii;
661 bp_stack[(*stack_count)].j = k;
670 if(fij == my_fc[k + 1] + my_ggg[idx[k] + ii]){
673 vrna_BT_gquad_mfe(vc, ii, k, bp_stack, stack_count);
680 case 2:
for(k = ii + turn + 1; k <= jj; k++){
681 if(hc->
matrix[idx[k] + ii] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP){
682 mm3 = ON_SAME_STRAND(k, k + 1, cp) ? S1[k + 1] : -1;
683 type = (
unsigned char)ptype[idx[k] + ii];
684 if(fij == my_fc[k + 1] + my_c[idx[k] + ii] +
E_ExtLoop(type, mm5, mm3, P)){
685 bp_stack[++(*stack_count)].i = ii;
686 bp_stack[(*stack_count)].j = k;
695 if(fij == my_fc[k + 1] + my_ggg[idx[k] + ii]){
698 vrna_BT_gquad_mfe(vc, ii, k, bp_stack, stack_count);
705 default:
for(k = ii + turn + 1; k <= jj; k++){
706 if(hc->
matrix[idx[k] + ii] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP){
707 type = (
unsigned char)ptype[idx[k] + ii];
708 if(fij == my_fc[k + 1] + my_c[idx[k] + ii] +
E_ExtLoop(type, -1, -1, P)){
709 bp_stack[++(*stack_count)].i = ii;
710 bp_stack[(*stack_count)].j = k;
717 mm3 = ON_SAME_STRAND(k, k + 1, cp) ? S1[k + 1] : -1;
718 en = my_c[idx[k] + ii];
723 if(fij == my_fc[k + 2] + en +
E_ExtLoop(type, -1, mm3, P)){
724 bp_stack[++(*stack_count)].i = ii;
725 bp_stack[(*stack_count)].j = k;
735 if(fij == my_fc[k + 1] + my_ggg[idx[k] + ii]){
738 vrna_BT_gquad_mfe(vc, ii, k, bp_stack, stack_count);
743 if(hc->
matrix[idx[k] + ii + 1] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP){
745 mm5 = ON_SAME_STRAND(ii, ii + 1,cp) ? S1[ii] : -1;
746 mm3 = ON_SAME_STRAND(k, k + 1,cp) ? S1[k + 1] : -1;
747 type = ptype[idx[k] + ii + 1];
748 en = my_c[idx[k] + ii + 1];
753 if(fij == en + my_fc[k + 1] +
E_ExtLoop(type, mm5, -1, P)){
754 bp_stack[++(*stack_count)].i = ii + 1;
755 bp_stack[(*stack_count)].j = k;
768 if(fij == en + my_fc[k + 2] +
E_ExtLoop(type, mm5, mm3, P)){
769 bp_stack[++(*stack_count)].i = ii + 1;
770 bp_stack[(*stack_count)].j = k;
788 fi = (hc->
up_ext[jj]) ? my_fc[jj - 1] :
INF;
801 if (jj < ii + turn + 2){
807 mm3 = ((jj < length) && ON_SAME_STRAND(jj, jj + 1, cp)) ? S1[jj + 1] : -1;
808 switch(dangle_model){
809 case 0:
for (k = jj - turn - 1; k >= ii; k--){
811 if(fij == my_fc[k - 1] + my_ggg[idx[jj] + k]){
814 vrna_BT_gquad_mfe(vc, k, jj, bp_stack, stack_count);
819 if(hc->
matrix[idx[jj] + k] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP){
820 type = (
unsigned char)ptype[idx[jj] + k];
821 en = my_c[idx[jj] + k];
822 if(!ON_SAME_STRAND(k, jj, cp))
825 if(fij == my_fc[k - 1] + en +
E_ExtLoop(type, -1, -1, P)){
826 bp_stack[++(*stack_count)].i = k;
827 bp_stack[(*stack_count)].j = jj;
836 case 2:
for(k = jj - turn - 1; k >= ii; k--){
838 if(fij == my_fc[k - 1] + my_ggg[idx[jj] + k]){
841 vrna_BT_gquad_mfe(vc, k, jj, bp_stack, stack_count);
846 if(hc->
matrix[idx[jj] + k] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP){
847 mm5 = ((k > 1) && ON_SAME_STRAND(k - 1, k, cp)) ? S1[k - 1] : -1;
848 type = (
unsigned char)ptype[idx[jj] + k];
849 en = my_c[idx[jj] + k];
850 if(!ON_SAME_STRAND(k, jj, cp))
853 if(fij == my_fc[k - 1] + en +
E_ExtLoop(type, mm5, mm3, P)){
854 bp_stack[++(*stack_count)].i = k;
855 bp_stack[(*stack_count)].j = jj;
865 default:
for(k = jj - turn - 1; k >= ii; k--){
868 if(fij == my_fc[k - 1] + my_ggg[idx[jj] + k]){
871 vrna_BT_gquad_mfe(vc, k, jj, bp_stack, stack_count);
876 if(hc->
matrix[idx[jj] + k] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP){
877 type = (
unsigned char)ptype[idx[jj] + k];
878 en = my_c[idx[jj] + k];
879 if(!ON_SAME_STRAND(k, jj, cp))
882 if(fij == my_fc[k - 1] + en +
E_ExtLoop(type, -1, -1, P)){
883 bp_stack[++(*stack_count)].i = k;
884 bp_stack[(*stack_count)].j = jj;
891 if((k > 1) && ON_SAME_STRAND(k - 1, k, cp)){
897 if(fij == my_fc[k - 2] + en +
E_ExtLoop(type, mm5, -1, P)){
898 bp_stack[++(*stack_count)].i = k;
899 bp_stack[(*stack_count)].j = jj;
909 if(hc->
matrix[idx[jj - 1] + k] & VRNA_CONSTRAINT_CONTEXT_EXT_LOOP){
910 type = (
unsigned char)ptype[idx[jj - 1] + k];
912 if(ON_SAME_STRAND(jj - 1, jj, cp)){
914 en = my_c[idx[jj - 1] + k];
915 if (!ON_SAME_STRAND(k, jj - 1, cp))
921 if (fij == en + my_fc[k - 1] +
E_ExtLoop(type, -1, mm3, P)){
922 bp_stack[++(*stack_count)].i = k;
923 bp_stack[(*stack_count)].j = jj - 1;
932 mm5 = ON_SAME_STRAND(k - 1, k, cp) ? S1[k - 1] : -1;
937 if (fij == my_fc[k - 2] + en +
E_ExtLoop(type, mm5, mm3, P)){
938 bp_stack[++(*stack_count)].i = k;
939 bp_stack[(*stack_count)].j = jj - 1;
969 int length, cp, ij, ii, jj, fij, fi, u, en, *my_c, *my_fML, *my_ggg, turn, *idx, with_gquad, dangle_model, *rtype;
970 unsigned char type, type_2;
986 rtype = &(md->rtype[0]);
993 with_gquad = md->
gquad;
1001 fij = my_fML[idx[jj] + ii];
1002 fi = (hc->
up_ml[jj]) ? my_fML[idx[jj - 1] + ii] + P->MLbase :
INF;
1012 }
while (fij == fi);
1017 fij = my_fML[idx[jj] + ii];
1018 fi = (hc->
up_ml[ii]) ? my_fML[idx[jj] + ii + 1] + P->MLbase :
INF;
1028 }
while (fij == fi);
1031 if (jj < ii + turn + 2){
1037 *component1 = *component2 = 1;
1042 if(fij == my_ggg[ij] + E_MLstem(0, -1, -1, P)){
1045 vrna_BT_gquad_mfe(vc, ii, jj, bp_stack, stack_count);
1050 type = (
unsigned char)ptype[ij];
1053 switch(dangle_model){
1054 case 0:
if(hc->
matrix[ij] & VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC){
1055 if(fij == en + E_MLstem(type, -1, -1, P)){
1065 case 2:
if(hc->
matrix[ij] & VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC){
1066 if(fij == en + E_MLstem(type, S1[ii - 1], S1[jj + 1], P)){
1076 default:
if(hc->
matrix[ij] & VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC){
1077 if(fij == en + E_MLstem(type, -1, -1, P)){
1085 if(hc->
matrix[ij + 1] & VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC){
1092 type = (
unsigned char)ptype[ij + 1];
1093 if(tmp_en == my_c[ij+1] + E_MLstem(type, S1[ii], -1, P) + P->MLbase){
1102 if(hc->
matrix[idx[jj - 1] + ii] & VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC){
1109 type = (
unsigned char)ptype[idx[jj - 1] + ii];
1110 if(tmp_en == my_c[idx[jj - 1] + ii] + E_MLstem(type, -1, S1[jj], P) + P->MLbase){
1119 if(hc->
matrix[idx[jj - 1] + ii + 1] & VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC){
1126 type = (
unsigned char)ptype[idx[jj - 1] + ii + 1];
1127 if(tmp_en == my_c[idx[jj - 1] + ii + 1] + E_MLstem(type, S1[ii], S1[jj], P) + 2 * P->MLbase){
1140 for(u = ii + 1 + turn; u <= jj - 2 - turn; u++){
1141 if(fij == my_fML[idx[u] + ii] + my_fML[idx[jj] + u + 1]){
1151 if(dangle_model==3){
1152 int ik, k1j, tmp_en;
1153 for (k1j = idx[jj] + ii + turn + 2, u = ii + 1 + turn; u <= jj - 2 - turn; u++, k1j++) {
1156 type = rtype[(
unsigned char)ptype[ik]];
1157 type_2 = rtype[(
unsigned char)ptype[k1j]];
1158 tmp_en = my_c[ik] + my_c[k1j] + P->stack[type][type_2] + 2*P->MLintern[1];
1164 *component1 = *component2 = 2;
1184 int ij, p, q, r, e, cp, *idx, turn, dangle_model, *my_c, *my_fML, *my_fc, *rtype;
1185 unsigned char type, type_2, tt;
1206 rtype = &(md->rtype[0]);
1207 type = (
unsigned char)ptype[ij];
1217 if(hc->
matrix[ij] & VRNA_CONSTRAINT_CONTEXT_MB_LOOP){
1220 if(!ON_SAME_STRAND(*i, *j, cp)){
1223 e = my_fc[p] + my_fc[q];
1228 s5 = ON_SAME_STRAND(q, *j, cp) ? S1[q] : -1;
1229 s3 = ON_SAME_STRAND(*i, p, cp) ? S1[p] : -1;
1231 switch(dangle_model){
1232 case 0:
if(en == e +
E_ExtLoop(type, -1, -1, P)){
1236 case 2:
if(en == e +
E_ExtLoop(type, s5, s3, P)){
1241 if(en == e +
E_ExtLoop(type, -1, -1, P)){
1246 e = my_fc[p + 1] + my_fc[q];
1253 if(en == e +
E_ExtLoop(type, -1, s3, P)){
1259 e = my_fc[p] + my_fc[q - 1];
1266 if(en == e +
E_ExtLoop(type, s5, -1, P)){
1272 e = my_fc[p + 1] + my_fc[q - 1];
1279 if(en == e +
E_ExtLoop(type, s5, s3, P)){
1280 ii = p + 1; jj = q - 1;
1299 *component1 = *component2 = 1;
1301 s5 = ON_SAME_STRAND(q, *j, cp) ? S1[q] : -1;
1302 s3 = ON_SAME_STRAND(*i, p, cp) ? S1[p] : -1;
1304 switch(dangle_model){
1305 case 0: e = en - E_MLstem(type, -1, -1, P) - P->MLclosing;
1310 for(r = *i + 2 + turn; r < *j - 2 - turn; ++r){
1311 if(e == my_fML[idx[r] + p] + my_fML[idx[q] + r + 1])
1316 case 2: e = en - E_MLstem(type, s5, s3, P) - P->MLclosing;
1321 for(r = p + turn + 1; r < q - turn - 1; ++r){
1322 if(e == my_fML[idx[r] + p] + my_fML[idx[q] + r + 1])
1327 default: e = en - P->MLclosing;
1332 for(r = p + turn + 1; r < q - turn - 1; ++r){
1333 if(e == my_fML[idx[r] + p] + my_fML[idx[q] + r + 1] + E_MLstem(type, -1, -1, P)){
1342 if(tmp_en == my_fML[idx[r] + p + 1] + my_fML[idx[q] + r + 1] + E_MLstem(type, -1, s3, P) + P->MLbase){
1353 if(tmp_en == my_fML[idx[r] + p] + my_fML[idx[q - 1] + r + 1] + E_MLstem(type, s5, -1, P) + P->MLbase){
1364 if(tmp_en == my_fML[idx[r] + p + 1] + my_fML[idx[q - 1] + r + 1] + E_MLstem(type, s5, s3, P) + 2 * P->MLbase){
1372 if(dangle_model == 3){
1374 if(hc->
matrix[idx[r] + p] & VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC){
1375 type_2 = rtype[(
unsigned char)ptype[idx[r] + p]];
1376 tmp_en = my_c[idx[r] + p] + P->stack[tt][type_2] + my_fML[idx[q] + r + 1];
1377 if(e == tmp_en + 2 * P->MLintern[1]){
1383 if(hc->
matrix[idx[q] + r + 1] & VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC){
1384 type_2 = rtype[(
unsigned char)ptype[idx[q] + r + 1]];
1385 tmp_en = my_c[idx[q] + r + 1] + P->stack[tt][type_2] + my_fML[idx[r] + p];
1386 if (e == tmp_en + 2 * P->MLintern[1]){
1397 if(r <= *j - turn - 3){
1405 if (dangle_model==3) {
1406 d5 = P->dangle5[tt][S1[j-1]];
1407 d3 = P->dangle3[tt][S1[i+1]];
1409 if (cij == fML[indx[j-2]+i+2] + mm + d3 + d5 + P->MLbase + P->MLbase) {
1412 }
else if (cij == fML[indx[j-2]+i+1] + mm + d5 + P->MLbase)
1414 else if (cij == fML[indx[j-1]+i+2] + mm + d3 + P->MLbase)
1417 if (cij != fML[indx[j-1]+i+1] + mm + P->MLbase)
1418 fprintf(stderr,
"backtracking failed in repeat");
1420 bt_stack[++s].i = i1;
int * ggg
Energies of g-quadruplexes.
Definition: data_structures.h:432
int uniq_ML
Flag to ensure unique multibranch loop decomposition during folding.
Definition: model.h:186
int * c
Energy array, given that i-j pair.
Definition: data_structures.h:425
struct vrna_hc_t * hc
The hard constraints data structure used for structure prediction.
Definition: data_structures.h:716
int * fM1
Second ML array, only for unique multibrnach loop decomposition.
Definition: data_structures.h:430
int cutpoint
The position of the (cofold) cutpoint within the provided sequence. If there is no cutpoint...
Definition: data_structures.h:712
The hard constraints data structure.
Definition: constraints.h:390
char * matrix
Upper triangular matrix encoding where a base pair or unpaired nucleotide is allowed.
Definition: constraints.h:391
struct vrna_param_t * params
The precomputed free energy contributions for each type of loop.
Definition: data_structures.h:721
int * jindx
DP matrix accessor.
Definition: data_structures.h:725
int * fML
Multi-loop auxiliary energy array.
Definition: data_structures.h:429
int * up_ml
A linear array that holds the number of allowed unpaired nucleotides in a multi branched loop...
Definition: constraints.h:403
int gquad
Include G-quadruplexes in structure prediction.
Definition: model.h:184
int * up_ext
A linear array that holds the number of allowed unpaired nucleotides in an exterior loop...
Definition: constraints.h:394
int ** free_energies
Energy contribution for unpaired sequence stretches.
Definition: constraints.h:414
#define MIN2(A, B)
Get the minimum of two comparable values.
Definition: utils.h:118
vrna_md_t model_details
Model details to be used in the recursions.
Definition: params.h:79
The most basic data structure required by many functions throughout the RNAlib.
Definition: data_structures.h:698
#define VRNA_CONSTRAINT_CONTEXT_MB_LOOP
Hard constraints flag, base pair is enclosed in an interior loop.
Definition: constraints.h:233
PRIVATE int E_ExtLoop(int type, int si1, int sj1, vrna_param_t *P)
Definition: exterior_loops.h:460
int * fc
Energy from i to cutpoint (and vice versa if i>cut)
Definition: data_structures.h:428
#define VRNA_CONSTRAINT_CONTEXT_EXT_LOOP
Hard constraints flag, base pair in the exterior loop.
Definition: constraints.h:201
#define INF
Definition: energy_const.h:16
Energy evaluation of exterior loops for MFE and partition function calculations.
#define VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC
Hard constraints flag, base pair is enclosed in a multi branch loop.
Definition: constraints.h:241
vrna_mx_mfe_t * matrices
The MFE DP matrices.
Definition: data_structures.h:718
int min_loop_size
Minimum size of hairpin loops.
Definition: model.h:194
PRIVATE int vrna_BT_mb_loop(vrna_fold_compound *vc, int *i, int *j, int *k, int en, int *component1, int *component2)
Backtrack the decomposition of a multi branch loop closed by .
Definition: multibranch_loops.h:1176
int dangles
Specifies the dangle model used in any energy evaluation (0,1,2 or 3)
Definition: model.h:172
unsigned int length
The length of the sequence (or sequence alignment)
Definition: data_structures.h:711
Various functions related to G-quadruplex computations.
char * ptype
Pair type array.
Definition: data_structures.h:749
Base pair.
Definition: data_structures.h:73
The datastructure that contains temperature scaled energy parameters.
Definition: params.h:41
The soft constraints data structure.
Definition: constraints.h:413
int circ
Assume RNA to be circular instead of linear.
Definition: model.h:183
The data structure that contains the complete model details used throughout the calculations.
Definition: model.h:169
PRIVATE int E_mb_loop_stack(int i, int j, vrna_fold_compound *vc)
Evaluate energy of a multi branch helices stacking onto closing pair (i,j)
Definition: multibranch_loops.h:256
Here all all declarations of the global variables used throughout RNAlib.
short * sequence_encoding
Numerical encoding of the input sequence.
Definition: data_structures.h:744
struct vrna_sc_t * sc
The soft constraints for usage in structure prediction and evaluation.
Definition: data_structures.h:763
int * en_basepair
Energy contribution for base pairs.
Definition: constraints.h:415
The datastructure that contains temperature scaled Boltzmann weights of the energy parameters...
Definition: params.h:86