📄 res_stats.c
字号:
return; } max_dev = 0.0; mh1 = hist.maxh-1; mht = (3*hist.maxh-3)/4 - 1; if (!m_msg.nohist && mh1 > 0) { for (i=0,maxval=0,maxvalt=0; i<hist.maxh; i++) { if (hist.hist_a[i] > maxval) maxval = hist.hist_a[i]; if (i >= mht && hist.hist_a[i]>maxvalt) maxvalt = hist.hist_a[i]; } n_chi_sq = 0; cum_hl = -hist.hist_a[0]; dotsiz = (maxval-1)/60+1; ddotsiz = (maxvalt-1)/50+1; doinset = (ddotsiz < dotsiz && dotsiz > 2); if (pst.zsflag>=0) fprintf(fd," opt E()\n"); else fprintf(fd," opt\n"); prev_e = zs_to_Ec((double)(hist.min_hist-hist.histint/2),hist.entries); for (i=0; i<=mh1; i++) { pch = (i==mh1) ? '>' : ' '; pch = (i==0) ? '<' : pch; hll = hl = hist.hist_a[i]; if (pst.zsflag>=0) { cum_hl += hl; f_int = (double)(i*hist.histint+hist.min_hist)+(double)hist.histint/2.0; cur_e = (double)zs_to_Ec(f_int,hist.entries); ev = el = ell = (int)(cur_e - prev_e + 0.5); if (hl > 0 && i > 5 && i < (90-hist.min_hist)/hist.histint) { x_tmp = fabs(cum_hl - cur_e); if ( x_tmp > max_dev) { max_dev = x_tmp; max_i = i; } n_chi_sq++; } if ((el=(el+dotsiz-1)/dotsiz) > 60) el = 60; if ((ell=(ell+ddotsiz-1)/ddotsiz) > 40) ell = 40; fprintf(fd,"%c%3d %5d %5d:", pch,(i<mh1)?(i)*hist.histint+hist.min_hist : mh1*hist.histint+hist.min_hist,hl,ev); } else fprintf(fd,"%c%3d %5d :", pch,(i<mh1)?(i)*hist.histint+hist.min_hist : mh1*hist.histint+hist.min_hist,hl); if ((hl=(hl+dotsiz-1)/dotsiz) > 60) hl = 60; if ((hll=(hll+ddotsiz-1)/ddotsiz) > 40) hll = 40; for (j=0; j<hl; j++) hline[j]='='; if (pst.zsflag>=0) { if (el <= hl ) { if (el > 0) hline[el-1]='*'; hline[hl]='\0'; } else { for (j = hl; j < el; j++) hline[j]=' '; hline[el-1]='*'; hline[hl=el]='\0'; } } else hline[hl] = 0; if (i==1) { for (j=hl; j<10; j++) hline[j]=' '; sprintf(&hline[10]," one = represents %d library sequences",dotsiz); } if (doinset && i == mht-2) { for (j = hl; j < 10; j++) hline[j]=' '; sprintf(&hline[10]," inset = represents %d library sequences",ddotsiz); } if (i >= mht&& doinset ) { for (j = hl; j < 10; j++) hline[j]=' '; hline[10]=':'; for (j = 11; j<11+hll; j++) hline[j]='='; hline[11+hll]='\0'; if (pst.zsflag>=0) { if (ell <= hll) hline[10+ell]='*'; else { for (j = 11+hll; j < 10+ell; j++) hline[j]=' '; hline[10+ell] = '*'; hline[11+ell] = '\0'; } } } fprintf(fd,"%s\n",hline); prev_e = cur_e; } } if (ntt.carry==0) { fprintf(fd, "%7ld residues in %5ld sequences\n", ntt.length, ntt.entries); } else { db_tt = (double)ntt.carry*(double)LONG_MAX + (double)ntt.length; fprintf(fd, "%.0f residues in %5ld library sequences\n", db_tt, ntt.entries); } if (pst.zsflag>=0) { if (MAX_STATS < hist.entries) fprintf(fd," statistics extrapolated from %d to %ld sequences\n", MAX_STATS,hist.entries); /* summ_stats(stat_info); */ fprintf(fd," %s\n",hist.stat_info); if (!m_msg.nohist && cum_hl > 0) fprintf(fd," Kolmogorov-Smirnov statistic: %6.4f (N=%d) at %3d\n", max_dev/(double)cum_hl, n_chi_sq,max_i*hist.histint+hist.min_hist); if (m_msg.markx & MX_M10FORM) { while ((bp=strchr(hist.stat_info,'\n'))!=NULL) *bp=' '; if (cum_hl <= 0) cum_hl = -1; sprintf(info_hstring1,"; mp_extrap: %d %ld\n; mp_stats: %s\n; mp_KS: %6.4f (N=%d) at %3d\n", MAX_STATS,hist.entries,hist.stat_info,max_dev/(double)cum_hl, n_chi_sq,max_i*hist.histint+hist.min_hist); } } fprintf(fd,"\n%s\n",info_gstring2); fflush(fd);}showbest(struct db_str ntt) { int ib, istart, istop; char bline[200], fmt[40], pad[200]; char rline[20]; int ntmp; int lcont, ccont, loff; int hcutoff; sprintf(fmt,"%%-%ds (%%3d)",llen-10); nshow = min(20,nbest); mshow = min(20,nbest); if (outtty) { printf(" How many scores would you like to see? [%d] ",nshow); fflush(stdout); if (fgets(rline,sizeof(rline),stdin)==NULL) exit(0); if (rline[0]!='\n' && rline[0]!=0) sscanf(rline,"%d",&nshow); if (nshow<=0) nshow = min(20,nbest); } else nshow=mshow; memset(pad,' ',llen-10); pad[llen-31]='\0'; if (zsflag) fprintf(outfd,"The best scores are:%s s-w Z-score E(%ld)\n",pad,ntt.entries); else fprintf(outfd,"The best scores are:%s s-w\n",pad); if (outfd != stdout) if (zsflag) fprintf(stdout,"The best scores are:%s s-w Z-score E(%ld)\n",pad,ntt.entries); else fprintf(stdout,"The best scores are:%s s-w\n",pad); istart = 0; l1: istop = min(nbest,nshow); for (ib=istart; ib<istop; ib++) { bbp = bptr[ib]; if (!outtty && zsflag && bbp->escore > e_cut) { nshow = ib; goto done; } sprintf(bline,"%-12s %d",bbp->libstr,bbp->lib); bline[13]='\0'; fprintf(outfd,fmt,bline,bbp->n1); if (zsflag) fprintf(outfd,"%4d %4.1f %6.2g\n", bbp->score,bbp->zscore, bbp->escore); else fprintf(outfd,"%4d\n",bbp->score); if (outfd!=stdout) { fprintf(stdout,fmt,bline,bbp->n1); if (zsflag) printf("%4d %4.1f %6.2g\n", bbp->score,bbp->zscore, bbp->escore); else printf("%4d\n",bbp->score); } } fflush(outfd); if (outfd!=stdout) fflush(stdout); if (outtty) { printf(" More scores? [0] "); fflush(stdout); if (fgets(rline,sizeof(rline),stdin)==NULL) exit(0); ntmp = 0; if (rline[0]!='\n' && rline[0]!=0) sscanf(rline,"%d",&ntmp); if (ntmp<=0) ntmp = 0; if (ntmp>0) { istart = istop; nshow += ntmp; mshow += ntmp; goto l1; } } else if (zsflag && bbp->escore < e_cut) { istart=istop; nshow += 10; goto l1; } done: if (outfd!=stdout) fprintf(outfd,"\n");}selectz(k,n) /* k is rank in array */ int k,n;{ int t, i, j, l, r; double v; struct beststr *tmptr; l=0; r=n-1; while ( r > l ) { i = l-1; j = r; v = bptr[r]->zscore; do { while (bptr[++i]->zscore > v ) ; while (bptr[--j]->zscore < v ) ; tmptr = bptr[i]; bptr[i]=bptr[j]; bptr[j]=tmptr; } while (j > i); bptr[j]=bptr[i]; bptr[i]=bptr[r]; bptr[r]=tmptr; if (i>=k) r = i-1; if (i<=k) l = i+1; }}sortbest(){ int cmps(), cmp1(), cmpa(), cmpz(); ksort(bptr,nbest,cmps);}sortbeste(){ int cmpe(); ksort(bptr,nbest,cmpe);}sortbestz(){ int cmpz(); ksort(bptr,nbest,cmpz);}cmps(ptr1,ptr2) struct beststr *ptr1, *ptr2;{ if (ptr1->score < ptr2->score) return (1); else if (ptr1->score > ptr2->score) return (-1); else return (0);}cmpe(ptr1,ptr2) struct beststr *ptr1, *ptr2;{ if (ptr1->escore < ptr2->escore) return (-1); else if (ptr1->escore > ptr2->escore) return (1); else return (0);}cmpz(ptr1,ptr2) struct beststr *ptr1, *ptr2;{ if (ptr1->zscore < ptr2->zscore) return (1); else if (ptr1->zscore > ptr2->zscore) return (-1); else return (0);}ksort(v,n,comp) char *v[]; int n, (*comp)();{ int gap, i, j; char *tmp; for (gap=n/2; gap>0; gap/=2) for (i=gap; i<n; i++) for (j=i-gap; j>=0; j -= gap) { if ((*comp)(v[j],v[j+gap]) <=0) break; tmp = v[j]; v[j]=v[j+gap]; v[j+gap]=tmp; }}/*do_bout(FILE *bout,struct stat_str **bptr, int nbest){ int i, min_hist, max_hist; double mu, var; if (bout==NULL) return; inithist(); for (i = 0; i<nbest; i++) addhist(bptr[i]->score,bptr[i]->n1); for (i=0; i<MAX_LLEN; i++) if (llen_hist[i]>0) { min_hist=i; break; } for (i=MAX_LLEN-1; i>=0; i--) if (llen_hist[i]>0) { max_hist=i; break; } for (i=min_hist; i<=max_hist; i++) { mu=(double)score_sums[i]/(double)llen_hist[i]; if (llen_hist[i]>1) { var = ((double)score2_sums[i]-(double)llen_hist[i]*mu*mu)/ (double)(llen_hist[i]-1); fprintf(bout,"%d\t%d\t%.1f\t%.1f\t%.1f\t%.4f\t%.4f\n", i,llen_hist[i],exp(((double)(i))/LN_FACT), score_sums[i],score2_sums[i],mu,var); } } free_hist(); fclose(bout);}*/s_abort(){ exit(1);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -