void head_to_tail(long j, long *npair_per_helix, long **bs_1, long **bs_2, long *nregions,long **sub_helix1,long **sub_helix2) /* Account only the real anti-parrellel helix from the longer helix.*/ { long i, n, m, k, nh, **helix, nregion; n = npair_per_helix[j]; helix = lmatrix(1, n , 1, 2); nh=1; nregion = 1; for(i=1; i<=n; i++){ /* get the anti-parrellel helix region */ helix[nregion][1] = i; for(i++;(i<=n)&& ((bs_1[j][i] == bs_1[j][i-1]+1) &&(bs_2[j][i] == bs_2[j][i-1]-1)) ||((bs_2[j][i] == bs_2[j][i-1]+1) &&(bs_1[j][i] == bs_1[j][i-1]-1)) ; i++){ helix[nregion][2] = i; } i--; if(helix[nregion][2] - helix[nregion][1] >= 1){ /* minimum two pairs */ nregion++; } } /* NOTE: each nregions[j] is the real anti-parrallel helix in the longer helix determined by geometry. */ nregions[j] = nregion -1; for(m=1; m<=nregions[j]; m++){ sub_helix1[j][m] = nh; for(k = helix[m][1]; k<=helix[m][2]; k++){ bs_1[j][nh]=bs_1[j][k]; bs_2[j][nh]=bs_2[j][k]; nh++; } sub_helix2[j][m] = nh-1; } npair_per_helix[j]=nh-1; free_lmatrix(helix, 1, n, 1, 2); }
void free_longmatrix( LONGMATRIX *m) { if(m==NULL || m->co==NULL){ t_error("This matrix was never allocated"); }else if(m->isdynamic==1){ free_lmatrix(m->co,NL,NL); m->isdynamic=m->nrl=m->ncl=m->nrh=m->nch=-1; free(m); return; }else{ printf("\nWarning::An attemp was made to free a non dynamic matrix\n"); } }