Exemplo n.º 1
0
void aligmentStr(char** query_str, char** target_str, Alignment* alignment, const char gap_item) {
    /* code take from SW# (its a private function)*/
    Chain* query = alignmentGetQuery(alignment);
    int query_start = alignmentGetQueryStart(alignment);

    Chain* target = alignmentGetTarget(alignment);
    int target_start = alignmentGetTargetStart(alignment);

    int path_len = alignmentGetPathLen(alignment);

    int query_idx = query_start;
    int target_idx = target_start;

    *query_str = new char[path_len];
    *target_str = new char[path_len];

    int i;
    for (i = 0; i < path_len; ++i) {

        char query_chr;
        char target_chr;

        switch (alignmentGetMove(alignment, i)) {
        case MOVE_LEFT:

            query_chr = gap_item;
            target_chr = chainGetChar(target, target_idx);

            target_idx++;

            break;
        case MOVE_UP:

            query_chr = chainGetChar(query, query_idx);
            target_chr = gap_item;

            query_idx++;

            break;
        case MOVE_DIAG:

            query_chr = chainGetChar(query, query_idx);
            target_chr = chainGetChar(target, target_idx);

            query_idx++;
            target_idx++;

            break;
        default:
            // error
            return;
        }

        (*query_str)[i] = query_chr;
        (*target_str)[i] = target_chr;
    }
}
Exemplo n.º 2
0
static void* alignThread(void* param) {

    AlignContext* context = (AlignContext*) param;
    
    DbAlignment** dbAlignment = context->dbAlignment;
    int type = context->type;
    Chain* query = context->query;
    int queryIdx = context->queryIdx;
    Chain* target = context->target;
    int targetIdx = context->targetIdx;
    double value = context->value;
    int score = context->score;
    Scorer* scorer = context->scorer;
    int* cards = context->cards;
    int cardsLen = context->cardsLen;

    // align
    Alignment* alignment;
    alignScoredPair(&alignment, type, query, target, scorer, score, cards, cardsLen, NULL);

    // check scores
    int s1 = alignmentGetScore(alignment);
    int s2 = score;

    ASSERT(s1 == s2, "Scores don't match %d %d, (%s %s)", s1, s2,
        chainGetName(query), chainGetName(target));

    // extract info
    int queryStart = alignmentGetQueryStart(alignment);
    int queryEnd = alignmentGetQueryEnd(alignment);
    int targetStart = alignmentGetTargetStart(alignment); 
    int targetEnd = alignmentGetTargetEnd(alignment);
    int pathLen = alignmentGetPathLen(alignment);

    char* path = (char*) malloc(pathLen);
    alignmentCopyPath(alignment, path);

    alignmentDelete(alignment);
        
    // create db alignment
    *dbAlignment = dbAlignmentCreate(query, queryStart, queryEnd, queryIdx, 
        target, targetStart, targetEnd, targetIdx, value, score, scorer, path, 
        pathLen);

    return NULL;
}