예제 #1
0
void gt_alignment_set_multieop_list(GtAlignment *alignment,
                                    GtMultieoplist *eoplist)
{
  gt_assert(alignment != NULL && eoplist != NULL);
  gt_multieoplist_delete(alignment->eops);
  alignment->eops = gt_multieoplist_ref(eoplist);
  alignment->alilen = gt_multieoplist_get_length(eoplist);
}
예제 #2
0
GtWord gt_alignment_eval_with_score(const GtAlignment *alignment,
                                  GtWord matchscore,
                                  GtWord mismatchscore,
                                  GtWord gapscore)
{
  GtUword i, j, idx_u = 0, idx_v = 0, meoplen;
  GtWord sumscore = 0;
  GtMultieop *meop;

  gt_assert(alignment != NULL);
  gt_assert(gt_alignment_is_valid(alignment));

  meoplen = gt_multieoplist_get_length(alignment->eops);

  for (i = meoplen; i > 0; i--) {
    meop = gt_multieoplist_get_entry(alignment->eops, i - 1);
    switch (meop->type) {
      case Mismatch:
      case Match:
      case Replacement:
        for (j = 0; j < meop->steps; j++) {
          if (alignment->u[idx_u] == alignment->v[idx_v] &&
              ISNOTSPECIAL(alignment->u[idx_u])) {
            sumscore += matchscore;
          }
          else {
            sumscore += mismatchscore;
          }
          idx_u++;
          idx_v++;
        }
        break;
      case Deletion:
        sumscore += gapscore * meop->steps;
        idx_u += meop->steps;
        break;
      case Insertion:
        sumscore += gapscore * meop->steps;
        idx_v += meop->steps;
        break;
    }
  }
  return sumscore;
}
예제 #3
0
GtUword gt_alignment_eval(const GtAlignment *alignment)
{
  GtUword i, j, idx_u = 0, idx_v = 0, sumcost = 0, meoplen;
  GtMultieop *meop;

  gt_assert(alignment != NULL);
  gt_assert(gt_alignment_is_valid(alignment));

  meoplen = gt_multieoplist_get_length(alignment->eops);
  for (i = meoplen; i > 0; i--) {
    meop = gt_multieoplist_get_entry(alignment->eops, i - 1);
    switch (meop->type) {
      case Mismatch:
        for (j = 0; j < meop->steps; j++) {
          sumcost++;
          idx_u++;
          idx_v++;
        }
        break;
      case Match:
      case Replacement:
        for (j = 0; j < meop->steps; j++) {
          if (tolower((int) alignment->u[idx_u]) !=
              tolower((int) alignment->v[idx_v])) {
            sumcost++;
          }
          idx_u++;
          idx_v++;
        }
        break;
      case Deletion:
        sumcost += meop->steps;
        idx_u += meop->steps;
        break;
      case Insertion:
        sumcost += meop->steps;
        idx_v += meop->steps;
        break;
    }
  }
  return sumcost;
}
예제 #4
0
void gt_alignment_show_with_mapped_chars(const GtAlignment *alignment,
                                         const GtUchar *characters,
                                         GtUchar wildcardshow,
                                         FILE *fp)
{
  GtUword i, j, idx_u, idx_v, meoplen;
  GtMultieop *meop;

  gt_assert(alignment);
  gt_assert(gt_alignment_is_valid(alignment));

  meoplen = gt_multieoplist_get_length(alignment->eops);
  /* output first line */
  idx_u = 0;
  for (i = meoplen; i > 0; i--)
  {
    meop = gt_multieoplist_get_entry(alignment->eops, i - 1);
    switch (meop->type)
    {
      case Mismatch:
      case Match:
      case Replacement:
      case Deletion:
        for (j = 0; j < meop->steps; j++)
        {
          gt_xfputc(ISSPECIAL(alignment->u[idx_u]) ?
                    (int) wildcardshow :
                    (int) characters[alignment->u[idx_u]], fp);
          idx_u++;
        }
        break;
      case Insertion:
        for (j = 0; j < meop->steps; j++)
        {
          gt_xfputc(GAPSYMBOL, fp);
        }
        break;
    }
  }
  gt_xfputc('\n', fp);
  /* output middle line */
  idx_u = idx_v = 0;
  for (i = meoplen; i > 0; i--)
  {
    meop = gt_multieoplist_get_entry(alignment->eops, i - 1);
    switch (meop->type)
    {
      case Mismatch:
      case Match:
      case Replacement:
        for (j = 0; j < meop->steps; j++)
        {
          if (alignment->u[idx_u] == alignment->v[idx_v] &&
              ISNOTSPECIAL(alignment->u[idx_u]))
          {
            gt_xfputc(MATCHSYMBOL, fp);
          } else
          {
            gt_xfputc(MISMATCHSYMBOL, fp);
          }
          idx_u++;
          idx_v++;
        }
        break;
      case Deletion:
        for (j = 0; j < meop->steps; j++)
        {
          gt_xfputc(MISMATCHSYMBOL, fp);
          idx_u++;
        }
        break;
      case Insertion:
        for (j = 0; j < meop->steps; j++)
        {
          gt_xfputc(MISMATCHSYMBOL, fp);
          idx_v++;
        }
        break;
    }
  }
  gt_xfputc('\n', fp);
  /* ouput last line */
  idx_v = 0;
  for (i = meoplen; i > 0; i--)
  {
    meop = gt_multieoplist_get_entry(alignment->eops, i - 1);
    switch (meop->type)
    {
      case Mismatch:
      case Match:
      case Replacement:
      case Insertion:
        for (j = 0; j < meop->steps; j++)
        {
          gt_xfputc(ISSPECIAL(alignment->v[idx_v]) ?
                    (int) wildcardshow :
                    (int) characters[alignment->v[idx_v]], fp);
          idx_v++;
        }
        break;
      case Deletion:
        for (j = 0; j < meop->steps; j++)
        {
          gt_xfputc(GAPSYMBOL, fp);
        }
        break;
    }
  }
  gt_xfputc('\n', fp);
}
예제 #5
0
/* XXX: add width parameter and format the GtAlignment accordingly */
void gt_alignment_show(const GtAlignment *alignment, FILE *fp)
{
  GtUword i, j, idx_u, idx_v, meoplen;
  GtMultieop *meop;

  gt_assert(alignment);
  gt_assert(gt_alignment_is_valid(alignment));

  meoplen = gt_multieoplist_get_length(alignment->eops);
  /* output first line */
  idx_u = 0;
  for (i = meoplen; i > 0; i--) {
    meop = gt_multieoplist_get_entry(alignment->eops, i - 1);
    switch (meop->type) {
      case Mismatch:
      case Match:
      case Replacement:
      case Deletion:
        for (j = 0; j < meop->steps; j++)
          gt_xfputc((int) alignment->u[idx_u++], fp);
        break;
      case Insertion:
        for (j = 0; j < meop->steps; j++)
          gt_xfputc(GAPSYMBOL, fp);
        break;
    }
  }
  gt_xfputc('\n', fp);
  /* output middle line */
  idx_u = idx_v = 0;
  for (i = meoplen; i > 0; i--) {
    meop = gt_multieoplist_get_entry(alignment->eops, i - 1);
    switch (meop->type) {
      case Mismatch:
      case Match:
      case Replacement:
        for (j = 0; j < meop->steps; j++) {
          if (tolower((int) alignment->u[idx_u++]) ==
              tolower((int) alignment->v[idx_v++]))
            gt_xfputc(MATCHSYMBOL, fp);
          else
            gt_xfputc(MISMATCHSYMBOL, fp);
        }
        break;
      case Deletion:
        for (j = 0; j < meop->steps; j++) {
          gt_xfputc(MISMATCHSYMBOL, fp);
          idx_u++;
        }
        break;
      case Insertion:
        for (j = 0; j < meop->steps; j++) {
          gt_xfputc(MISMATCHSYMBOL, fp);
          idx_v++;
        }
        break;
    }
  }
  gt_xfputc('\n', fp);
  /* ouput last line */
  idx_v = 0;
  for (i = meoplen; i > 0; i--) {
    meop = gt_multieoplist_get_entry(alignment->eops, i - 1);
    switch (meop->type) {
      case Mismatch:
      case Match:
      case Replacement:
      case Insertion:
        for (j = 0; j < meop->steps; j++)
          gt_xfputc((int) alignment->v[idx_v++], fp);
        break;
      case Deletion:
        for (j = 0; j < meop->steps; j++)
          gt_xfputc(GAPSYMBOL, fp);
        break;
    }
  }
  gt_xfputc('\n', fp);
}
예제 #6
0
GtUword gt_alignment_get_length(const GtAlignment *alignment)
{
  gt_assert(alignment != NULL);
  return gt_multieoplist_get_length(alignment->eops);
}