void sortbeste(struct beststr **bptr, int nbest) { int gap, i, j, k; struct beststr *tmp; double v; int incs[14] = { 198768, 86961, 33936, 13776, 4592, 1968, 861, 336, 112, 48, 21, 7, 3, 1 }; for ( k = 0; k < 14; k++) { gap = incs[k]; for (i=gap; i < nbest; i++) { j = i; tmp = bptr[i]; v = tmp->rst.escore; while ( j >= gap && bptr[j-gap]->rst.escore > v) { bptr[j] = bptr[j - gap]; j -= gap; } bptr[j] = tmp; } } /* sometimes there are many high scores with E()==0.0, sort those by z() score */ j = 0; while (j < nbest && bptr[j]->rst.escore <= 2.0*DBL_MIN ) {j++;} if (j > 1) sortbestz(bptr,j); }
int last_calc( unsigned char **aa0, unsigned char *aa1save, int maxn, struct beststr **bptr, int nbest, const struct mngmsg *m_msg, struct pstruct *ppst , void **f_str , void *rstat_str) { unsigned char *aa1; int nopt, ib; struct beststr *bbp; long loffset, l_off; int n0, n1; struct rstruct rst; struct lmf_str *m_fptr; char bline[60]; int tat_samp, tat_inc, loop_cnt, i; double min_escore, ess; n0 = m_msg->n0; sortbestz(bptr,nbest); tat_inc = 500; /* if (zs_to_E(bptr[0]->zscore,bptr[0]->n1,0,ppst->zdb_size,m_msg->db)/ zs_to_E(bptr[nbest-1]->zscore,bptr[nbest-1]->n1,0,ppst->zdb_size,m_msg->db) < 1e-20) { tat_inc /= 4 ;} */ /* || (zs_to_E(bptr[0]->zscore,bptr[0]->n1,0,ppst->zdb_size,m_msg->db)< 1e-5); */ ib = tat_samp = 0; for (loop_cnt = 0; loop_cnt < 5; loop_cnt++) { tat_samp += tat_inc; nopt = min(nbest,tat_samp); min_escore = 1000000.0; for ( ; ib<nopt; ib++) { bbp = bptr[ib]; if (bbp->rst.score[0] < 0) break; if (bbp->seq->aa1b == NULL) { if ((m_fptr=re_openlib(bbp->mseq->m_file_p,!m_msg->quiet))==NULL) { fprintf(stderr,"*** cannot re-open %s\n",bbp->mseq->m_file_p->lb_name); exit(1); } RANLIB(bline,sizeof(bline),bbp->mseq->lseek,bbp->mseq->libstr,m_fptr); n1 = re_getlib(aa1save,NULL,maxn,m_msg->ldb_info.maxt3, m_msg->ldb_info.l_overlap,bbp->mseq->cont, m_msg->ldb_info.term_code, &loffset,&l_off,bbp->mseq->m_file_p); aa1 = aa1save; } else { n1 = bbp->seq->n1; aa1 = bbp->seq->aa1b; loffset = bbp->seq->l_offset; l_off = bbp->seq->l_off; } do_opt(aa0[bbp->frame],m_msg->n0,aa1,n1,bbp->frame,ppst, f_str[bbp->frame],&rst); memcpy(&(bbp->rst),&rst,sizeof(struct rstruct)); if ((ess=scale_one_score(ib, bbp->rst.escore, m_msg->db, rstat_str)) < min_escore) { min_escore = ess;} /* fprintf(stderr,"%d: %4d %2d %3d %.4g %.4g\n", ib, bbp->rst.score[0], bbp->segnum,bbp->seglen,bbp->escore, ess); */ } if (min_escore > m_msg->e_cut) goto done; } done: return ib; }