示例#1
0
static GtUchar gt_mmsearch_accessquery(const GtQueryrepresentation *queryrep,
                                       GtUword pos)
{
  GtUword abspos, cc;

  gt_assert(queryrep != NULL);
  gt_assert(pos < queryrep->seqlen);
  abspos = queryrep->startpos + (queryrep->readmode == GT_READMODE_FORWARD
                                  ? pos
                                  : GT_REVERSEPOS(queryrep->seqlen,pos));
  if (queryrep->sequence != NULL)
  {
    cc = queryrep->sequence[abspos];
  } else
  {
    gt_assert(queryrep->encseq != NULL);
    cc = gt_encseq_get_encoded_char(queryrep->encseq,abspos,
                                    GT_READMODE_FORWARD);
  }
  if (GT_ISDIRCOMPLEMENT(queryrep->readmode))
  {
    if (ISSPECIAL(cc))
    {
      return cc;
    }
    return GT_COMPLEMENTBASE(cc);
  } else
  {
    return cc;
  }
}
示例#2
0
static GtUchar gt_mmsearch_accessquery(const GtQueryrepresentation *queryrep,
                                       GtUword pos)
{
    GtUword abspos;

    gt_assert(queryrep != NULL);
    gt_assert(pos < queryrep->seqlen);
    abspos = queryrep->startpos + (queryrep->readmode == GT_READMODE_FORWARD
                                   ? pos
                                   : GT_REVERSEPOS(queryrep->seqlen,pos));
    if (queryrep->sequence != NULL)
    {
        gt_assert(!GT_ISDIRCOMPLEMENT(queryrep->readmode)); /* not implemented */
        return queryrep->sequence[abspos];
    } else
    {
        gt_assert(queryrep->encseq != NULL);
        return gt_encseq_get_encoded_char(queryrep->encseq,abspos,
                                          GT_READMODE_FORWARD);
    }
}
示例#3
0
void gt_edistmyersbitvectorAPM(Myersonlineresources *mor,
                               const GtUchar *pattern,
                               GtUword patternlength,
                               GtUword maxdistance)
{
    GtUword Pv = ~0UL,
            Mv = 0UL,
            Eq,
            Xv,
            Xh,
            Ph,
            Mh,
            score;
    const GtUword Ebit = 1UL << (patternlength-1);
    GtUchar cc;
    GtUword pos;
    const GtReadmode readmode = GT_READMODE_REVERSE;
    GtIdxMatch match;

    gt_initeqsvectorrev(mor->eqsvectorrev,
                        (GtUword) mor->alphasize,
                        pattern,patternlength);
    score = patternlength;
    gt_encseq_reader_reinit_with_readmode(mor->esr, mor->encseq, readmode, 0);
    match.dbabsolute = NULL;
    match.dbsubstring = NULL;
    match.querystartpos = 0;
    match.querylen = patternlength;
    match.alignment = NULL;
    for (pos = 0; pos < mor->totallength; pos++)
    {
        cc = gt_encseq_reader_next_encoded_char(mor->esr);
        if (cc == (GtUchar) SEPARATOR)
        {
            Pv = ~0UL;
            Mv = 0UL;
            score = patternlength;
        } else
        {
            if (cc == (GtUchar) WILDCARD)
            {
                Eq = 0;
            } else
            {
                Eq = mor->eqsvectorrev[(GtUword) cc];   /*  6 */
            }
            Xv = Eq | Mv;                                   /*  7 */
            Xh = (((Eq & Pv) + Pv) ^ Pv) | Eq;              /*  8 */

            Ph = Mv | ~ (Xh | Pv);                          /*  9 */
            Mh = Pv & Xh;                                   /* 10 */

            if (Ph & Ebit)
            {
                score++;
            } else
            {
                if (Mh & Ebit)
                {
                    gt_assert(score > 0);
                    score--;
                }
            }

            Ph <<= 1;                                       /* 15 */
            Pv = (Mh << 1) | ~ (Xv | Ph);                   /* 17 */
            Mv = Ph & Xv;                                   /* 18 */
            if (score <= maxdistance)
            {
                GtUword dbstartpos = GT_REVERSEPOS(mor->totallength,pos);
                Definedunsignedlong matchlength;

                if (maxdistance > 0)
                {
                    matchlength = gt_forwardprefixmatch(mor->encseq,
                                                        mor->alphasize,
                                                        dbstartpos,
                                                        mor->nowildcards,
                                                        mor->eqsvector,
                                                        pattern,
                                                        patternlength,
                                                        maxdistance);
                } else
                {
                    matchlength.defined = true;
                    matchlength.valueunsignedlong = patternlength;
                }
                gt_assert(matchlength.defined || mor->nowildcards);
                if (matchlength.defined)
                {
                    match.dbstartpos = dbstartpos;
                    match.dblen = (GtUword) matchlength.valueunsignedlong;
                    match.distance = score;
                    mor->processmatch(mor->processmatchinfo,&match);
                }
            }
        }
    }
}
static void seededmatch2alignment(const GtQuerymatch *querymatch,
                                  GtUword querystartabsolute,
                                  const GtEncseq *encseq,
                                  GtQuerymatchoutoptions *querymatchoutoptions)
{
  GtUword ulen, vlen, rightdistance = 0, leftdistance = 0,
          offset1 = querymatchoutoptions->seedpos1 +
                    querymatchoutoptions->seedlen,
          offset2 = querymatchoutoptions->seedpos2 +
                    querymatchoutoptions->seedlen;
  GtAlignment *alignment = gt_alignment_new();

  gt_assert(querymatch->dbstart + querymatch->dblen >= offset1);
  ulen = querymatch->dbstart + querymatch->dblen - offset1;
  gt_assert(querystartabsolute + querymatch->querylen >= offset2);
  vlen = querystartabsolute + querymatch->querylen - offset2;
  if (ulen > 0 && vlen > 0)
  {
    Polished_point best_polished_point = {0,0,0};
    rightdistance = align_front_prune_edist(true,
                                            &best_polished_point,
                                            querymatchoutoptions->front_trace,
                                            encseq,
                                            querymatchoutoptions->ggemi,
                                            offset1,
                                            ulen,
                                            offset2,
                                            vlen);
    front_trace2alignments(alignment,
                           querymatchoutoptions->front_trace,
                           &best_polished_point,
                           ulen,vlen);
    front_trace_reset(querymatchoutoptions->front_trace,ulen+vlen);
  }
  gt_assert(rightdistance <= querymatch->edist);
  if (querymatchoutoptions->totallength == GT_UWORD_MAX)
  {
    querymatchoutoptions->totallength = gt_encseq_total_length(encseq);
  }
  if (querymatchoutoptions->seedpos1 > querymatch->dbstart &&
      querymatchoutoptions->seedpos2 > querystartabsolute)
  {
    Polished_point best_polished_point = {0,0,0};
    ulen = querymatchoutoptions->seedpos1 - querymatch->dbstart;
    vlen = querymatchoutoptions->seedpos2 - querystartabsolute;
    leftdistance = align_front_prune_edist(false,
                               &best_polished_point,
                               querymatchoutoptions->front_trace,
                               encseq,
                               querymatchoutoptions->ggemi,
                               GT_REVERSEPOS(querymatchoutoptions->totallength,
                                             querymatchoutoptions->seedpos1-1),
                               ulen,
                               GT_REVERSEPOS(querymatchoutoptions->totallength,
                                             querymatchoutoptions->seedpos2-1),
                               vlen);
    front_trace_reset(querymatchoutoptions->front_trace,ulen+vlen);
  }
  if (leftdistance + rightdistance > querymatch->edist)
  {
    fprintf(stderr,"leftdistance + rightdistance = " GT_WU " + " GT_WU " > "
                   GT_WU " = querymatch->edist\n",
                   leftdistance,rightdistance,querymatch->edist);
  }
  gt_assert(leftdistance + rightdistance <= querymatch->edist);
  gt_alignment_delete(alignment);
}