Esempio n. 1
0
/* 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;
}
Esempio n. 2
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;
}