Beispiel #1
0
int main() {

    int evalcost;

    char *align = "R7I2R2D1R3I1R3";

    char *seq1 = "acgtagatatatagat";
    char *seq2 = "agaaagaggtaagaggga";
       
    alignment alg = alignment_new(seq1, seq2, align);

    alignment_show(alg);

    evalcost = alignment_evalcost(alg);

    printf("\tCosts: %d\n\n", evalcost);

    printf("\tadding one deletion...\n");
    alignment_add_operation(&alg, 1, 'D');
    alignment_show(alg);

    printf("\tadding one insertion...\n");
    alignment_add_operation(&alg, 1, 'I');
    alignment_show(alg);

    printf("\tadding one replacement...\n");
    alignment_add_operation(&alg, 1, 'R');
    alignment_show(alg);

    return(EXIT_SUCCESS);
}
Beispiel #2
0
int main(int argc, char* argv[])
{
  
  // check argument count
  if (argc < 5)
  {
    printf("usage: %s seq1 seq2 scorematrix indelcosts\n!", argv[0]);
    return 1;
  }
  
  // read sequences and m (cost function) from command line
  char* s1 = argv[1];
  int len1 = strlen(s1);
  char* s2 = argv[2];
  int len2 = strlen(s2);
  char* filename = argv[3];
  int indel;
  sscanf(argv[4], "%d", &indel);

  printf("Sequenz 1: %s\n", s1);
  printf("Sequenz 2: %s\n", s2);

  scorematrix* sm = read_scorematrix(filename,indel);
  if (sm == NULL)
    return 1;

  // reserve memory for dynamic programing table
  alignentry*** table = initializeDP (len1+1, len2+1);

  // calculate costs for optimal alignment of s1 and s2
  int imax,jmax;
  int score = align (table, s1, len1, s2, len2, sm, &imax, &jmax);
  // print dynamic programing table
  show_DPtable(s1,len1,s2,len2,table);
  printf("Alignment: %d\n", score);

  alignment* align = alignment_new(s1,len1,s2,len2);
  traceback(table,align,imax,jmax);
  if (alignment_show(align))
  {
    puts("FEHLER: inkonsistentes Alignment!");
  }
  alignment_delete(align);
  deleteDP (table, len1+1, len2+1);

  return 0;
}
Beispiel #3
0
int main(int argc, char * ARGV[])
{
  if (argc < 5 || argc%2 == 0)
  {
    printf("FEHLER: falsche Anzahl Argumente!\n");
    return 1;
  }

  char * s1 = ARGV[1];
  int len1 = strlen(s1);
  char * s2 = ARGV[2];
  int len2 = strlen(s2);

  int ops = 0;

  int i;
  alignment *al = alignment_new (s1, len1, s2, len2);
  for (i = 3; i < argc; i+=2)
  {
    ops |= alignment_add_operations (al, ARGV[i][0], atoi(ARGV[i+1]));
  }

  if (ops)
  {
    printf ("Fehler beim Einfuegen einer Operation (Ueberlauf)!\n");
  }

  int show = alignment_show (al);

  if (show)
  {
    printf ("Fehler beim Ausgeben des Alignments (Alignment inkonsistent)!\n");
  }

  printf ("Länge des Alignments (Länge der Multiedit-Liste): %d (%d)\n", \
      al->length, al->editlength);

  int costs = alignment_evalcost (al, unit_cost);
  printf ("Kosten des Alignments: %d\n", costs);
  alignment_delete (al);
  al = NULL;

  return 0;
}
Beispiel #4
0
int main(int argc, char* argv[])
{
  
  // check argument count
  if (argc < 3)
  {
    printf("usage: %s seq1 seq2\n!", argv[0]);
    return 0;
  }
  
  int costs;
  alignment* a = optimal_alignment(argv[1], argv[2], unity, &costs);

  printf("Alignment: %d\n", costs);

  if (alignment_show(a))
  {
    puts("FEHLER: inkonsistentes Alignment!");
  }
  alignment_delete(a);

  return 0;
}
Beispiel #5
0
int main(int argc, char* argv[])
{
  
  // check argument count
  if (argc < 4)
  {
    printf("FEHLER: zu wenig Argumente angegeben\n!");
    return 1;
  }
  
  // read sequences and m (cost function) from command line
  char* s1 = argv[1];
  int len1 = strlen(s1);
  char* s2 = argv[2];
  int len2 = strlen(s2);
  int m = atoi(argv[3]);

  // determine function-pointer for cost function
  int (*costFunc)(char,char);
  if (m == 0)
    costFunc = unity;
  else if (m == 1)
    costFunc = hamming;
  else
    costFunc = otherCosts;

  printf("Sequenz 1: %s\n", s1);
  printf("Sequenz 2: %s\n", s2);
  // reserve memory for dynamic programing table
  alignentry*** table = initializeDP (len1+1, len2+1);
  // calculate costs for optimal alignment of s1 and s2
  int costs = align (table, s1, len1, s2, len2, costFunc);
  // print dynamic programing table
  printf("------------------------------------------------------\n");
  int i,j;
  int c;
  for (i = -1; i <= len1; i++)
  {
    for (j = -1; j <= len2; j++)
    {
      if (i == -1 && j != -1)
      {
        if (j == 0)
          printf("%3c ", '-');
        else
          printf("%3c ", s2[j-1]);
      }
      else if (j == -1 && i != -1)
      {
        if (i == 0)
          printf("%3c ", '-');
        else
          printf("%3c ", s1[i-1]);
      }
      else if (i == -1 && j == -1)
      {
        printf("%3c ", ' ');
      }
      else
      {
        c = table[i][j]->value;
        if (c == INF)
          printf("%3c ", 'I');
        else
          printf("%3d ", c);
      }
    }
    printf("\n");
  }
  printf("------------------------------------------------------\n");
  
  printf("Alignment: %d\n", costs);

  alignment* align = alignment_new(s1,len1,s2,len2);
  traceback(table,align,len1,len2);
  if (alignment_show(align))
  {
    puts("FEHLER: inkonsistentes Alignment!");
  }
  alignment_delete(align);
  deleteDP (table, len1+1, len2+1);

  return 0;
}