Ejemplo n.º 1
0
void gt_eoplist_match_add(GtEoplist *eoplist,GtUword length)
{
  gt_assert(eoplist != NULL && length > 0);
  eoplist->countmatches += length;
  while (true)
  {
    if (length <= FT_EOPCODE_MAXMATCHES)
    {
      gt_assert(length > 0);
      GT_EOPLIST_PUSH(eoplist,(uint8_t) (length - 1)); /* R length */
      break;
    }
    GT_EOPLIST_PUSH(eoplist,FT_EOPCODE_MAXMATCHES - 1); /* R max */
    length -= FT_EOPCODE_MAXMATCHES;
  }
}
Ejemplo n.º 2
0
void front_trace_multireplacement(GtEoplist *eoplist,GtUword repnum)
{
  gt_assert(eoplist != NULL && repnum > 0);
  eoplist->countmatches += repnum;
  while (true)
  {
    if (repnum <= FT_EOPCODE_MAXREPLACEMENT)
    {
      gt_assert(repnum > 0);
      GT_EOPLIST_PUSH(eoplist,(uint8_t) (repnum - 1)); /* R repnum */
      break;
    }
    GT_EOPLIST_PUSH(eoplist,FT_EOPCODE_MAXREPLACEMENT - 1); /* R max */
    repnum -= FT_EOPCODE_MAXREPLACEMENT;
  }
}
Ejemplo n.º 3
0
void gt_eoplist_insertion_add(GtEoplist *eoplist)
{
  gt_assert(eoplist != NULL);
  GT_EOPLIST_PUSH(eoplist,FT_EOPCODE_INSERTION);
  eoplist->countinsertions++;
}
Ejemplo n.º 4
0
void gt_eoplist_deletion_add(GtEoplist *eoplist)
{
  GT_EOPLIST_PUSH(eoplist,FT_EOPCODE_DELETION);
  eoplist->countdeletions++;
}
Ejemplo n.º 5
0
void gt_eoplist_mismatch_add(GtEoplist *eoplist)
{
  GT_EOPLIST_PUSH(eoplist,FT_EOPCODE_MISMATCH); /* R 1 */
  eoplist->countmismatches++;
}
Ejemplo n.º 6
0
static void gt_front_trace_backtracepath2eoplist(GtEoplist *eoplist,
                                                 unsigned int lastlcs,
                                                 const GtBacktraceFrontpath
                                                   *backtracepath,
                                                GtUword elementsinbacktracepath,
                                                GT_UNUSED GtUword ulen,
                                                GT_UNUSED GtUword vlen)
{
  GtUword idx, deletions = 0, insertions = 0, mismatches = 0, matches = 0;

  if (lastlcs > 0)
  {
    front_trace_multireplacement(eoplist,lastlcs);
    matches += lastlcs;
  }
  gt_assert(eoplist != NULL);
  for (idx = 0; idx < elementsinbacktracepath; idx++)
  {
    if (backtracepath[idx].eopcode == FT_EOPCODE_DELETION)
    {
      eoplist->countdeletions++;
      deletions++;
    } else
    {
      if (backtracepath[idx].eopcode == FT_EOPCODE_INSERTION)
      {
        eoplist->countinsertions++;
        insertions++;
      } else
      {
        eoplist->countmismatches++;
        mismatches++;
      }
    }
    GT_EOPLIST_PUSH(eoplist,backtracepath[idx].eopcode);
    if (backtracepath[idx].lcs > 0)
    {
      front_trace_multireplacement(eoplist,backtracepath[idx].lcs);
      matches += backtracepath[idx].lcs;
    }
  }
  /*
  if (matches + mismatches + deletions != ulen)
  {
    fprintf(stderr,
            "matches=" GT_WU ",mismatches=" GT_WU ",deletions=" GT_WU ","
            "sum=" GT_WU " != " GT_WU " = ulen\n",
             matches,mismatches,deletions,
             matches+mismatches+deletions,
             ulen);
  }
  if (matches + mismatches + insertions != vlen)
  {
    fprintf(stderr,
            "matches=" GT_WU ",mismatches=" GT_WU ",insertions=" GT_WU ","
            "sum=" GT_WU " " != " GT_WU " = vlen\n",
             matches,mismatches,insertions,
             matches+mismatches+insertions,
             vlen);
  }
  */
}
Ejemplo n.º 7
0
static void front_trace2eoplist_directed(GtEoplist *eoplist,
                                         GtFronttrace *front_trace,
                                         const Polished_point *pp,
                                         const GtUchar *useq,
                                         GT_UNUSED GtUword ulen,
                                         const GtUchar *vseq,
                                         GT_UNUSED GtUword vlen)
{
  GtUword distance, localoffset, globaloffset, remainingvalidfronts,
          totalrunlength = 0, trimleft;
  GtWord diagonal;
  unsigned int row, lcs;
  uint8_t trace, preferred_eop = FT_EOP_REPLACEMENT;

  gt_assert(front_trace != NULL && front_trace->gen_nextfree > 0 && pp != NULL);
  localoffset = polished_point2offset(front_trace,pp);
  remainingvalidfronts = valid_total_fronts(front_trace->gen_table,
                                            pp->distance,
                                            front_trace->gen_nextfree);
  gt_assert(remainingvalidfronts <= front_trace->backref_nextfree);
  globaloffset = front_trace->backref_nextfree - remainingvalidfronts;
  distance = pp->distance;
  diagonal = (GtWord) pp->alignedlen - (GtWord) GT_MULT2(pp->row);
  trace = front_trace->backref_table[globaloffset + localoffset].bits;
  lcs = front_trace->backref_table[globaloffset + localoffset].lcs;
  row = pp->row;
  trimleft = pp->trimleft;
  gt_assert(distance < front_trace->gen_nextfree);
  while (distance > 0)
  {
    GtUword nextrowadd;
    GtWord base_diagonal;

    if (eoplist != NULL)
    {
      if (lcs > 0)
      {
        front_trace_multireplacement(eoplist,lcs);
      }
    } else
    {
      gt_check_diagonal_run(useq, vseq, diagonal, row - lcs, row);
    }
    if (trace & preferred_eop)
    {
      totalrunlength++;
      if (preferred_eop == FT_EOP_REPLACEMENT)
      {
        nextrowadd = 1;
      } else
      {
        if (preferred_eop == FT_EOP_INSERTION)
        {
          gt_assert(-(GtWord) ulen < diagonal);
          diagonal--;
          nextrowadd = 0;
        } else
        {
          gt_assert(preferred_eop == FT_EOP_DELETION);
          gt_assert(diagonal < (GtWord) vlen);
          diagonal++;
          nextrowadd = 1;
        }
      }
    } else
    {
      if (trace & FT_EOP_REPLACEMENT)
      {
        preferred_eop = FT_EOP_REPLACEMENT;
        nextrowadd = 1;
      } else
      {
        if (trace & FT_EOP_INSERTION)
        {
          gt_assert(-(GtWord) ulen < diagonal);
          diagonal--;
          preferred_eop = FT_EOP_INSERTION;
          nextrowadd = 0;
        } else
        {
          gt_assert(trace & FT_EOP_DELETION);
          gt_assert(diagonal < (GtWord) vlen);
          diagonal++;
          preferred_eop = FT_EOP_DELETION;
          nextrowadd = 1;
        }
      }
    }
    if (eoplist != NULL)
    {
      if (preferred_eop == FT_EOP_DELETION)
      {
        GT_EOPLIST_PUSH(eoplist,FT_EOPCODE_DELETION);
        eoplist->countdeletions++;
      } else
      {
        if (preferred_eop == FT_EOP_INSERTION)
        {
          GT_EOPLIST_PUSH(eoplist,FT_EOPCODE_INSERTION);
          eoplist->countinsertions++;
        } else
        {
          GT_EOPLIST_PUSH(eoplist,0); /* R 1 */
          eoplist->countmismatches++;
        }
      }
    }
    gt_assert(trimleft >=
              (GtUword) front_trace->gen_table[distance].trimleft_diff);
    trimleft -= (GtUword) front_trace->gen_table[distance].trimleft_diff;
    distance--;
    base_diagonal = (GtWord) trimleft - (GtWord) distance;
    gt_assert(base_diagonal <= diagonal);
    gt_assert(diagonal <
              base_diagonal + (GtWord) front_trace->gen_table[distance].valid);
    localoffset = (GtUword) (diagonal - base_diagonal);
    gt_assert((GtUword) front_trace->gen_table[distance].valid
              <= globaloffset);
    globaloffset -= (GtUword) front_trace->gen_table[distance].valid;
    gt_assert(row >= lcs + nextrowadd);
    row -= lcs + nextrowadd;
    trace = front_trace->backref_table[globaloffset + localoffset].bits;
    lcs = front_trace->backref_table[globaloffset + localoffset].lcs;
  }
  /*printf("avg runlength=%.2f\n",(double) pp->distance/totalrunlength);*/
  gt_assert(globaloffset + localoffset == 0 && trace == 0);
  if (eoplist != NULL && lcs > 0)
  {
    front_trace_multireplacement(eoplist,lcs);
  }
}