Exemplo n.º 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;
}
Exemplo n.º 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
}
Exemplo n.º 3
0
void gt_checklinearspace_local(GT_UNUSED bool forward,
                               const GtUchar *useq, GtUword ulen,
                               const GtUchar *vseq, GtUword vlen)
{
  GtAlignment *align;
  GtWord score1, score2, score3, score4,
         matchscore = 2, mismatchscore = -2, gapscore = -1;
  GtUchar *low_useq, *low_vseq;
  LinspaceManagement *spacemanager;
  GtScoreHandler *scorehandler;
  GtAlphabet *alphabet;

  if (memchr(useq, LINEAR_EDIST_GAP,ulen) != NULL)
  {
    fprintf(stderr,"%s: sequence u contains gap symbol\n",__func__);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }
  if (memchr(vseq, LINEAR_EDIST_GAP,vlen) != NULL)
  {
    fprintf(stderr,"%s: sequence v contains gap symbol\n",__func__);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }

  scorehandler = gt_scorehandler_new_DNA(matchscore, mismatchscore,
                                         0, gapscore);
  alphabet = gt_scorehandler_get_alphabet(scorehandler);
  low_useq = check_dna_sequence(useq, ulen, alphabet);
  low_vseq = check_dna_sequence(vseq, vlen, alphabet);

  if (low_useq == NULL || low_vseq == NULL)
  {
    low_useq? gt_free(low_useq):0;
    low_vseq? gt_free(low_vseq):0;
    gt_scorehandler_delete(scorehandler);
    return;
  }

  spacemanager = gt_linspaceManagement_new();
  align = gt_alignment_new();
  score1 = gt_computelinearspace_local_generic(spacemanager, scorehandler,
                                               align, useq, 0, ulen,
                                               vseq, 0, vlen);

  score2 = gt_alignment_eval_with_score(align, matchscore,
                                        mismatchscore, gapscore);

  gt_linspaceManagement_delete(spacemanager);
  gt_scorehandler_delete(scorehandler);

  if (score1 != score2)
  {
    fprintf(stderr,"gt_computelinearspace_local = "GT_WD" != "GT_WD
            " = gt_alignment_eval_generic_with_score\n", score1, score2);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }

  gt_alignment_reset(align);
  score3 = alignment_in_square_space_local(NULL, align, useq, 0, ulen,
                                           vseq, 0, vlen, matchscore,
                                           mismatchscore, gapscore);

  if (score1 != score3)
  {
    fprintf(stderr,"gt_computelinearspace_local = "GT_WD" != "GT_WD
            " = alignment_in_square_space_local\n", score1, score3);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }

  score4 = gt_alignment_eval_with_score(align, matchscore,
                                                mismatchscore, gapscore);
  if (score3 != score4)
  {
    fprintf(stderr,"alignment_in_square_space_local = "GT_WD" != "GT_WD
            " = gt_alignment_eval_generic_with_score\n", score3, score4);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }

  gt_alignment_delete(align);
  gt_free(low_useq);
  gt_free(low_vseq);
}
Exemplo n.º 4
0
void gt_checklinearspace(GT_UNUSED bool forward,
                         const GtUchar *useq,
                         GtUword ulen,
                         const GtUchar *vseq,
                         GtUword vlen)
{
  GtAlignment *align;
  GtUword edist1, edist2, edist3, edist4,
          matchcost = 0, mismatchcost = 1, gapcost = 1;
  LinspaceManagement *spacemanager;
  GtScoreHandler *scorehandler;
  GtUchar *low_useq, *low_vseq;

  if (memchr(useq, LINEAR_EDIST_GAP,ulen) != NULL)
  {
    fprintf(stderr,"%s: sequence u contains gap symbol\n",__func__);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }
  if (memchr(vseq, LINEAR_EDIST_GAP,vlen) != NULL)
  {
    fprintf(stderr,"%s: sequence v contains gap symbol\n",__func__);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }

  scorehandler = gt_scorehandler_new_DNA(matchcost,  mismatchcost, 0, gapcost);
  GtAlphabet *alphabet = gt_scorehandler_get_alphabet(scorehandler);
  low_useq = check_dna_sequence(useq, ulen, alphabet);
  low_vseq = check_dna_sequence(vseq, vlen, alphabet);

  if (low_useq == NULL || low_vseq == NULL)
  {
    low_useq? gt_free(low_useq):0;
    low_vseq? gt_free(low_vseq):0;
    gt_scorehandler_delete(scorehandler);
    return;
  }

  spacemanager = gt_linspaceManagement_new();
  align = gt_alignment_new_with_seqs(low_useq, ulen, low_vseq, vlen);

  edist1 = gt_calc_linearalign(spacemanager, scorehandler, align,
                               low_useq, 0, ulen,
                               low_vseq, 0, vlen);

  edist2 = distance_only_global_alignment(useq, 0, ulen, vseq, 0, vlen,
                                          scorehandler);

  if (edist1 != edist2)
  {
    fprintf(stderr,"gt_calc_linearalign = "GT_WU" != "GT_WU
            " = distance_only_global_alignment\n", edist1,edist2);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }

  edist3 = gt_alignment_eval_with_score(align, matchcost,
                                        mismatchcost, gapcost);

  if (edist2 != edist3)
  {
    fprintf(stderr,"distance_only_global_alignment = "GT_WU" != "GT_WU
            " = gt_alignment_eval_with_score\n", edist2,edist3);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }

  edist4 = gt_calc_linearedist(low_useq, ulen, low_vseq, vlen);
  if (edist3 != edist4)
  {
    fprintf(stderr,"gt_alignment_eval_with_score = "GT_WU" != "GT_WU
            " = gt_calc_linearedist\n", edist3, edist4);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }

  gt_free(low_useq);
  gt_free(low_vseq);
  gt_linspaceManagement_delete(spacemanager);
  gt_scorehandler_delete(scorehandler);
  gt_alignment_delete(align);
}
Exemplo n.º 5
0
void gt_linearalign_check_local(GT_UNUSED bool forward,
                                const GtUchar *useq, GtUword ulen,
                                const GtUchar *vseq, GtUword vlen)
{
  GtAlignment *align;
  GtWord score1, score2, score3, score4,
         matchscore = 2, mismatchscore = -2, gapscore = -1;
  GtLinspaceManagement *spacemanager;
  GtScoreHandler *scorehandler;

  if (memchr(useq, LINEAR_EDIST_GAP,ulen) != NULL)
  {
    fprintf(stderr,"%s: sequence u contains gap symbol\n",__func__);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }
  if (memchr(vseq, LINEAR_EDIST_GAP,vlen) != NULL)
  {
    fprintf(stderr,"%s: sequence v contains gap symbol\n",__func__);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }
  scorehandler = gt_scorehandler_new(matchscore, mismatchscore, 0, gapscore);
  gt_scorehandler_plain(scorehandler);
  spacemanager = gt_linspace_management_new();
  align = gt_alignment_new();
  score1 = gt_linearalign_compute_local_generic(spacemanager, scorehandler,
                                                align, useq, 0, ulen,
                                                vseq, 0, vlen);

  score2 = gt_alignment_eval_with_score(align, true, matchscore,
                                        mismatchscore, gapscore);
  gt_linspace_management_delete(spacemanager);
  gt_scorehandler_delete(scorehandler);
  if (score1 != score2)
  {
    fprintf(stderr,"gt_linearalign_compute_local_generic = "GT_WD" != "GT_WD
            " = gt_alignment_eval_generic_with_score\n", score1, score2);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }

  gt_alignment_reset(align);
  score3 = gt_squarealign_calculate_local(NULL, align, useq, 0, ulen,
                                          vseq, 0, vlen, matchscore,
                                          mismatchscore, gapscore);

  if (score1 != score3)
  {
    fprintf(stderr,"gt_linearalign_compute_local_generic = "GT_WD" != "GT_WD
            " = gt_squarealign_calculate_local\n", score1, score3);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }

  score4 = gt_alignment_eval_with_score(align, true, matchscore,
                                        mismatchscore, gapscore);
  if (score3 != score4)
  {
    fprintf(stderr,"gt_squarealign_calculate_local = "GT_WD" != "GT_WD
            " = gt_alignment_eval_generic_with_score\n", score3, score4);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }
  gt_alignment_delete(align);
}
Exemplo n.º 6
0
void gt_linearalign_check(GT_UNUSED bool forward,
                          const GtUchar *useq,
                          GtUword ulen,
                          const GtUchar *vseq,
                          GtUword vlen)
{
  GtAlignment *align;
  GtUword edist1, edist2, edist3, edist4,
          matchcost = 0, mismatchcost = 1, gapcost = 1;
  GtLinspaceManagement *spacemanager;
  GtScoreHandler *scorehandler;
  const bool downcase = true;

  if (memchr(useq, LINEAR_EDIST_GAP,ulen) != NULL)
  {
    fprintf(stderr,"%s: sequence u contains gap symbol\n",__func__);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }
  if (memchr(vseq, LINEAR_EDIST_GAP,vlen) != NULL)
  {
    fprintf(stderr,"%s: sequence v contains gap symbol\n",__func__);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }

  scorehandler = gt_scorehandler_new(matchcost,  mismatchcost, 0, gapcost);
  gt_scorehandler_plain(scorehandler);
  gt_scorehandler_downcase(scorehandler);
  spacemanager = gt_linspace_management_new();
  align = gt_alignment_new_with_seqs(useq, ulen, vseq, vlen);
  edist1 = gt_calc_linearalign(spacemanager, scorehandler, align,
                               useq, 0, ulen,
                               vseq, 0, vlen);
  edist2 = gt_squarealign_global_distance_only(useq, 0, ulen, vseq, 0, vlen,
                                               scorehandler);

  if (edist1 != edist2)
  {
    fprintf(stderr,"gt_calc_linearalign = "GT_WU" != "GT_WU
            " = gt_squarealign_global_distance_only\n", edist1,edist2);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }

  edist3 = gt_alignment_eval_with_score(align, true, matchcost,
                                        mismatchcost, gapcost);

  if (edist2 != edist3)
  {
    fprintf(stderr,"gt_squarealign_global_distance_only = "GT_WU" != "GT_WU
            " = gt_alignment_eval_with_score\n", edist2,edist3);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }

  edist4 = gt_calc_linearedist(downcase,useq, ulen, vseq, vlen);
  if (edist3 != edist4)
  {
    fprintf(stderr,"gt_alignment_eval_with_score = "GT_WU" != "GT_WU
            " = gt_calc_linearedist\n", edist3, edist4);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }
  gt_linspace_management_delete(spacemanager);
  gt_scorehandler_delete(scorehandler);
  gt_alignment_delete(align);
}