📄 dropfz2.c
字号:
fprintf(stderr,"\n-----\n");*//* fprintf(stderr,"n1: %d, aa1x[n1]: %d; EOSEQ: %d\n", n1,f_str->aa1x[n1],EOSEQ); for (fs=aa1,itemp=0; itemp <3; itemp++,fs++) { for (fd= &f_str->aa1x[itemp]; *fs!=EOSEQ; fd += 3, fs++) *fd = *fs; fprintf(stderr,"fs stopped at: %d\n",(int)(fs-f_str->aa1x)); *fd=EOSEQ; }*//* for (i=0; i<n1; i++) { fputc(ppst->sq[f_str->aa1x[i]],stderr); if (i%60==59) fputc('\n',stderr); }*/ rst->score[2] = dmatchx(aa0, n0, aa1, n1, *hoff=vmptr->dp-f_str->noff, ppst->param_u.fa.optwid, ppst->pam2[0], ppst->gdelval,ppst->ggapval,ppst->gshift,f_str);#endif /* TFAST */ } }}void do_work (const unsigned char *aa0, int n0, const unsigned char *aa1, int n1, int frame, struct pstruct *ppst, struct f_struct *f_str, int qr_flg, struct rstruct *rst){ int hoff; int last_n1, itx, dnav, n10, i, ir; unsigned char *aa1x; rst->escore = 1.0; rst->segnum = rst->seglen = 1; if (n1 < ppst->param_u.fa.ktup) { rst->score[0] = rst->score[1] = rst->score[2] = 0; return; }#ifndef TFAST do_fasta (f_str->aa0x, n0, aa1, n1, ppst, f_str, rst, &hoff);#else /* make a precomputed codon number series */ if (frame == 0) { pre_com(aa1, n1, f_str->aa1v); } else { pre_com_r(aa1, n1, f_str->aa1v); } /* make translated sequence */ last_n1 = 0; aa1x = f_str->aa1x; for (itx= frame*3; itx< frame*3+3; itx++) { n10 = saatran(aa1,&aa1x[last_n1],n1,itx); /* fprintf(stderr," itt %d frame: %d\n",itx,frame); for (i=0; i<n10; i++) { fprintf(stderr,"%c",aa[f_str->aa1x[last_n1+i]]); if ((i%60)==59) fprintf(stderr,"\n"); } fprintf(stderr,"\n"); fprintf(stderr,"n10: %d aa1x[] %d last_n1: %d\n",n10,aa1x[last_n1+n10], last_n1); */ last_n1 += n10+1; } n10 = last_n1-1; do_fasta (aa0, n0, f_str->aa1x, n10, ppst, f_str, rst, &hoff);#endif}void do_opt (const unsigned char *aa0, int n0, const unsigned char *aa1, int n1, int frame, struct pstruct *ppst, struct f_struct *f_str, struct rstruct *rst){ int optflag, tscore, hoff; optflag = ppst->param_u.fa.optflag; ppst->param_u.fa.optflag = 1;#ifndef TFAST do_fasta (f_str->aa0x, n0, aa1, n1, ppst, f_str, rst, &hoff);#else do_fasta (aa0, n0, aa1, n1, ppst, f_str, rst, &hoff);#endif ppst->param_u.fa.optflag = optflag;}#ifdef ALLOCN0voidsavemax (dptr, dpos, f_str) register struct dstruct *dptr; int dpos; struct f_struct *f_str;{ register struct savestr *vmptr; register int i;#elsevoidsavemax (dptr, f_str) register struct dstruct *dptr; struct f_struct *f_str;{ register int dpos; register struct savestr *vmptr; register int i; dpos = (int) (dptr - f_str->diag);#endif/* check to see if this is the continuation of a run that is already saved */ if ((vmptr = dptr->dmax) != NULL && vmptr->dp == dpos && vmptr->start == dptr->start) { vmptr->stop = dptr->stop; if ((i = dptr->score) <= vmptr->score) return; vmptr->score = i; if (vmptr != f_str->lowmax) return; } else { i = f_str->lowmax->score = dptr->score; f_str->lowmax->dp = dpos; f_str->lowmax->start = dptr->start; f_str->lowmax->stop = dptr->stop; dptr->dmax = f_str->lowmax; } for (vmptr = f_str->vmax; vmptr < &f_str->vmax[MAXSAV]; vmptr++) if (vmptr->score < i) { i = vmptr->score; f_str->lowmax = vmptr; } f_str->lowscor = i;}int spam (const unsigned char *aa0, const unsigned char *aa1, struct savestr *dmax, int **pam2, struct f_struct *f_str){ int lpos; int tot, mtot; struct { int start, stop, score; } curv, maxv; const unsigned char *aa0p, *aa1p; aa1p = &aa1[lpos = dmax->start]; aa0p = &aa0[lpos - dmax->dp + f_str->noff]; curv.start = lpos; tot = curv.score = maxv.score = 0; for (; lpos <= dmax->stop; lpos++) { tot += pam2[*aa0p++][*aa1p++]; if (tot > curv.score) { curv.stop = lpos; curv.score = tot; } else if (tot < 0) { if (curv.score > maxv.score) { maxv.start = curv.start; maxv.stop = curv.stop; maxv.score = curv.score; } tot = curv.score = 0; curv.start = lpos+1; } } if (curv.score > maxv.score) { maxv.start = curv.start; maxv.stop = curv.stop; maxv.score = curv.score; }/* if (maxv.start != dmax->start || maxv.stop != dmax->stop) printf(" new region: %3d %3d %3d %3d\n",maxv.start, dmax->start,maxv.stop,dmax->stop);*/ dmax->start = maxv.start; dmax->stop = maxv.stop; return maxv.score;}#define XFACT 10int sconn (struct savestr **v, int n, int cgap, int pgap, struct f_struct *f_str){ int i, si; struct slink { int score; struct savestr *vp; struct slink *next; } *start, *sl, *sj, *so, sarr[MAXSAV]; int lstart, tstart, plstop, ptstop;/* sort the score left to right in lib pos */ kpsort (v, n); start = NULL;/* for the remaining runs, see if they fit */ for (i = 0, si = 0; i < n; i++) {/* if the score is less than the gap penalty, it never helps */ if (v[i]->score < cgap) continue; lstart = v[i]->start; tstart = lstart - v[i]->dp + f_str->noff;/* put the run in the group */ sarr[si].vp = v[i]; sarr[si].score = v[i]->score; sarr[si].next = NULL;/* if it fits, then increase the score */ for (sl = start; sl != NULL; sl = sl->next) { plstop = sl->vp->stop; ptstop = plstop - sl->vp->dp + f_str->noff; if (plstop < lstart+XFACT && ptstop < tstart+XFACT) { sarr[si].score = sl->score + v[i]->score + pgap; break; } }/* now recalculate where the score fits */ if (start == NULL) start = &sarr[si]; else for (sj = start, so = NULL; sj != NULL; sj = sj->next) { if (sarr[si].score > sj->score) { sarr[si].next = sj; if (so != NULL) so->next = &sarr[si]; else start = &sarr[si]; break; } so = sj; } si++; } if (start != NULL) return (start->score); else return (0);}voidkssort (v, n)struct savestr *v[];int n;{ int gap, i, j; struct savestr *tmp; for (gap = n / 2; gap > 0; gap /= 2) for (i = gap; i < n; i++) for (j = i - gap; j >= 0; j -= gap) { if (v[j]->score >= v[j + gap]->score) break; tmp = v[j]; v[j] = v[j + gap]; v[j + gap] = tmp; }}voidkpsort (v, n)struct savestr *v[];int n;{ int gap, i, j; struct savestr *tmp; for (gap = n / 2; gap > 0; gap /= 2) for (i = gap; i < n; i++) for (j = i - gap; j >= 0; j -= gap) { if (v[j]->start <= v[j + gap]->start) break; tmp = v[j]; v[j] = v[j + gap]; v[j + gap] = tmp; }}static intdmatchx(const unsigned char *aa0, int n0, const unsigned char *aa1, int n1, int hoff, int window, int **pam2, int gdelval, int ggapval, int gshift, struct f_struct *f_str){ hoff -= window/2;#ifndef TFAST return lx_band(aa1,n1,f_str->aa0v,n0-2, pam2,#ifdef OLD_FASTA_GAP -(gdelval - ggapval),#else -gdelval,#endif -ggapval,-gshift, hoff,window,f_str);#else return lx_band(aa0,n0,f_str->aa1v,n1-2, pam2,#ifdef OLD_FASTA_GAP -(gdelval - ggapval),#else -gdelval,#endif -ggapval,-gshift, hoff,window,f_str);#endif}static voidinit_row(struct sx_s *row, int sp) { int i; for (i = 0; i < sp; i++) { row[i].C1 = row[i].I1 = 0; row[i].C2 = row[i].I2 = 0; row[i].C3 = row[i].I3 = 0; row[i].flag = 0; }}int lx_band(const unsigned char *prot_seq, /* array with protein sequence numbers*/ int len_prot, /* length of prot. seq */ const unsigned char *dna_prot_seq, /* translated DNA sequence numbers*/ int len_dna_prot, /* length trans. seq. */ int **pam_matrix, /* scoring matrix */ int gopen, int gext, /* gap open, gap extend penalties */ int gshift, /* frame-shift penalty */ int start_diag, /* start diagonal of band */ int width, /* width for band alignment */ struct f_struct *f_str){ void *ckalloc(); int i, j, bd, bd1, x1, x2, sp, p1=0, p2=0, end_prot; struct sx_s *last, *tmp; int sc, del, best = 0, cd,ci, e1, e2, e3, cd1, cd2, cd3, f, gg; const unsigned char *dp; register struct sx_s *ap, *aq; struct wgt *wt, *ww; int aa, b, a,x,y,z; sp = width+7; gg = gopen+gext; /* sp = sp/3+1; */ if (f_str->cur == NULL) { f_str->cur = (struct sx_s *) ckalloc(sizeof(struct sx_s)*sp); } init_row(f_str->cur, sp); /* if (start_diag %3 !=0) start_diag = start_diag/3-1; else start_diag = start_diag/3; if (width % 3 != 0) width = width/3+1; else width = width /3; */ x1 = start_diag; /* x1 = lower bound of DNA */ x2 = 1; /* the amount of position shift from last row*/ end_prot = max(0,-width-start_diag) + (len_dna_prot+5)/3 + width; end_prot = min(end_prot,len_prot); /* i counts through protein sequence, x1 through DNAp */ for (i = max(0, -width-start_diag), x1+=i; i < len_prot; i++, x1++) { bd = min(x1+width, (len_dna_prot+2)/3); /* upper bound of band */ bd1 = max(0,x1); /* lower bound of band */ wt = f_str->weight0[prot_seq[i]]; del = 1-x1; /*adjustment*/ bd += del; bd1 +=del; ap = &f_str->cur[bd1]; aq = ap+1; e1 = f_str->cur[bd1-1].C3; e2 = ap->C1; cd1 = cd2= cd3= 0; for (dp = &dna_prot_seq[(bd1-del)*3]; ap < &f_str->cur[bd]; ap++) { ww = &wt[(unsigned char) *dp++]; sc = max(max(e1+ww->iv, (e3=ap->C2)+ww->ii), e2+ww->iii); if (cd1 > sc) sc = cd1; cd1 -= gext; if ((ci = aq->I1) > 0) { if (sc < ci) { ap->C1 = ci; ap->I1 = ci-gext;} else { ap->C1 = sc; sc -= gg; if (sc > 0) { if (sc > best) best =sc; if (cd1 < sc) cd1 = sc; ap->I1 = max(ci-gext, sc); } else ap->I1 = ci-gext; } } else { if (sc <= 0) { ap->I1 = ap->C1 = 0; } else { ap->C1 = sc; sc-=gg; if (sc >0) { if (sc > best) best =sc; if (cd1 < sc) cd1 = sc; ap->I1 = sc; } else ap->I1 = 0; } } ww = &wt[(unsigned char) *dp++]; sc = max(max(e2+ww->iv, (e1=ap->C3)+ww->ii), e3+ww->iii); if (cd2 > sc) sc = cd2; cd2 -= gext; if ((ci = aq->I2) > 0) { if (sc < ci) { ap->C2 = ci; ap->I2 = ci-gext;} else { ap->C2 = sc; sc -= gg; if (sc > 0) { if (sc > best) best =sc; if (cd2 < sc) cd2 = sc; ap->I2 = max(ci-gext, sc); } } } else { if (sc <= 0) { ap->I2 = ap->C2 = 0; } else { ap->C2 = sc; sc-=gg; if (sc >0) { if (sc > best) best =sc; if (cd2 < sc) cd2 = sc; ap->I2 = sc; } else ap->I2 = 0; } } ww = &wt[(unsigned char)*dp++]; sc = max(max(e3+ww->iv, (e2=aq->C1)+ww->ii), e1+ww->iii); if (cd3 > sc) sc = cd3; cd3 -= gext; if ((ci = aq++->I3) > 0) { if (sc < ci) { ap->C3 = ci; ap->I3 = ci-gext;} else { ap->C3 = sc; sc -= gg; if (sc > 0) { if (sc > best) best =sc; if (cd3 < sc) cd3 = sc; ap->I3 = max(ci-gext, sc); } } } else { if (sc <= 0) { ap->I3 = ap->C3 = 0; } else { ap->C3 = sc; sc-=gg; if (sc >0) { if (sc > best) best =sc; if (cd3 < sc) cd3 = sc; ap->I3 = sc; } else ap->I3 = 0; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -