/* -*-C-*- */ /* this file contains code for folding circular RNAs */ /* it's #include'd into fold.c */ float circfold(const char *string, char *structure) { /* variant of fold() for circular RNAs */ /* auxiliarry arrays: fM2 = multiloop region with exactly two stems, extending to 3' end for stupid dangles=1 case we also need: fM_d3 = multiloop region with >= 2 stems, starting at pos 2 (a pair (k,n) will form 3' dangle with pos 1) fM_d5 = multiloop region with >= 2 stems, extending to pos n-1 (a pair (1,k) will form a 5' dangle with pos n) */ int *fM2, Fc, FcH, FcI, FcM, Hi, Hj, Ii, Ij, Ip, Iq, Mi; int *fM_d3, *fM_d5, Md3i, Md5i, FcMd3, FcMd5; int i,j, p,q,length, energy, bonus=0, bonus_cnt=0; int s=0; /* if (!uniq_ML) {uniq_ML=1; init_length=-1;} */ length = (int) strlen(string); if (length>init_length) initialize_fold(length); if (fabs(P->temperature - temperature)>1e-6) update_fold_params(); encode_seq(string); BP = (int *)space(sizeof(int)*(length+2)); make_ptypes(S, structure); /* compute all arrays used by fold() for linear RNA */ energy = fill_arrays(string); /* extra arrays for circfold() */ fM2 = (int *) space(sizeof(int)*(length+2)); FcH = FcI= FcM = FcMd3= FcMd5= Fc = INF; for (i=1; i max_separation) type = 0; */ /* forces locality degree */ type=rtype[type]; if (!type) continue; if (no_close) new_c = FORBIDDEN; else { char loopseq[10]; int si1, sj1; if (u<7) { strcpy(loopseq , string+j-1); strncat(loopseq, string, i); } si1 = (i==1)?S1[length] : S1[i-1]; sj1 = (j==length)?S1[1] : S1[j+1]; new_c = HairpinE(u, type, sj1, si1, loopseq)+bonus+c[ij]; } if (new_cMAXLOOP) break; qmin = u1+i-1+length-MAXLOOP; if (qminMAXLOOP) continue; si1 = (i==1)? S1[length] : S1[i-1]; sq1 = (q==length)? S1[1] : S1[q+1]; energy = LoopEnergy(u1, u2, type, type_2, S1[j+1], si1, S1[p-1], sq1); new_c = c[ij] + c[indx[q]+p] + energy; if (new_cMLclosing; if (fmMLclosing+P->MLintern[type]+P->dangle3[type][S1[1]]; if (fmMLclosing+P->MLintern[type]+P->dangle3[type][S1[1]]+P->dangle5[type][S1[i]]; if (fmdangle5[type][S1[length]]+c[indx[i]+1]+fM_d5[i+1]+P->MLclosing+P->MLintern[type]; if (fmdangle5[type][S1[length]]+c[indx[i]+1]+P->dangle3[type][S1[i+1]]+ fM_d5[i+2]+P->MLclosing+P->MLintern[type]; if (fm0)?Md5i:-Md5i; sector[s].ml = 2; i = (Md5i>0)?Md5i+1 : -Md5i+2; /* let's backtrack fm_d5[Md5i+1] */ for (u=i+TURN; u0)?Md3i+1:-Md3i+1; sector[s].j = length; sector[s].ml = 2; i = (Md3i>0)? Md3i : -Md3i-1; /* let's backtrack fm_d3[Md3i] */ for (u=2+TURN; u-4)) { bonus_cnt++; if((BP[i]==-3)&&(structure[i-1]==')')) bonus++; if((BP[i]==-2)&&(structure[i-1]=='(')) bonus++; if((BP[i]==-1)&&(structure[i-1]!='.')) bonus++; } if(BP[i]>i) { int l; bonus_cnt++; for(l=1; l<=base_pair[0].i; l++) if((i==base_pair[l].i)&&(BP[i]==base_pair[l].j)) bonus++; } } if (bonus_cnt>bonus) fprintf(stderr,"\ncould not enforce all constraints\n"); bonus*=BONUS; free(fM2); free(S); free(S1); free(BP); energy = Fc + bonus; /*remove bonus energies from result */ return (float) energy/100.; }