⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blast_gapalign.c

📁 ncbi源码
💻 C
📖 第 1 页 / 共 5 页
字号:
                else                    script = SCRIPT_NEXT_PLUS_TWO_FRAMES;            }            else {                if (score_other_frame2 == score_col2)                    script = SCRIPT_AHEAD_ONE_FRAME;                else                    script = SCRIPT_NEXT_PLUS_ONE_FRAME;            }            score += matrix_row[ B[ b_index * increment ] ];            score_other_frame1 = score_other_frame2;            score_other_frame2 = MAX(score_col3, score_array[b_index].best);            score_col3 = score_array[b_index].best;            score_gap_col = score_array[b_index].best_gap;            if (score < MAX(score_gap_col, score_row3)) {                score = MAX(score_gap_col, score_row3);                if (best_score - score > x_dropoff) {                    if (first_b_index == b_index)                         first_b_index = b_index + 1;                    else                        score_array[b_index].best = MININT;                }                else {                    if (score == score_gap_col)                        script = SCRIPT_OOF_OPEN_GAP | SCRIPT_GAP_IN_A;                    else                         script = SCRIPT_OOF_OPEN_GAP | SCRIPT_GAP_IN_B;                    last_b_index = b_index + 1;                    score_array[b_index].best = score;                    score_array[b_index].best_gap = score_gap_col - gap_extend;                    score_row3 -= gap_extend;                }            }            else {                if (best_score - score > x_dropoff) {                    if (first_b_index == b_index)                         first_b_index = b_index + 1;                    else                        score_array[b_index].best = MININT;                }                else {                    last_b_index = b_index + 1;                    score_array[b_index].best = score;                    if (score > best_score) {                        best_score = score;                        *a_offset = a_index;                        *b_offset = b_index;                    }                    score -= gap_open_extend;                    score_row3 -= gap_extend;                    if (score > score_row3)                        score_row3 = score;                    else                        script |= SCRIPT_EXTEND_GAP_IN_B;                    score_gap_col -= gap_extend;                    if (score < score_gap_col) {                        score_array[b_index].best_gap = score_gap_col;                        script |= SCRIPT_EXTEND_GAP_IN_A;                    }                    else {                        score_array[b_index].best_gap = score;                    }                }            }            edit_script_row[b_index] = script;            b_index++;        }          /* Finish aligning if the best scores for all positions           of B will fail the X-dropoff test, i.e. the inner loop            bounds have converged to each other */        if (first_b_index == b_size)            break;        if (last_b_index < b_size) {            /* This row failed the X-dropoff test earlier than               the last row did; just shorten the loop bounds               before doing the next row */            b_size = last_b_index;        }        else {            /* The inner loop finished without failing the X-dropoff               test; initialize extra bookkeeping structures until               the X dropoff test fails or we run out of letters in B.                The next inner loop will have larger bounds.                             Keep initializing extra structures until the X dropoff               test fails in all frames for this row */            score = MAX(score_row1, MAX(score_row2, score_row3));            last_b_index = b_size + (score - (best_score - x_dropoff)) /                                                    gap_extend;            last_b_index = MIN(last_b_index, N + 2);            while (b_size < last_b_index) {                score_array[b_size].best = score_row1;                score_array[b_size].best_gap = score_row1 - gap_open_extend;                score_row1 -= gap_extend;                edit_script_row[b_size] = SCRIPT_OOF_OPEN_GAP | SCRIPT_GAP_IN_B;                if (++b_size > last_b_index)                    break;                score_array[b_size].best = score_row2;                score_array[b_size].best_gap = score_row2 - gap_open_extend;                score_row2 -= gap_extend;                edit_script_row[b_size] = SCRIPT_OOF_OPEN_GAP | SCRIPT_GAP_IN_B;                if (++b_size > last_b_index)                    break;                score_array[b_size].best = score_row3;                score_array[b_size].best_gap = score_row3 - gap_open_extend;                score_row3 -= gap_extend;                edit_script_row[b_size] = SCRIPT_OOF_OPEN_GAP | SCRIPT_GAP_IN_B;                if (++b_size > last_b_index)                    break;            }        }        /* chop off the best score in each frame */        last_b_index = MIN(b_size + 4, N + 3);        while (b_size < last_b_index) {            score_array[b_size].best = MININT;            score_array[b_size].best_gap = MININT;            b_size++;        }        state_struct->used += MAX(b_index, b_size) - orig_b_index + 1;    }    a_index = *a_offset;    b_index = *b_offset;    script = 1;    align_len = 0;    edit_script_row = (Uint1 *)malloc(a_index + b_index);    while (a_index > 0 || b_index > 0) {        next_script = edit_script[a_index][b_index];        switch (script) {        case SCRIPT_GAP_IN_A:            script = next_script & SCRIPT_OOF_OP_MASK;            if (next_script & (SCRIPT_OOF_OPEN_GAP | SCRIPT_EXTEND_GAP_IN_A))                script = SCRIPT_GAP_IN_A;            break;        case SCRIPT_GAP_IN_B:            script = next_script & SCRIPT_OOF_OP_MASK;            if (next_script & (SCRIPT_OOF_OPEN_GAP | SCRIPT_EXTEND_GAP_IN_B))                script = SCRIPT_GAP_IN_B;            break;        default:            script = next_script & SCRIPT_OOF_OP_MASK;            break;        }        if (script == SCRIPT_GAP_IN_B) {            b_index -= 3;        }        else {            b_index -= script;            a_index--;        }        edit_script_row[align_len++] = script;    }    /* Traceback proceeded backwards through edit_script,        so the output traceback information is written        in reverse order */    for (align_len--; align_len >= 0; align_len--)         *data.sapp++ = edit_script_row[align_len];          sfree(edit_script_row);    sfree(edit_script);    sfree(score_array);    *sapp = data.sapp;    if (!reversed)        *b_offset -= 2;    return best_score;}/** Low level function to perform gapped extension with out-of-frame * gapping with or without traceback. * @param A The query sequence [in] * @param B The subject sequence [in] * @param M Maximal extension length in query [in] * @param N Maximal extension length in subject [in] * @param S The traceback information from previous extension [in] * @param a_offset Resulting starting offset in query [out] * @param b_offset Resulting starting offset in subject [out] * @param score_only Only find the score, without saving traceback [in] * @param sapp the traceback information [out] * @param gap_align Structure holding various information and allocated  *        memory for the gapped alignment [in] * @param score_params Parameters related to scoring [in] * @param query_offset The starting offset in query [in] * @param reversed Has the sequence been reversed? Used for psi-blast [in] * @return The best alignment score found. */static Int4 OOF_SEMI_G_ALIGN(Uint1* A, Uint1* B, Int4 M, Int4 N,   Int4* S, Int4* a_offset, Int4* b_offset, Boolean score_only, Int4** sapp,    BlastGapAlignStruct* gap_align, const BlastScoringParameters* score_params,   Int4 query_offset, Boolean reversed){    BlastGapDP* score_array;            /* sequence pointers and indices */    Int4 i, increment;     Int4 a_index;    Int4 b_index, b_size, first_b_index, last_b_index;      Int4 gap_open;              /* alignment penalty variables */    Int4 gap_extend;    Int4 gap_open_extend;    Int4 shift_penalty;    Int4 x_dropoff;      Int4* *matrix;              /* pointers to the score matrix */    Int4* matrix_row;      Int4 score;                 /* score tracking variables */    Int4 score_row1;     Int4 score_row2;     Int4 score_row3;    Int4 score_gap_col;     Int4 score_col1;     Int4 score_col2;     Int4 score_col3;    Int4 score_other_frame1;     Int4 score_other_frame2;     Int4 best_score;      if (!score_only) {        return OOF_ALIGN(A, B, M, N, S, a_offset, b_offset, sapp, gap_align,                       score_params, query_offset, reversed);    }        /* do initialization and sanity-checking */    matrix = gap_align->sbp->matrix;    *a_offset = 0;    *b_offset = -2;    gap_open = score_params->gap_open;    gap_extend = score_params->gap_extend;    gap_open_extend = gap_open + gap_extend;    shift_penalty = score_params->shift_pen;    x_dropoff = gap_align->gap_x_dropoff;      if (x_dropoff < gap_open_extend)        x_dropoff = gap_open_extend;      if(N <= 0 || M <= 0)         return 0;      /* Allocate and fill in the auxiliary        bookeeping structures (one struct       per letter of B) */    score_array = (BlastGapDP*)calloc((N + 5), sizeof(BlastGapDP));    score = -gap_open_extend;    score_array[0].best = 0;    score_array[0].best_gap = -gap_open_extend;      for (i = 3; i <= N + 2; i += 3) {        score_array[i].best = score;        score_array[i].best_gap = score - gap_open_extend;         score_array[i-1].best = MININT;        score_array[i-1].best_gap = MININT;        score_array[i-2].best = MININT;        score_array[i-2].best_gap = MININT;        if (score < -x_dropoff)             break;        score -= gap_extend;    }      /* The inner loop below examines letters of B from        index 'first_b_index' to 'b_size' */    b_size = i - 2;    score_array[b_size].best = MININT;    score_array[b_size].best_gap = MININT;    best_score = 0;    first_b_index = 0;    if (reversed) {        increment = -1;    }    else {        /* Allow for a backwards frame shift */        B -= 2;        increment = 1;    }      for (a_index = 1; a_index <= M; a_index++) {        /* XXX Why is this here? */        score_array[2].best = MININT;        score_array[2].best_gap = MININT;        /* pick out the row of the score matrix            appropriate for A[a_index] */        if (!(gap_align->positionBased)) {            matrix_row = matrix[ A[ a_index * increment ] ];        }        else {            if(reversed)                matrix_row = gap_align->sbp->posMatrix[M - a_index];            else                 matrix_row = gap_align->sbp->posMatrix[a_index + query_offset];        }        /* initialize running-score variables */        score = MININT;        score_row1 = MININT;         score_row2 = MININT;         score_row3 = MININT;        score_gap_col = MININT;         score_col1 = MININT;         score_col2 = MININT;         score_col3 = MININT;        score_other_frame1 = MININT;         score_other_frame2 = MININT;         last_b_index = first_b_index;        b_index = first_b_index;        while (b_index < b_size) {            /* FRAME 0 */            /* Pick the best score among all frames */            score = MAX(score_other_frame1, score_other_frame2) - shift_penalty;            score = MAX(score, score_col1) +                                 matrix_row[ B[ b_index * increment ] ];            score_other_frame1 = MAX(score_col1, score_array[b_index].best);            score_col1 = score_array[b_index].best;            score_gap_col = score_array[b_index].best_gap;            /* Use the row and column scores if they improve               the score overall */            if (score < MAX(score_gap_col, score_row1)) {                score = MAX(score_gap_col, score_row1);                if (best_score - score > x_dropoff) {                   /* the current best score failed the X-dropoff                      criterion. Note that this does not stop the                      inner loop, only forces future iterations to                      skip this column of B.                          Also, if the very first letter of B that was                      tested failed the X dropoff criterion, make                      sure future inner loops start one letter to                       the right */                    if (first_b_index == b_index)                         first_b_index = b_index + 1;                    else                        score_array[b_index].best = MININT;                }                else {                    /* update the row and column running scores */                    last_b_index = b_index + 1;                    score_array[b_index].best = score;                    score_array[b_index].best_gap = score_gap_col - gap_extend;                    score_row1 -= gap_extend;                }            }            else {                if (best_score - score > x_dropoff) {                   /* the current best score failed the X-dropoff                      criterion. */                    if (first_b_index == b_index)                         first_b_index = b_index + 1;                    else                        score_array[b_index].best = MININT;                }                else {                    /* The current best score exceeds the                       row and column scores, and thus may                       improve on the current optimal score */                    last_b_index = b_index + 1;                    score_array[b_index].best = score;                    if (score > best_sco

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -