📄 dropgsw2.c
字号:
f_str->word_score, n0, aa1, n1, f_str->bias,#ifndef OLD_FASTA_GAP -(ppst->gdelval + ppst->ggapval),#else -ppst->gdelval,#endif -ppst->ggapval, f_str); } #endif /* not Altivec */#if defined(SW_SSE2) if(f_str->try_8bit) { score = smith_waterman_sse2_byte(aa0, f_str->byte_score, n0, aa1, n1, f_str->bias,#ifndef OLD_FASTA_GAP -(ppst->gdelval + ppst->ggapval),#else -ppst->gdelval,#endif -ppst->ggapval, f_str); f_str->done_8bit++; if(score>=255) { /* Overflow, so we have to redo it in 16 bits. */ score = smith_waterman_sse2_word(aa0, f_str->word_score, n0, aa1, n1,#ifndef OLD_FASTA_GAP -(ppst->gdelval + ppst->ggapval),#else -ppst->gdelval,#endif -ppst->ggapval, f_str); /* The 8 bit version is roughly 50% faster than the 16 bit version, * so we are fine if less than about 1/3 of the runs have to * be rerun with 16 bits. If it is more, and we have tried at least * 500 sequences, we switch off the 8-bit mode. */ f_str->done_16bit++; if(f_str->done_8bit>500 && (3*f_str->done_16bit)>(f_str->done_8bit)) f_str->try_8bit = 0; } } else { /* Just use the 16-bit altivec version directly */ score = smith_waterman_sse2_word(aa0, f_str->word_score, n0, aa1, n1,#ifndef OLD_FASTA_GAP -(ppst->gdelval + ppst->ggapval),#else -ppst->gdelval,#endif -ppst->ggapval, f_str); } #endif#if !defined(SW_ALTIVEC) && !defined(SW_SSE2) score = FLOCAL_ALIGN(aa0,aa1,n0,n1,0,0, NULL,#ifdef OLD_FASTA_GAP -(ppst->gdelval - ppst->ggapval),#else -ppst->gdelval,#endif -ppst->ggapval,0,f_str);#endif rst->score[0] = score; rst->score[1] = rst->score[2] = 0; if(( ppst->zsflag == 6 || ppst->zsflag == 16) && (do_karlin(aa1, n1, ppst->pam2[0], ppst,f_str->aa0_f, f_str->kar_p, &lambda, &H)>0)) { rst->comp = 1.0/lambda; rst->H = H; } else {rst->comp = rst->H = -1.0;}}static intFLOCAL_ALIGN(const unsigned char *aa0, const unsigned char *aa1, int n0, int n1, int low, int up, int **W, int GG,int HH, int MW, struct f_struct *f_str) { register int *pwaa; register struct swstr *ssj; struct swstr *ss; register int h, e, f, p; int temp, score; int gap_ext, n_gap_init; const unsigned char *aa1p; ss = f_str->ss; ss[n0].H = -1; ss[n0].E = 1; n_gap_init = GG + HH; gap_ext = -HH; /* GG, HH are both positive, gap_ext penalty should be negative */ score = 0; for (h=0; h<n0; h++) { /* initialize 0th row */ ss[h].H = ss[h].E = 0; } aa1p=aa1; while (*aa1p) { /* relies on aa1[n1]==0 for EOS flag */ /* waa_s has the offsets for each residue in aa0 into pam2 */ /* waa_s has complexity (-S) dependent scores */ pwaa = f_str->waa_s + (*aa1p++)*n0; ssj = ss; e = f = h = p = 0; zero_f: /* in this section left-gap f==0, and is never examined */ while (1) { /* build until h > n_gap_init (f < 0 until h > n_gap_init) */ /* bump through the pam[][]'s for each of the aa1[] matches to aa0[], because of the way *pwaa is set up */ h = p + *pwaa++; /* increment diag value */ p = ssj->H; /* get next diag value */ if ((e = ssj->E) > 0 ) { /* >0 from up-gap */ if (p == -1) goto next_row; /* done, -1=ss[n0].H sentinel */ if (h < e) h = e; /* up-gap better than diag */ else if (h > n_gap_init) { /* we won't starting a new up-gap */ e += gap_ext; /* but we might be extending one */ goto transition; /* good h > n_gap_diag; scan f */ } e += gap_ext; /* up-gap decreased */ ssj->E = (e > 0) ? e : 0; /* set to 0 if < 0 */ ssj++->H = h; /* diag match updated */ } else { /* up-gap (->E) is 0 */ if ( h > 0) { /* diag > 0 */ if (h > n_gap_init) { /* we won't be starting a new up-gap */ e = 0; /* and we won't be extending one */ goto transition; /* good h > n_gap_diag; scan f */ } ssj++->H = h; /* update diag */ } else ssj++->H = 0; /* update diag to 0 */ } } /* here h > n_gap_init and h > e, => the next f will be > 0 */ transition:#ifdef DEBUG if ( h > 10000) fprintf(stderr,"h: %d ssj: %d\n",h, (int)(ssj-ss));#endif if ( score < h ) score = h; /* save best score, only when h > n_gap_init */ temp = h - n_gap_init; /* best score for starting a new gap */ if ( f < temp ) f = temp; /* start a left-gap? */ if ( e < temp ) e = temp; /* start an up-gap? */ ssj->E = ( e > 0 ) ? e : 0; /* update up-gap */ ssj++->H = h; /* update diag */ e = 0; do { /* stay here until f <= 0 */ h = p + *pwaa++; /* diag + match/mismatch */ p = ssj->H; /* save next (right) diag */ if ( h < f ) h = f; /* update diag using left gap */ f += gap_ext; /* update next left-gap */ if ((e = ssj->E) > 0) { /* good up gap */ if (p == -1) goto next_row; /* at the end of the row */ if ( h < e ) h = e; /* update diag using up-gap */ else if ( h > n_gap_init ) { e += gap_ext; /* update up gap */ goto transition; /* good diag > n_gap_init, restart */ } e += gap_ext; /* update up-gap */ ssj->E = (e > 0) ? e : 0; /* e must be >= 0 */ ssj++->H = h; /* update diag */ } else { /* up-gap <= 0 */ if ( h > n_gap_init ) { e = 0; goto transition; /* good diag > n_gap_init; restart */ } ssj++->H = h; /* update diag */ } } while ( f > 0 ); /* while left gap f > 0 */ goto zero_f; /* otherwise, go to f==0 section */ next_row: ; } /* end while(*aap1) {} */ return score;} /* here we should be all done */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){}voiddo_walign (const unsigned char *aa0, int n0, const unsigned char *aa1, int n1, int frame, struct pstruct *ppst, struct f_struct *f_str, struct a_res_str *a_res, int *have_ares){ *have_ares = 0x3; /* set 0x2 bit to indicate local copy */ #ifndef LALIGN /* now we need alignment storage - get it */ if ((a_res->res = (int *)calloc((size_t)f_str->max_res,sizeof(int)))==NULL) { fprintf(stderr," *** cannot allocate alignment results array %d\n",f_str->max_res); exit(1); } a_res->next = NULL; a_res->sw_score = sw_walign(f_str->pam2p[0], n0, aa1, n1, #ifdef OLD_FASTA_GAP -(ppst->gdelval - ppst->ggapval),#else -ppst->gdelval,#endif -ppst->ggapval, f_str->ss, a_res);#else /* LALIGN */ if (!ppst->show_ident && same_seq(aa0, n0, aa1, n1)) ppst->nseq = 1; else ppst->nseq = 2; SIM(aa0-1, aa1-1, n0, n1, ppst, ppst->nseq, ppst->repeat_thresh, ppst->max_repeat, a_res);#endif}/*#define XTERNAL#include "upam.h"voidprint_seq_prof(unsigned char *A, int M, unsigned char *B, int N, int **w, int iw, int dir) { char c_max; int i_max, j_max, i,j; char *c_dir="LRlr"; for (i=1; i<=min(60,M); i++) { fprintf(stderr,"%c",aa[A[i]]); } fprintf(stderr, - %d\n,M); for (i=0; i<min(60,M); i++) { i_max = -1; for (j=1; j<21; j++) { if (w[iw+i][j]> i_max) { i_max = w[iw+i][j]; j_max = j; } } fprintf(stderr,"%c",aa[j_max]); } fputc(':',stderr); for (i=1; i<=min(60,N); i++) { fprintf(stderr,"%c",aa[B[i]]); } fprintf(stderr," -%c: %d,%d\n",c_dir[dir],M,N);}*/voidpre_cons(const unsigned char *aa1, int n1, int frame, struct f_struct *f_str) {#ifdef TFAST f_str->n10 = aatran(aa1,f_str->aa1x,n1,frame);#endif}/* aln_func_vals - set up aln.qlfact, qlrev, llfact, llmult, frame, llrev *//* call from calcons, calc_id, calc_code */void aln_func_vals(int frame, struct a_struct *aln) { aln->llfact = aln->llmult = aln->qlfact = 1; aln->qlrev = aln->llrev = 0; aln->frame = 0;}/* calculate the 100% identical score */intprof_score(const unsigned char *aa1p, int n0, int *pwaa_s){ int sum=0; while (*aa1p) { sum += pwaa_s[(*aa1p++)*n0]; pwaa_s++; } return sum;}int same_seq(const unsigned char *aa0, int n0, const unsigned char *aa1, int n1){ const unsigned char *ap0, *ap1; int cnt=0; if (n0 != n1) return 0; ap0 = aa0; ap1 = aa1; while ( *ap0 && *ap0++ == *ap1++ ) {cnt++;} if (cnt != n0) return 0; return 1;}#ifdef PCOMPLIB#include "p_mw.h"voidupdate_params(struct qmng_str *qm_msg, struct pstruct *ppst){ ppst->n0 = qm_msg->n0;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -