/* merge.c Compile with: gcc -g merge.c -lm -o N.data/merge gcc -g merge.c -DANCHOR -lm -o A.data/merge Example run: merge intv_file1 intv_file2 > intv_file3 (see bat_merge for a more contextual example) Merges two interval files of anchor values, to produce an interval file with a finer interleaving. For instance, merging: ::::: tmp1 ::::: 0.001 0.003 15 20 35 0.004 0.006 12 10 22 with: ::::: tmp2 ::::: 0.001 0.002 10 10 20 0.003 0.006 20 20 40 produces: 0.001 0.002 25 30 55 0.003 0.003 35 40 75 0.004 0.006 32 30 62 NOTE: used in combined region assessments. */ #include #include #include #include #include #include #define EPSILON 0.001 #ifndef ANCHOR #define LOWER_BOUND 0.00 #define UPPER_BOUND 100.00 #else #define LOWER_BOUND -100.00 #define UPPER_BOUND 100.00 #endif #define Usage "%s [L=] [U=]" #define max(x,y) (((x)>=(y)) ? (x) : (y)) #define min(x,y) (((x)<=(y)) ? (x) : (y)) void fatal(char *message); void fatalf(char *msg, char *val); FILE *ckopen(char *name, char *mode); int read_file(char *,double *,double *,int *,int *); int merge(double *,double *,double *,double *,double *,double *, int *,int *,int *,int *,int *,int *,int,int); void print_results(double *,double *,int *,int *,int,int,int); int comparable(double,double,double,double); int main(int argc, char *argv[]) { int n1, n2, low, up, top; double From1[1000], From2[1000], To1[1000], To2[1000]; double From[2000], To[2000]; int FP1[1000], FP2[1000], FN1[1000], FN2[1000]; int FP[2000], FN[2000]; low = LOWER_BOUND; up = UPPER_BOUND; if ((argc<3) || (argc>5)) fatalf(Usage, argv[0]); while (argc>3) { if (!strncmp(argv[argc-1],"L=",2)) low = atoi(argv[argc-1]+2); else if (!strncmp(argv[argc-1],"U=",2)) up = atoi(argv[argc-1]+2); argc--; } n1 = read_file(argv[1], From1, To1, FP1, FN1); n2 = read_file(argv[2], From2, To2, FP2, FN2); top = merge(From1, From2, From, To1, To2, To, FP1, FP2, FP, FN1, FN2, FN, n1, n2); print_results(From, To, FP, FN, top, low, up); return 0; } void print_results(double *from, double *to, int *fp, int *fn, int top, int low, int up) { int i, save_i; char tmp[50]; i = 0; while ((i