/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ /* From input file "dotsba.p" */ #include /* dotsba: dots to database Tom Schneider NCI/FCRDC Bldg 469. Room 144 P.O. Box B Frederick, MD 21702-1201 (301) 846-5581 (-5532 for messages) network address: toms@ncifcrf.gov National Cancer Institute Laboratory of Mathematical Biology 1990 */ /* end of program */ /* begin module version */ #define version 1.07 /* of dotsba.p 1990 December 9 origin 1987 sep 21 */ /* end module version */ /* begin module describe.dotsba */ /* name dotsba: dots to database synopsis dotsba(dots: in, database: out, output: out) files dots: dot input format of sequences. First line is the header line for the database. Second line is the standard, not to be copied to the database. Following lines have a period (dot, '.') replacing bases that are the same as the standard or a different base. There may be any number of spaces. Following this is a bar (|). Following the bar are other data to be copied to the database: clone number, primer for sequencing, and the date. database: reformatted data ready for sites program output: messages to the user description To convert from dots format to one the sites program can use. It should not have been necesary to do this, but Peter Papp didn't type the original sequences in unfortunately. examples documentation see also sites.p author Thomas Dana Schneider bugs This is a stupid program. technical notes */ /* end module describe.dotsba */ /* begin module interact.const */ #define maxstring 150 /* the maximum string */ /* end module interact.const version = 4.09; (@ of prgmod.p 1990 May 18 */ /* begin module interact.type */ typedef struct string { /* a string of characters */ Char letters[maxstring]; /* the letters in the string */ long length; /* the number of characters in the string */ long current; /* the letter we are working on */ } string; /* end module interact.type version = 4.09; (@ of prgmod.p 1990 May 18 */ Static _TEXT dots, database; /* files 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 */ /* end module copyaline version = 4.75; (@ of rsgra.p 1990 Oct 2 */ /* begin module interact.clearstring */ Static Void clearstring(ribbon) string *ribbon; { /* empty the string */ long index; /* to the ribbon */ for (index = 0; index < maxstring; index++) ribbon->letters[index] = ' '; ribbon->length = 0; ribbon->current = 0; } /* clearstring */ /* end module interact.clearstring version = 4.09; (@ of prgmod.p 1990 May 18 */ /* begin module interact.getstring */ Static Void getstring(afile, buffer, gotten) _TEXT *afile; string *buffer; boolean *gotten; { /* get a string from a file not using string calls. this lets one obtain lines from a file without interactive prompts */ long index = 0; /* of buffer */ clearstring(buffer); if (BUFEOF(afile->f)) { *gotten = false; return; } while (!P_eoln(afile->f) && index < maxstring) { index++; buffer->letters[index-1] = getc(afile->f); if (buffer->letters[index-1] == '\n') buffer->letters[index-1] = ' '; } if (!P_eoln(afile->f)) { printf(" getstring: a line exceeds maximum string size (%ld)\n", (long)maxstring); halt(); } buffer->length = index; buffer->current = 1; fscanf(afile->f, "%*[^\n]"); getc(afile->f); *gotten = true; } /* getstring */ #define mark_ '|' /* character indicating end of sequence data on a line */ /* end module interact.getstring version = 4.09; (@ of prgmod.p 1990 May 18 */ /* begin module dotsba.themain */ Static Void themain(dots, database) _TEXT *dots, *database; { /* the main procedure of the program */ boolean gotten; /* a line of data was obtained */ string wildtype; /* first line of the dots file; sample */ printf("dotsba %4.2f\n", version); /* put the database title out */ if (*dots->name != '\0') { if (dots->f != NULL) dots->f = freopen(dots->name, "r", dots->f); else dots->f = fopen(dots->name, "r"); } else rewind(dots->f); if (dots->f == NULL) _EscIO2(FileNotFound, dots->name); RESETBUF(dots->f, Char); if (*database->name != '\0') { if (database->f != NULL) database->f = freopen(database->name, "w", database->f); else database->f = fopen(database->name, "w"); } else { if (database->f != NULL) rewind(database->f); else database->f = tmpfile(); } if (database->f == NULL) _EscIO2(FileNotFound, database->name); SETUPBUF(database->f, Char); copyaline(dots, database); if (*dots->name != '\0') { if (dots->f != NULL) dots->f = freopen(dots->name, "r", dots->f); else dots->f = fopen(dots->name, "r"); } else rewind(dots->f); if (dots->f == NULL) _EscIO2(FileNotFound, dots->name); RESETBUF(dots->f, Char); fscanf(dots->f, "%*[^\n]"); getc(dots->f); /* skip the database title */ getstring(dots, &wildtype, &gotten); /* the standard */ if (!gotten) { printf("could not find the sequence standard!\n"); halt(); } while (!BUFEOF(dots->f)) { wildtype.current = 1; while ((!P_eoln(dots->f)) & (P_peek(dots->f) != mark_)) { if (P_peek(dots->f) == '.') CPUTFBUF(database->f, wildtype.letters[wildtype.current - 1]); else CPUTFBUF(database->f, P_peek(dots->f)); if (P_peek(dots->f) != ' ') CPUT(database->f); getc(dots->f); wildtype.current++; } if (P_peek(dots->f) != mark_) { printf("missing mark (%c): it was\"%c\"\n", mark_, P_peek(dots->f)); /* should have been a | */ halt(); } getc(dots->f); copyaline(dots, database); } } #undef mark_ /* end module dotsba.themain */ main(argc, argv) int argc; Char *argv[]; { PASCAL_MAIN(argc, argv); if (setjmp(_JL1)) goto _L1; database.f = NULL; strcpy(database.name, "database"); dots.f = NULL; strcpy(dots.name, "dots"); themain(&dots, &database); _L1: if (dots.f != NULL) fclose(dots.f); if (database.f != NULL) fclose(database.f); exit(EXIT_SUCCESS); } /* End. */