Esempio n. 1
0
void gt_print_edist_alignment(const GtUchar *useq, GtUword ustart, GtUword ulen,
                              const GtUchar *vseq, GtUword vstart, GtUword vlen)
{
  GtAlignment *align;
  align = gt_alignment_new_with_seqs(useq+ustart, ulen, vseq+vstart, vlen);

  alignment_in_square_space(NULL, align, useq, ustart, ulen,
                            vseq, vstart, vlen, 0, 1, 1);
  gt_alignment_show(align, true, stdout, 80);
  gt_alignment_delete(align);
}
Esempio n. 2
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);
  }
gt_alignment_show(align,stdout,80);
  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);
}