/* interval_expand.c Compile with: gcc -g interval_expand.c -lm -o int_expand Example run: interval beta_DEVIATION.l5 > beta.l5.c int_expand beta.l5.c > beta.l5.graph Gives a point-by-point representation of an interval file with a resolution of 0.001. Used to expand the interval files of anchor values for infocon/phylogen test. */ #include #include #include #include #define Usage "%s \n" #define LARGE_NUMBER 99999999 #define STEP 0.001 void fatalf(char *msg, char *val); FILE *ckopen(char *name, char *mode); void *ckalloc(size_t amount); int main(int argc, char *argv[]) { char buffer[1000]; int k, nfn, nfp, total; double from, i, to; FILE *fp; if (argc!=2) fatalf(Usage,argv[0]); fp = ckopen(argv[1],"r"); while (fgets(buffer,1000,fp)!=NULL) { if (!isdigit(buffer[0]) && (buffer[0]!='-')) continue; sscanf(buffer, "%lf %lf %d %d %d", &from, &to, &nfp, &nfn, &total); i = from; while (i<=to) { printf("%1.3lf %d\n", i, total); i += STEP; } } fclose(fp); return 0; } void fatal(char *msg) { (void)fprintf(stderr, "%s\n", msg); exit(1); } void fatalf(char *msg, char *val) { (void)fprintf(stderr, msg, val); (void)putc('\n', stderr); exit(1); } FILE *ckopen(char *name, char *mode) { FILE *fp; if ((fp = fopen(name, mode)) == NULL) fatalf("Cannot open %s.", name); return fp; } void *ckalloc(size_t amount) { void *p; if ((p = malloc(amount)) == NULL) fatal("Ran out of memory."); return p; }