/* sample program for invoking robust.c */ #include #define DIGIT 10.0 /* all parameters are accurate to the tenth */ main(argc, argv) int argc; char *argv[]; { double atof(); char *ckalloc(); char *seq1, *seq2; int M, N; /* lengths of sequences */ long low, up, ms, G, H, W[128][128]; long *S; /* conversion operations */ int i, j; long c; if (argc != 6) fatalf("%s seq1 seq2 ms(<0) g(>=0) h(>0)",argv[0]); M = get_seq(argv[1], &seq1); N = get_seq(argv[2], &seq2); ms = DIGIT * atof(argv[3]); if (ms > 0) fatal("The mismatch weight should be nonpositive."); G = DIGIT * atof(argv[4]); if (G < 0) fatal("The gap-open penalty should be nonnegative."); H = DIGIT * atof(argv[5]); if (H < 0) fatal("The gap-extend penalty should be positive."); /* set up match and mismatch weights */ for (i = 0; i < 128; i++) for (j = 0; j < 128; j++) if (i == j) W[i][j] = DIGIT; else W[i][j] = ms; printf("%s: length = %d\n",argv[1],M); printf("%s: length = %d\n",argv[2],N); printf("mismatch = %.1f, gap_open = %.1f, gap_ext = %.1f\n\n",ms/DIGIT,G/DIGIT,H/DIGIT); S = (long *)ckalloc((M+N)*sizeof(long)); c = ALIGN(seq1-1,seq2-1,M,N,W,G,H,S); printf("\nOptimal cost = %.1f\n", ((float)c)/DIGIT); DISPLAY(seq1-1,seq2-1,M,N,S,1,1); ROBUST(seq1-1,seq2-1,M,N,S,c); exit(0); } /* get_seq - read a sequence */ int get_seq(file_name, seqptr) char *file_name, **seqptr; { FILE *qp, *ckopen(); char *p, *fgets(), *ckalloc(); int c, n; qp = ckopen(file_name, "r"); for (n=0; (c=getc(qp)) != EOF;) if (c != '\n') ++n; *seqptr = ckalloc(n+1); rewind(qp); p = *seqptr; while((c=getc(qp)) != EOF) if (c != '\n') *p++ = c; *p = '\0'; return p - *seqptr; }