/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ /* From input file "bndrec.p" */ #include /* bndrec: create marks file for a boundrectangle Tom Schneider NCI/FCRDC Bldg 469. Room 144 P.O. Box B Frederick, MD 21702-1201 (301) 846-5581 (-5532 for messages) permanent email: toms@alum.mit.edu toms@ncifcrf.gov http://www.lecb.ncifcrf.gov/~toms/ National Cancer Institute Laboratory of Experimental and Computational Biology */ /* end of program */ /* begin module version */ #define version 1.05 /* of bndrec.p 2000 March 27 1.00; 2000 March 23 origin */ #define updateversion 1.00 /* defines lowest acceptable current parameter file */ /* end module version */ /* begin module describe.bndrec */ /* name bndrec: create marks file for a boundrectangle synopsis bndrec(bndrecp: in, bndmarks: out, output: out) files bndmarks: The marks for the lister program. Concatenate this to the end of the marks.arrow file and put the result into the marks file for lister. bndrecp: 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. output: messages to the user description It is somewhat difficult to write the specific corners of boundrectangles as defined in marks.arrow. This program takes a simple parameter file and creates the user defined marks. examples The boundrectangle is called this way: U 4000.0 -12.00 4019.0 -11.00 -217 boundrectangle U says to lister to start working on a user defined mark 4000 is the left edge of the mark in bases -12 is the lower edge of the mark in bits 4019 is the right edge of the mark in bases -12 is the upper edge of the mark in bits -217 is how far back the rectangle should be shifte in bases The bndmarkp file creates this from: documentation see also {program that uses marks} lister.p {definition of boundrectangles:} marks.arrow {this MUST be before the bndmarks from this file.} author Thomas Dana Schneider bugs technical notes */ /* end module describe.bndrec */ Static _TEXT bndrecp; /* file used by this program */ Static _TEXT bndmarks; /* 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 = 'delmod 6.16 84 mar 12 tds/gds'; */ /* 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 */ #define dec 2 /* decimals of reals */ #define wid 10 /* width of reals */ #define debug false /* true means give debug output */ /* end module copyaline version = 7.42; {of delmod.p 2000 Mar 22} */ /* begin module bndrec.themain */ Static Void themain(bndrecp, bndmarks) _TEXT *bndrecp, *bndmarks; { /* the main procedure of the program */ double bits; /* bits below or above the DNA line */ double bitheight = 1.0; /* height of rectangle */ long counter; /* for debugging */ double displacement = 0.0; /* displacement of the trigger point */ double left; /* left edge */ double parameterversion; /* parameter version number */ double right; /* right edge */ Char skip; /* for skipping characters */ printf("bndrec %4.2f\n", version); if (*bndrecp->name != '\0') { if (bndrecp->f != NULL) bndrecp->f = freopen(bndrecp->name, "r", bndrecp->f); else bndrecp->f = fopen(bndrecp->name, "r"); } else rewind(bndrecp->f); if (bndrecp->f == NULL) _EscIO2(FileNotFound, bndrecp->name); RESETBUF(bndrecp->f, Char); fscanf(bndrecp->f, "%lg%*[^\n]", ¶meterversion); getc(bndrecp->f); if (parameterversion < updateversion) { printf("You have an old parameter file!\n"); halt(); } if (*bndmarks->name != '\0') { if (bndmarks->f != NULL) bndmarks->f = freopen(bndmarks->name, "w", bndmarks->f); else bndmarks->f = fopen(bndmarks->name, "w"); } else { if (bndmarks->f != NULL) { rewind(bndmarks->f); } else bndmarks->f = tmpfile(); } if (bndmarks->f == NULL) _EscIO2(FileNotFound, bndmarks->name); SETUPBUF(bndmarks->f, Char); fprintf(bndmarks->f, "* bndrec %4.2f\n", version); if (debug) counter = 0; while (!BUFEOF(bndrecp->f)) { if (debug) counter++; if (debug) printf("%ld\n", counter); if (debug) printf("bndrecp^ = \"%c\"\n", P_peek(bndrecp->f)); if (P_eoln(bndrecp->f)) { fscanf(bndrecp->f, "%*[^\n]"); getc(bndrecp->f); continue; } if (P_peek(bndrecp->f) == 'd') { /* set displacement */ fscanf(bndrecp->f, "%c%lg%*[^\n]", &skip, &displacement); getc(bndrecp->f); if (skip == '\n') skip = ' '; fprintf(bndmarks->f, "* displacement: %*.*f\n", wid, dec, displacement); continue; } if (P_peek(bndrecp->f) == 'b') { /* set bits height */ fscanf(bndrecp->f, "%c%lg%*[^\n]", &skip, &bitheight); getc(bndrecp->f); if (skip == '\n') skip = ' '; fprintf(bndmarks->f, "* bitheight: %*.*f\n", wid, dec, bitheight); continue; } if (P_peek(bndrecp->f) == 'u') { /* set user definitions */ do { copyaline(bndrecp, bndmarks); if (BUFEOF(bndrecp->f)) { printf("no end to user definition (u) found.\n"); printf("you need to end it with a '!'\n"); halt(); } if (debug) printf("copying\n"); } while (P_peek(bndrecp->f) != '!'); copyaline(bndrecp, bndmarks); /* pass by the '!' */ continue; } if (P_peek(bndrecp->f) == '*') { /* copy comment */ copyaline(bndrecp, bndmarks); continue; } if (debug) printf("reading left ...\n"); fscanf(bndrecp->f, "%lg%lg%lg%*[^\n]", &left, &right, &bits); getc(bndrecp->f); if (right < left) { printf("all right coordinates must be greater than left\n"); printf("* left:%*.*f\n", wid, dec, left); printf("* right:%*.*f\n", wid, dec, right); halt(); } fprintf(bndmarks->f, "\n* left:%*.*f\n", wid, dec, left); fprintf(bndmarks->f, "* right:%*.*f\n", wid, dec, right); fprintf(bndmarks->f, "U %*.*f %*.*f %*.*f %*.*f %*.*f boundrectangle\n", wid, dec, displacement, wid, dec, bits, wid, dec, displacement + right - left, wid, dec, bits + bitheight, wid, dec, 2 * (left - displacement)); displacement += 1.0; } /* U 4000.0 -12.00 4019.0 -11.00 -217 boundrectangle U 4001.0 -13.00 4040.0 -12.00 -217 boundrectangle */ } #undef dec #undef wid #undef debug /* end module bndrec.themain */ main(argc, argv) int argc; Char *argv[]; { PASCAL_MAIN(argc, argv); if (setjmp(_JL1)) goto _L1; bndmarks.f = NULL; strcpy(bndmarks.name, "bndmarks"); bndrecp.f = NULL; strcpy(bndrecp.name, "bndrecp"); themain(&bndrecp, &bndmarks); _L1: if (bndrecp.f != NULL) fclose(bndrecp.f); if (bndmarks.f != NULL) fclose(bndmarks.f); exit(EXIT_SUCCESS); } /* End. */