/* false positives */ /* crops_fp.c Compile with: gcc -g crops_fp.c -lm -o crops_fp Example run: crops_fp beta_DEVIATION.X.l6 60 93 14 Example output: from: 61 to: 80 fp: 40 fn: 13 total: 53 (93) 60 l=6 Given an agree-DEVIATION file, it outputs the interval of p-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 p-interval for phylogen runs on the HBB promoter region with l=6 (ct) which exceed 60% true positives (ie, < 40% fn) is [61,80], when gaps are not allowed in the regions (X). The fp, fn and total counts are: 40, 13 and 53 respectively. 93 is the total length of the known functional regions (maxfn). The chars_to_len value is 14=strlen("agree.beta.X.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; int from[1000], to[1000]; int fn[1000], fp[1000]; 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; 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,"%d %d %d %d", &from[k], &to[k], &fp[k], &fn[k]); if (fn[k]>thresh) continue; if (fp[k]+fn[k]=1) && (fp[i]==fp[i-1])) i--; if (i>=0) printf("from: %d to: %d 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; }