Beispiel #1
0
const void *gt_completealignmentfromLocaliTracebackstate(
                                        GtUword *alignedquerylength,
                                        const Limdfsconstinfo *lci)
{
#ifndef NDEBUG
  Scoretype evalscore;
#endif
  const GtUchar *querysubstart;

#ifdef SKDEBUG
  gt_alignment_show_multieop_list(lci->tbs.alignment,stdout);
#endif
  gt_assert(lci->tbs.queryend >= lci->tbs.querypos);
  *alignedquerylength = lci->tbs.queryend - lci->tbs.querypos;
  querysubstart = lci->query + lci->tbs.querypos;
  gt_assert(querysubstart != NULL);
  gt_alignment_set_seqs(lci->tbs.alignment,
                        querysubstart,
                        *alignedquerylength,
                        lci->tbs.spaceGtUchardbsubstring,
                        (GtUword) lci->tbs.dbprefixlen);
#ifndef NDEBUG
  evalscore = gt_alignment_eval_with_score(lci->tbs.alignment,false,
                                           lci->scorevalues.matchscore,
                                           lci->scorevalues.mismatchscore,
                                           lci->scorevalues.gapextend);
  if (evalscore < 0 || (GtUword) evalscore < lci->threshold)
  {
    fprintf(stderr,"unexpected eval score "GT_WD"\n",evalscore);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }
#endif
  return (const void *) lci->tbs.alignment;
}
Beispiel #2
0
static void swproducealignment(GtAlignment *alignment,
                               GtUchar *dbsubstring,
                               Retracebits *edges,
                               Scoretype *scol,
                               const Scorevalues *scorevalues,
                               GT_UNUSED GtUword scorethreshold,
                               const GtUchar *useq,
                               GtUword ulen,
                               const GtEncseq *vencseq,
                               GtUword startpos,
                               GtUword endpos)
{
  GtUword vlen = endpos - startpos;

  swmaximalDPedges(edges,scol,scorevalues,useq,ulen,vencseq,startpos,endpos);
  swtracebackDPedges(alignment,ulen,vencseq,vlen,dbsubstring,startpos,edges);
  gt_alignment_set_seqs(alignment,useq,ulen,dbsubstring,(GtUword) vlen);
#ifndef NDEBUG
  {
    Scoretype evalscore;

    evalscore = gt_alignment_eval_with_score(alignment,false,
                                             scorevalues->matchscore,
                                             scorevalues->mismatchscore,
                                             scorevalues->gapextend);
    if (evalscore < 0 || (GtUword) evalscore < scorethreshold)
    {
      fprintf(stderr,"unexpected eval score "GT_WD"\n",evalscore);
      exit(GT_EXIT_PROGRAMMING_ERROR);
    }
  }
#endif
}
Beispiel #3
0
GtAlignment* gt_alignment_new_with_seqs(const GtUchar *u, GtUword ulen,
                                        const GtUchar *v, GtUword vlen)
{
  GtAlignment *alignment;
  gt_assert(u && v);
  alignment = gt_alignment_new();
  gt_alignment_set_seqs(alignment, u, ulen, v, vlen);
  return alignment;
}
/* create an local alignment in square space, to use it in linear context you
 * have to generate an spacemanager before, in any other case it can be NULL */
GtWord alignment_in_square_space_local_generic(GtLinspaceManagement
                                               *spacemanager,
                                               GtAlignment *align,
                                               const GtUchar *useq,
                                               GtUword ustart,
                                               GtUword ulen,
                                               const GtUchar *vseq,
                                               GtUword vstart,
                                               GtUword vlen,
                                               const GtScoreHandler
                                               *scorehandler)
{
  GtWord score = 0, **Ltabcolumn;
  GtMaxcoordvalue *max;

  gt_assert(align != NULL);
  if (spacemanager == NULL)
  {
    /*use it in normally case*/
    gt_array2dim_malloc(Ltabcolumn, (ulen+1), (vlen+1));
    max = gt_max_new();
  }
  else
  {
    /*use it in lineraspace context*/
    Ltabcolumn = (GtWord **)
                 gt_linspaceManagement_change_to_square(spacemanager,ulen,vlen);
    max = gt_linspaceManagement_get_maxspace(spacemanager);
  }

  score = fillDPtab_in_square_space_local(Ltabcolumn, max, useq, ustart, ulen,
                                          vseq, vstart, vlen, scorehandler);

  /* reconstruct local alignment from 2dimarray Ltabcolumn */
  reconstructalignment_from_Ltab(align, Ltabcolumn, max,
                                 useq, ustart, ulen,
                                 vseq,vstart,vlen,scorehandler);

  if (gt_max_get_length_safe(max))
  {
    ustart = ustart+(gt_max_get_start(max)).a;
    vstart = vstart+(gt_max_get_start(max)).b;
    ulen = gt_max_get_row_length(max);
    vlen = gt_max_get_col_length(max);

    gt_alignment_set_seqs(align, &useq[ustart], ulen,
                                 &vseq[vstart], vlen);
  }

  if (spacemanager == NULL)
  {
    gt_array2dim_delete(Ltabcolumn);
    gt_max_delete(max);
  }
  return score;
}
Beispiel #5
0
/* global alignment with linear gapcosts in linear space */
GtUword gt_computelinearspace_generic(LinspaceManagement *spacemanager,
                                      GtScoreHandler *scorehandler,
                                      GtAlignment *align,
                                      const GtUchar *useq,
                                      GtUword ustart,
                                      GtUword ulen,
                                      const GtUchar *vseq,
                                      GtUword vstart,
                                      GtUword vlen)
{
  GtUword distance;
  gt_assert(spacemanager && scorehandler && align);

  gt_alignment_set_seqs(align, useq+ustart, ulen, vseq+vstart, vlen);
  distance = gt_calc_linearalign(spacemanager, scorehandler, align,
                                 useq, ustart, ulen,
                                 vseq, vstart, vlen);

  return distance;
}
Beispiel #6
0
/* determining start and end of local alignment and call global function */
GtWord gt_computelinearspace_local_generic(LinspaceManagement *spacemanager,
                                           GtScoreHandler *scorehandler,
                                           GtAlignment *align,
                                           const GtUchar *useq,
                                           GtUword ustart,
                                           GtUword ulen,
                                           const GtUchar *vseq,
                                           GtUword vstart,
                                           GtUword vlen)
{
  GtWord *Ltabcolumn, GT_UNUSED  score = GT_WORD_MAX;
  GtUwordPair *Starttabcolumn;
  GtUword ulen_part, ustart_part, vlen_part, vstart_part;
  Gtmaxcoordvalue *max;

  gt_assert(spacemanager && scorehandler && align);
  gt_linspaceManagement_set_ulen(spacemanager,ulen);

  if (ulen == 0UL || vlen == 0UL)
  {
     /* empty alignment */
    return 0;
  }
  else if (vlen == 1UL)
  {
    gt_linspaceManagement_check_local(spacemanager,
                                    (ulen+1)*(vlen+1)-1, ulen,
                                    sizeof (GtWord),
                                    sizeof (GtWord *));
    return alignment_in_square_space_local_generic(spacemanager, align,
                                                   useq, ustart, ulen,
                                                   vseq, vstart, vlen,
                                                   scorehandler);
  }
  else if (gt_linspaceManagement_checksquare_local(spacemanager, ulen, vlen,
                                                   sizeof (*Ltabcolumn),
                                                   sizeof (*Starttabcolumn)))
  {
    /* call 2dim */
    return alignment_in_square_space_local_generic(spacemanager, align,
                                                   useq, ustart, ulen,
                                                   vseq, vstart, vlen,
                                                   scorehandler);
  }

  gt_linspaceManagement_check_local(spacemanager,
                                    ulen, vlen,
                                    sizeof (*Ltabcolumn),
                                    sizeof (*Starttabcolumn));

  max = evaluateallLScolumns(spacemanager, scorehandler,
                             useq, ustart, ulen,
                             vseq, vstart, vlen);

  if (gt_max_get_length_safe(max))
  {
    ustart_part = ustart+(gt_max_get_start(max)).a;
    vstart_part = vstart+(gt_max_get_start(max)).b;
    ulen_part = gt_max_get_row_length(max);
    vlen_part = gt_max_get_col_length(max);
    score = gt_max_get_value(max);

    gt_scorehandler_change_score_to_cost(scorehandler);
    gt_alignment_set_seqs(align, &useq[ustart_part], ulen_part,
                                 &vseq[vstart_part], vlen_part);
    /* call global function */
    gt_calc_linearalign(spacemanager,
                        gt_scorehandler_get_costhandler(scorehandler), align,
                        useq, ustart_part, ulen_part,
                        vseq, vstart_part, vlen_part);

  } else
  {
    /*empty alignment */
    return 0;
  }

  return score;
}