/* false positives */ /* crops_fp.c Compile with: gcc -g crops_fp.c -lm -o crops_fp Example run: crops_fp beta_DEVIATION.N.l8 80 93 Example output: from: 0.019 to: 0.040 fp: 35 fn: 15 total: 50 (93) 80 l=8 Given a DEVIATION file, it outputs the interval of anchor values for which the best "fp" count is obtained, providing that only the runs with at least the specified percentage of true positives are included. In the example above, the best a-interval for phylogen runs on the HBB promoter region with l=8 (ct) which exceed 80% true positives (ie, < 20% fn) is [0.019,0.040], when no flexible anchor is used (N). The fp, fn and total counts are: 35, 15 and 50 respectively. 93 is the total length of the known functional regions (maxfn). The chars-to_len value is 15=strlen("phylogen.beta.l") (see the denomination for a run in the DEVIATION file). Produces an interval file as an intermediate (tmp) file. NOTE: For use in 'cut' experiments on individual regions. Fp-based evaluation criteria were not used in the "Comparison of five methods..." paper. Refer to crops_total.c, instead. */ #include #include #include #include #include #include #define Usage "%s " void fatal(char *message); void fatalf(char *msg, char *val); FILE *ckopen(char *name, char *mode); int get_len(char *s); int main(int argc, char *argv[]) { char buffer[200], cmd[100]; int i, k, length, pct, best_k, best, thresh, chars_to_len; double from[1000], to[1000]; int fn[1000], fp[1000], first; char *s; FILE *file; if (argc!=5) fatalf(Usage, argv[0]); pct = atoi(argv[2]); length = atoi(argv[3]); chars_to_len = atoi(argv[4]); thresh = ((100-pct)*length)/100; best = 100000; i = best_k = -1; first = 0; sprintf(cmd,"interval %s %d > tmp",argv[1], chars_to_len); system(cmd); file = ckopen("tmp","r"); k = 0; while (fgets(buffer,200,file)!=NULL) { if (buffer[0]=='#') continue; sscanf(buffer,"%lf %lf %d %d", &from[k], &to[k], &fp[k], &fn[k]); if (fn[k]>thresh) continue; else if (!first) { first = 1; i = k; } if (fp[k]+fn[k]=0) printf("from: %1.3lf to: %1.3lf fp: %d fn: %d total: %d (%d) %d l=%d\n", from[i], to[i], fp[i], fn[i], fp[i]+fn[i], length, pct, get_len(argv[1])); return 0; } int get_len(char *s) { int len; char *p = s; while (*p && !isspace(*p) && (*p!='l')) p++; sscanf(p+1,"%d",&len); return len; } 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; }