Пример #1
0
void gt_queryuniquematch(bool selfmatch,
                        const Suffixarray *suffixarray,
                        uint64_t queryunitnum,
                        GtQueryrepresentation *queryrep,
                        GtUword minmatchlength,
                        GtProcessquerymatch processquerymatch,
                        void *processquerymatchinfo,
                        GtQuerymatch *querymatchspaceptr)
{
  GtUword offset, totallength = gt_encseq_total_length(suffixarray->encseq),
          localqueryoffset = 0;
  uint64_t localqueryunitnum = queryunitnum;

  gt_assert(!selfmatch && queryrep->seqlen >= minmatchlength);
  for (offset = 0; offset <= queryrep->seqlen - minmatchlength; offset++)
  {
    GtUword matchlen, dbstart;

    matchlen = gt_suffixarrayfindmums (suffixarray,
                                       0,
                                       0, /* leftbound */
                                       totallength, /* rightbound */
                                       &dbstart,
                                       queryrep->sequence + offset,
                                       queryrep->sequence + queryrep->seqlen);
    if (dbstart != ULONG_MAX &&
        matchlen >= minmatchlength &&
        gt_mum_isleftmaximal(suffixarray->encseq,
                             suffixarray->readmode,
                             dbstart,
                             offset,
                             queryrep->sequence))
    {
      GtUword dbseqnum = gt_encseq_seqnum(suffixarray->encseq,dbstart),
              dbseqstartpos = gt_encseq_seqstartpos(suffixarray->encseq,
                                                    dbseqnum),
              dbseqlen = gt_encseq_seqlength(suffixarray->encseq,dbseqnum);

      gt_querymatch_init(querymatchspaceptr,
                         matchlen,
                         dbstart,
                         dbseqnum,
                         dbstart - dbseqstartpos,
                         dbseqlen,
                         0, /* score */
                         0, /* edist */
                         selfmatch,
                         localqueryunitnum,
                         matchlen,
                         localqueryoffset,
                         queryrep->seqlen);
      processquerymatch(processquerymatchinfo,querymatchspaceptr);
    }
    if (queryrep->sequence[offset] == (GtUchar) SEPARATOR)
    {
      localqueryunitnum++;
      localqueryoffset = 0;
    } else
    {
      localqueryoffset++;
    }
  }
}
Пример #2
0
static int gt_queryuniquematch(bool selfmatch,
                               const Suffixarray *suffixarray,
                               uint64_t queryunitnum,
                               const GtQueryrep *queryrep,
                               unsigned long minmatchlength,
                               GtProcessquerymatch processquerymatch,
                               void *processquerymatchinfo,
                               GtQuerymatch *querymatchspaceptr,
                               GtError *err)
{
  unsigned long offset,
                totallength = gt_encseq_total_length(suffixarray->encseq),
                localqueryoffset = 0;
  uint64_t localqueryunitnum = queryunitnum;
  bool haserr = false;

  gt_assert(!selfmatch && queryrep->length >= minmatchlength);
  for (offset = 0; offset <= queryrep->length - minmatchlength; offset++)
  {
    unsigned long matchlen, dbstart;

    matchlen = gt_suffixarrayfindmums (suffixarray,
                                       0,
                                       0, /* leftbound */
                                       totallength, /* rightbound */
                                       &dbstart,
                                       queryrep->sequence + offset,
                                       queryrep->sequence + queryrep->length);
    if (dbstart != ULONG_MAX &&
        matchlen >= minmatchlength &&
        gt_mum_isleftmaximal(suffixarray->encseq,
                             suffixarray->readmode,
                             dbstart,
                             offset,
                             queryrep->sequence))
    {
      gt_querymatch_fill(querymatchspaceptr,
                         matchlen,
                         dbstart,
                         queryrep->readmode,
                         queryrep->reversecopy,
                         0, /* score */
                         0, /* edist */
                         selfmatch,
                         localqueryunitnum,
                         matchlen,
                         localqueryoffset);
      if (processquerymatch(processquerymatchinfo,
                            suffixarray->encseq,
                            querymatchspaceptr,
                            queryrep->sequence,
                            queryrep->length,
                            err) != 0)
      {
        haserr = true;
      }
    }
    if (!haserr)
    {
      if (queryrep->sequence[offset] == (GtUchar) SEPARATOR)
      {
        localqueryunitnum++;
        localqueryoffset = 0;
      } else
      {
        localqueryoffset++;
      }
    }
  }
  return haserr ? -1 : 0;
}