/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ /* From input file "denav.p" */ #include /* denav: density average Dr. Thomas D. Schneider National Institutes of Health National Cancer Institute Center for Cancer Research Nanobiology Program Molecular Information Theory Group Frederick, Maryland 21702-1201 toms@ncifcrf.gov permanent email: toms@alum.mit.edu (use only if first address fails) http://www.ccrnp.ncifcrf.gov/~toms/ */ /* end of program */ /* begin module version */ #define version 1.00 /* of denav.p 2009 Apr 14 2009 Apr 14, 1.00: origin */ #define updateversion 1.00 /* defines lowest acceptable current parameter file */ /* end module version */ /* begin module describe.denav */ /* name denav: density average synopsis denav(data: in, denavp: in, bfile: out, output: out) files data: Scan data file prepared for density plotting with denplo bfile: (not used) denavp: parameters to control the program. The file must contain the following parameters, one per line: parameterversion: The version number of the program. This allows the user to be warned if an old parameter file is used. piece coordinate column in data Ri evaluation (bits per site) output: messages to the user description When an individual information scan has been set up with zero coordinates, it can be plotted using denplo. What is the average information for the negative, zero and positive coordinates? examples 1.00 version of denav that this parameter file is designed for. 4 piece coordinate column in data 6 Ri evaluation (bits per site) documentation see also {scan program to generate data:} scan.p {density plotting program:} denplo.p {example parameter file for current scan data file:} denavp author Thomas Dana Schneider bugs technical notes */ /* end module describe.denav */ Static _TEXT data; /* file used by this program */ Static _TEXT denavp; /* file used by this program */ Static _TEXT bfile; /* file used by this program */ Static jmp_buf _JL1; /* begin module halt */ Static Void halt() { /* stop the program. the procedure performs a goto to the end of the program. you must have a label: label 1; declared, and also the end of the program must have this label: 1: end. examples are in the module libraries. this is the only goto in the delila system. */ printf(" program halt.\n"); longjmp(_JL1, 1); } #define tab 9 /* tab character */ /* end module halt version = 5.40; (@ of prgmod.p 2008 Aug 06 */ /* begin module skipblanks */ /* 2003 July 31: tab is considered a blank character */ Static boolean isblank(c) Char c; { /* is the character c blank or tab? */ return (c == ' ' || c == tab); } #undef tab Static Void skipblanks(thefile) _TEXT *thefile; { /* skip over blanks until a non-blank, or end of line, is found */ while (isblank(P_peek(thefile->f)) & (!P_eoln(thefile->f))) getc(thefile->f); } Static Void skipnonblanks(thefile) _TEXT *thefile; { /* skip over nonblanks until a blank, or end of line, is found */ while ((!isblank(P_peek(thefile->f))) & (!P_eoln(thefile->f))) getc(thefile->f); } Static Void skipcolumn(thefile) _TEXT *thefile; { /* skip over a data column */ skipblanks(thefile); skipnonblanks(thefile); } #define debugging true /* create output for debugging? */ /* end module skipblanks version = 5.40; (@ of prgmod.p 2008 Aug 06 */ /* begin module denav.themain */ Static Void themain(data, denavp, bfile) _TEXT *data, *denavp, *bfile; { /* the main procedure of the program */ double parameterversion; /* parameter version number */ long column; /* current column being inspected in the data file */ long coordinatecolumn; /* piece coordinate column in data */ long ricolumn; /* Ri evaluation (bits per site) column */ long coordinate; /*piece coordinate column in data */ double ri; /* Ri evaluation (bits per site) */ double risumneg = 0.0; /* Ri sum from negative coordinate values */ double risumzer = 0.0; /* Ri sum from zero coordinate values */ double risumpos = 0.0; /* Ri sum from positive coordinate values */ long negatives = 0; /* count of negative coordinate cases */ long zeros = 0; /* count of zero coordinate cases */ long positives = 0; /* count of positive coordinate cases */ printf("denav %4.2f\n", version); if (*denavp->name != '\0') { if (denavp->f != NULL) denavp->f = freopen(denavp->name, "r", denavp->f); else denavp->f = fopen(denavp->name, "r"); } else rewind(denavp->f); if (denavp->f == NULL) _EscIO2(FileNotFound, denavp->name); RESETBUF(denavp->f, Char); fscanf(denavp->f, "%lg%*[^\n]", ¶meterversion); getc(denavp->f); if ((long)floor(100 * parameterversion + 0.5) < (long)floor(100.0 + 0.5)) { printf("You have an old parameter file!\n"); halt(); } fscanf(denavp->f, "%ld%*[^\n]", &coordinatecolumn); getc(denavp->f); fscanf(denavp->f, "%ld%*[^\n]", &ricolumn); getc(denavp->f); if (*data->name != '\0') { if (data->f != NULL) data->f = freopen(data->name, "r", data->f); else data->f = fopen(data->name, "r"); } else { rewind(data->f); } if (data->f == NULL) _EscIO2(FileNotFound, data->name); RESETBUF(data->f, Char); while (!BUFEOF(data->f)) { if ((P_peek(data->f) == '*') | P_eoln(data->f)) { fscanf(data->f, "%*[^\n]"); getc(data->f); /* skip blank lines and comment lines */ continue; } column = 1; while (column < coordinatecolumn) { column++; skipcolumn(data); } fscanf(data->f, "%ld", &coordinate); column++; while (column < ricolumn) { column++; skipcolumn(data); } fscanf(data->f, "%lg", &ri); fscanf(data->f, "%*[^\n]"); getc(data->f); /* if debugging then writeln(output, coordinate:1, ' ',ri:10:8); */ /* at this point we have the coordinate and the ri value */ if (coordinate < 0) { risumneg = ri + risumneg; negatives++; /* if debugging then writeln(output, '= ', negatives:1, ' ', risumneg:1); */ continue; } if (coordinate > 0) { risumpos = ri + risumpos; positives++; /* if debugging then writeln(output, '= ', positives:1, ' ', risumpos:1); */ } else { risumzer = ri + risumzer; zeros++; /* coordinate = 0 */ } } /* now compute the averages! */ if (negatives > 0) printf("Average of %7ld negative coordinate Ri values: %10.6f bits per site\n", negatives, risumneg / negatives); /* writeln(output, 'negatives: ', negatives:1, ' ', risumneg:10); */ else printf(" No negative coordinates\n"); if (zeros > 0) printf("Average of %7ld zero coordinate Ri values: %10.6f bits per site\n", zeros, risumzer / zeros); /* writeln(output, 'zeros: ', zeros:1, ' ', risumzer:10); */ else printf(" No zero coordinates\n"); if (positives > 0) printf("Average of %7ld positive coordinate Ri values: %10.6f bits per site\n", positives, risumpos / positives); /* writeln(output, 'positives: ', positives:1, ' ', risumpos:10); */ else printf(" No positive coordinates\n"); if (negatives + zeros + positives > 0) printf( "Average of %7ld total coordinate Ri values: %10.6f bits per site\n", positives + zeros + negatives, (risumneg + risumzer + risumpos) / (negatives + zeros + positives)); else { printf(" No coordinates\n"); } } #undef debugging /* end module denav.themain */ main(argc, argv) int argc; Char *argv[]; { PASCAL_MAIN(argc, argv); if (setjmp(_JL1)) goto _L1; bfile.f = NULL; strcpy(bfile.name, "bfile"); denavp.f = NULL; strcpy(denavp.name, "denavp"); data.f = NULL; strcpy(data.name, "data"); themain(&data, &denavp, &bfile); _L1: if (data.f != NULL) fclose(data.f); if (denavp.f != NULL) fclose(denavp.f); if (bfile.f != NULL) fclose(bfile.f); exit(EXIT_SUCCESS); } /* End. */