예제 #1
0
static Seqpos *leftcontextofspecialchardist(unsigned int numofchars,
                                            const Encodedsequence *encseq,
                                            Readmode readmode)
{
  GtUchar cc;
  unsigned int idx;
  Seqpos *specialchardist, totallength = getencseqtotallength(encseq);

  specialchardist = gt_malloc(sizeof(*specialchardist) * numofchars);
  for (idx = 0; idx<numofchars; idx++)
  {
    specialchardist[idx] = 0;
  }
  if (hasspecialranges(encseq))
  {
    Specialrangeiterator *sri;
    Sequencerange range;

    sri = newspecialrangeiterator(encseq,true);
    if (ISDIRREVERSE(readmode))
    {
      Readmode thismode = (readmode == Reversemode) ? Forwardmode
                                                    : Complementmode;
      while (nextspecialrangeiterator(&range,sri))
      {
        if (range.rightpos < totallength)
        {
          cc = getencodedchar(encseq,range.rightpos,thismode);
          if (ISNOTSPECIAL(cc))
          {
            specialchardist[cc]++;
          }
        }
      }
    } else
    {
      while (nextspecialrangeiterator(&range,sri))
      {
        gt_assert(range.leftpos < totallength);
        if (range.leftpos > 0)
        {
          cc = getencodedchar(encseq,range.leftpos-1,readmode);
          if (ISNOTSPECIAL(cc))
          {
            specialchardist[cc]++;
          }
        }
      }
    }
    freespecialrangeiterator(&sri);
  }
  if (getencseqlengthofspecialsuffix(encseq) == 0)
  {
    cc = getencodedchar(encseq,totallength-1,readmode);
    gt_assert(ISNOTSPECIAL(cc));
    specialchardist[cc]++;
  }
  return specialchardist;
}
예제 #2
0
int checkspecialrangesfast(const Encodedsequence *encseq)
{
  GtArray *rangesforward, *rangesbackward;
  bool haserr = false;
  Specialrangeiterator *sri;
  Sequencerange range;

  if (!hasspecialranges(encseq))
  {
    return 0;
  }
  rangesforward = gt_array_new(sizeof (Sequencerange));
  rangesbackward = gt_array_new(sizeof (Sequencerange));

  sri = newspecialrangeiterator(encseq,true);
  while (nextspecialrangeiterator(&range,sri))
  {
    gt_array_add(rangesforward,range);
  }
  freespecialrangeiterator(&sri);
  sri = newspecialrangeiterator(encseq,false);
  while (nextspecialrangeiterator(&range,sri))
  {
    gt_array_add(rangesbackward,range);
  }
  freespecialrangeiterator(&sri);
  gt_array_reverse(rangesbackward);
  if (!haserr)
  {
    if (array_compare(rangesforward,rangesbackward,
                      compareSequencerange) != 0)
    {
      exit(GT_EXIT_PROGRAMMING_ERROR);
    }
  }
  gt_array_delete(rangesforward);
  gt_array_delete(rangesbackward);
  return haserr ? - 1 : 0;
}