/* crop.c Compile with: gcc -g crop.c -lm -o crop Example run: crop hs3_DEVIATION.l11 80 73 > tmp 'Crops' a DEVIATION file to the runs which conform to the specified true positives percentage cut. In the example above, only runs reported in hs3_DEVIATION.l11 which have more than 80% true positives (ie, less than 20% false negatives) of the 73 total functional positions will be extracted. */ #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 main(int argc, char *argv[]) { char buffer[200], *s; int i, length, pct, thresh; FILE *fp; if (argc!=4) fatalf(Usage, argv[0]); pct = atoi(argv[2]); length = atoi(argv[3]); thresh = ((100-pct)*length)/100; fp = ckopen(argv[1],"r"); while (fgets(buffer,200,fp)!=NULL) { s = buffer; while (!isspace(*s)) s++; /* go past filename */ while (isspace(*s)) s++; /* go past blanks */ while (!isspace(*s)) s++; /* go past fp: label */ while (isspace(*s)) s++; /* go past blanks */ while (isdigit(*s)) s++; /* go past fp values */ while (isspace(*s)) s++; /* go past blanks */ while (!isspace(*s)) s++; /* go past fn: label */ while (isspace(*s)) s++; /* go past blanks */ sscanf(s,"%d",&i); if (i