/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ /* From input file "chaos.p" */ #include /* chaos: chaotic analysis of scan data Tom Schneider NCI/FCRDC Bldg 469. Room 144 P.O. Box B Frederick, MD 21702-1201 (301) 846-5581 (-5532 for messages) toms@ncifcrf.gov http://www-lmmb.ncifcrf.gov/~toms/ National Cancer Institute Laboratory of Mathematical Biology */ /* end of program */ /* begin module version */ #define version 1.05 /* of chaos.p 1996 October 21 origin 1996 January 25 */ /* end module version */ /* begin module describe.chaos */ /* name chaos: chaotic analysis of scan data synopsis chaos(data: in, xyin: out, output: out) files data: data from the scan program xyin: data rearranged for chaotic analysis plot. The file format is ready for input to xyplo. output: messages to the user description A "classical" test for chaos in a system is to transform the series: x1, x2, x3, x4, x5, ... Into a set of pairs of coordinates: (x1,x2) (x2,x3) (x3,x4) (x4,x5) ... If there is no relationship, then one gets a random-looking scatter diagram. If there is a chaotic relationship, one gets curves. This program uses the potential locations of binding sites found by the scan program (and output in file 'data') as the input series. These values are then weighted by their probability. examples data: * DEFINITION OF THE DATA COLUMNS: * 1 piece number * 2 piece length * 3 piece name * 4 piece coordinate * 5 matrix orientation (+1 = as in book, -1 = complement) * 6 Ri evaluation (bits per site) * 7 Z * 8 probability * 1 87192 p1 15 1 2.184500 -2.223394 0.013095 1 87192 p1 81 1 1.000218 -2.648260 0.004045 1 87192 p1 88 1 2.780186 -2.009690 0.022232 1 87192 p1 109 1 5.395104 -1.071578 0.141955 1 87192 p1 113 1 1.761704 -2.375074 0.008773 1 87192 p1 165 1 1.217743 -2.570222 0.005082 1 87192 p1 387 1 3.648239 -1.698272 0.044728 1 87192 p1 447 1 1.022737 -2.640181 0.004143 1 87192 p1 480 1 2.553458 -2.091029 0.018263 1 87192 p1 528 1 6.956904 -0.511276 0.304579 1 87192 p1 540 1 2.927385 -1.956881 0.025181 1 87192 p1 587 1 1.316462 -2.534806 0.005625 1 87192 p1 609 1 6.937751 -0.518147 0.302178 1 87192 p1 621 1 1.241720 -2.561620 0.005209 1 87192 p1 625 1 2.097234 -2.254701 0.012076 1 87192 p1 705 1 1.965286 -2.302038 0.010667 1 87192 p1 992 1 3.166391 -1.871137 0.030663 1 87192 p1 1108 1 1.757896 -2.376440 0.008740 documentation see also scan.p, xyplo.p author Thomas Dana Schneider bugs The program uses the coordinates reported in the data file. Since these are piece coordinates they are not necessarily linear (ie, 1 to n). If fragments have been extracted from a circular sequence, the results will have some incorrect data. (This is a minor bug.) technical notes */ /* end module describe.chaos */ /* begin module chaos.const */ #define infofield 12 /* size of field for printing information in bits */ #define infodecim 6 /* number of decimal places for printing information */ /* end module chaos.const */ Static _TEXT data; /* file used by this program */ Static _TEXT xyin; /* 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); } /* end module halt version = 4.15; (@ of prgmod.p 1994 November 12 */ /* begin module copyaline */ Static Void copyaline(fin, fout) _TEXT *fin, *fout; { /* copy a line from file fin to file fout */ while (!P_eoln(fin->f)) { putc(P_peek(fin->f), fout->f); getc(fin->f); } fscanf(fin->f, "%*[^\n]"); getc(fin->f); putc('\n', fout->f); } /* copyaline */ /* end module copyaline version = 4.15; (@ of prgmod.p 1994 November 12 */ /* begin module skipblanks */ Static Void skipblanks(thefile) _TEXT *thefile; { /* skip over blanks until a non-blank, or end of line, is found */ while ((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 ((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); } /* end module skipblanks version = 4.15; (@ of prgmod.p 1994 November 12 */ /* begin module chaos.themain */ Static Void themain(data, xyin) _TEXT *data, *xyin; { /* the main procedure of the program */ long piecenumber; /* standard column in data */ long piecelength; /* standard column in data */ /* piecename skip this, standard column in data */ long piececoordinate; /* standard column in data */ long matrixorientation; /* standard column in data */ double Ri; /* standard column in data */ double Z; /* standard column in data */ double probability; /* standard column in data */ long oldpiecenumber = LONG_MAX; /* standard column in data */ long oldpiecelength = LONG_MAX; /* standard column in data */ /* oldpiecename skip this, standard column in data */ long oldpiececoordinate = LONG_MAX; /* standard column in data */ long oldmatrixorientation = LONG_MAX; /* standard column in data */ double oldRi = LONG_MAX; /* standard column in data */ double oldZ = LONG_MAX; /* standard column in data */ double oldprobability = LONG_MAX; /* standard column in data */ long oldoldpiecenumber = 0; /* standard column in data */ double hue; /* the hue of a color */ double saturation = 1.00; /* the saturation of a color */ double brightness = 1.00; /* the brightness of a color */ long deltapiececoordinate; /* change in piececoordinate */ long olddeltapiececoordinate = LONG_MAX; /* previous deltapiececoordinate */ printf("chaos %4.2f\n", version); if (*xyin->name != '\0') { if (xyin->f != NULL) xyin->f = freopen(xyin->name, "w", xyin->f); else xyin->f = fopen(xyin->name, "w"); } else { if (xyin->f != NULL) rewind(xyin->f); else xyin->f = tmpfile(); } if (xyin->f == NULL) _EscIO2(FileNotFound, xyin->name); SETUPBUF(xyin->f, Char); fprintf(xyin->f, "* chaos %4.2f\n", version); fprintf(xyin->f, "*\n"); fprintf(xyin->f, "* DEFINITION OF THE DATA COLUMNS:\n"); fprintf(xyin->f, "* 1 delta old piece coordinate\n"); fprintf(xyin->f, "* 2 delta piece coordinate\n"); fprintf(xyin->f, "* 3 hue\n"); fprintf(xyin->f, "* 4 saturation\n"); fprintf(xyin->f, "* 5 brightness\n"); fprintf(xyin->f, "*\n"); 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)) { /* write (output,'piecenumber:',piecenumber:10); write (output,'oldpiecenumber:',oldpiecenumber:10); writeln(output,'oldoldpiecenumber:',oldoldpiecenumber:10); */ while (P_peek(data->f) == '*') copyaline(data, xyin); if (BUFEOF(data->f)) break; fscanf(data->f, "%ld", &piecenumber); fscanf(data->f, "%ld", &piecelength); skipcolumn(data); /* skip the piecename */ fscanf(data->f, "%ld", &piececoordinate); fscanf(data->f, "%ld", &matrixorientation); fscanf(data->f, "%lg", &Ri); fscanf(data->f, "%lg", &Z); fscanf(data->f, "%lg", &probability); fscanf(data->f, "%*[^\n]"); getc(data->f); deltapiececoordinate = piececoordinate - oldpiececoordinate; /* we display only when there are two delta intervals available: */ if (oldoldpiecenumber == piecenumber) { hue = probability; fprintf(xyin->f, " %*.*f", infofield, infodecim, oldRi); fprintf(xyin->f, " %*.*f", infofield, infodecim, Ri); fprintf(xyin->f, " %*.*f", infofield, infodecim, hue); fprintf(xyin->f, " %*.*f", infofield, infodecim, saturation); fprintf(xyin->f, " %*.*f\n", infofield, infodecim, brightness); } oldoldpiecenumber = oldpiecenumber; oldpiecenumber = piecenumber; oldpiecelength = piecelength; oldpiececoordinate = piececoordinate; oldmatrixorientation = matrixorientation; oldRi = Ri; oldZ = Z; oldprobability = probability; olddeltapiececoordinate = deltapiececoordinate; } printf("done\n"); } /* end module chaos.themain */ main(argc, argv) int argc; Char *argv[]; { PASCAL_MAIN(argc, argv); if (setjmp(_JL1)) goto _L1; xyin.f = NULL; strcpy(xyin.name, "xyin"); data.f = NULL; strcpy(data.name, "data"); themain(&data, &xyin); _L1: if (data.f != NULL) fclose(data.f); if (xyin.f != NULL) fclose(xyin.f); exit(EXIT_SUCCESS); } /* * DEFINITION OF THE DATA COLUMNS: * 1 piece number * 2 piece length * 3 piece name * 4 piece coordinate * 5 matrix orientation (+1 = as in book, -1 = complement) * 6 Ri evaluation (bits per site) * 7 Z * 8 probability * 1 87192 p1 15 1 2.184500 -2.223394 0.013095 1 87192 p1 81 1 1.000218 -2.648260 0.004045 1 87192 p1 88 1 2.780186 -2.009690 0.022232 1 87192 p1 109 1 5.395104 -1.071578 0.141955 1 87192 p1 113 1 1.761704 -2.375074 0.008773 1 87192 p1 165 1 1.217743 -2.570222 0.005082 1 87192 p1 387 1 3.648239 -1.698272 0.044728 1 87192 p1 447 1 1.022737 -2.640181 0.004143 1 87192 p1 480 1 2.553458 -2.091029 0.018263 1 87192 p1 528 1 6.956904 -0.511276 0.304579 1 87192 p1 540 1 2.927385 -1.956881 0.025181 1 87192 p1 587 1 1.316462 -2.534806 0.005625 1 87192 p1 609 1 6.937751 -0.518147 0.302178 1 87192 p1 621 1 1.241720 -2.561620 0.005209 1 87192 p1 625 1 2.097234 -2.254701 0.012076 1 87192 p1 705 1 1.965286 -2.302038 0.010667 1 87192 p1 992 1 3.166391 -1.871137 0.030663 1 87192 p1 1108 1 1.757896 -2.376440 0.008740 */ /* End. */