/* false positives */ /* crops_fp.c Compile with: gcc -g crops_fp.c -lm -o crops_fp Example run: crops_fp beta_DEVIATION.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 infocon runs on the HBB promoter region with l=8 (ct) which exceed 80% true positives (ie, < 20% fn) is [0.019,0.040]. The fp, fn and total counts are: 35, 15 and 50 respectively. 93 is the total length of the known functional regions (maxfn). Produces an interval file as an intermediate (tmp) file. NOTE: Recommended 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 *chars_to_len); int main(int argc, char *argv[]) { char buffer[200], cmd[100]; int i, k, length, pct, best_k, best, thresh, len, chars_to_len; double from[1000], to[1000]; int fn[1000], fp[1000]; char *s; FILE *file; if (argc!=4) fatalf(Usage, argv[0]); pct = atoi(argv[2]); length = atoi(argv[3]); thresh = ((100-pct)*length)/100; best = 100000; best_k = -1; len = get_len(argv[1],&chars_to_len); 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; if (fp[k]+fn[k]= 0) printf("Best_total %d: from: %1.3lf to: %1.3lf fp: %d fn: %d total: %d (%d)\n", pct, from[best_k], to[best_k], fp[best_k], fn[best_k], fp[best_k]+fn[best_k], length); */ i = k-1; while ((i>=1) && (fp[i]==fp[i-1])) i--; if (i>=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, len); return 0; } int get_len(char *s, int *chars_to_len) { int len; char *p = s; while (*p && !isspace(*p) && (*p!='l')) p++; *chars_to_len = p-s+1; 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; }