/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ /* From input file "dblo.p" */ #include /* dblo: look at the catalogue of a genbank/embl database thomas schneider copyright module libraries required: delman, prgmods */ /* end of the program */ /* begin module version */ #define version 1.11 /* of dblo.p 1998 July 16 1998 July 16: upgrade origin 1985 may 28 */ /* end module version */ /* begin module describe.dblo */ /* name dblo: look at the catalogue of a genbank/embl database synopsis dblo(cat: in, list: out, output: out) files cat: a catalogue from program dbcat list: a listing in tabular form of the catalogue output: messages to the user description the program dbcat creates a machine readable catalogue of the locations of entries in a genbank /embl database. one cannot read this directly because it is a compressed internal format of the computer. (that is, it is a file of records.) to read the file, one must convert it into normal characters, which is what dblo does. author thomas schneider see also dbcat.p, dbpull.p, loocat.p, delila.p bugs none known */ /* end module describe.dblo */ /* begin module dblo.const */ #define linewidth 10 /* number of characters for display of the line number of an entry in the catalogue */ #define libwidth 10 /* number of characters for display of the number of the library in which an entry is found */ /* end module dblo.const */ /* begin module dbpull.constant */ /* more constants */ #define idlength 20 /* length of identification code of a library entry */ #define namelength idlength /* length of computer system date */ #define lclength 3 /* length of code at beginning of each library line */ #define libtotal 8 /* number of libraries used in program */ #define lctotal 20 /* maximum number of line code requests */ #define checknum 1 /* controls the number of times certain procedures run */ /* the following constants are used for string comparisons by the functions lcequal and idequal. if your computer system does not do these packed array comparisons, the functions must be re- written and the constants replaced by a series of assignment statements to declared arrays. */ #define spraw "RAW" /* special fin request that pulls only sequence */ #define spall "ALL" /* special request that pulls whole entry */ #define lcloc "LOC" /* short for locus, line code(lc) for genb entry beginning point. this line contains id of entry */ #define lcid "ID " /* begining point of embl entry, also holds id */ #define lc3spc " " /* three space line code always identifies sequence lines of an embl type entry */ #define lcxx "XX " /* marks the end of a string of one or more embl lines having the same line code */ #define lct " T" /* first letter of title, part of reference section of genb entry. if you pull 'ref', you pull ' t' */ #define lca " A" /* first letter of author, part of reference section of a genb entry. if you pull 'ref', you pull ' a' */ #define lcj " J" /* first letter of journal, part of ref also */ #define lcori "ORI" /* short for origin, code for line just above sequence in genbank entries */ #define lcsit "SIT" /* short for sites, line just below sequence in genb */ #define lcterm "// " /* terminus code at the end of every entry */ #define lcdat "DAT" /* short for date, used for dateline of libraries */ #define idembl "EMBL " /* fin line indicating that following lines contain embl requests */ #define idgenb "GENB " /* following lines are for genb requests */ #define idgenbank "GENBANK " /* ' ' */ #define iddate "DATE " /* catalogs of undated libraries use this as the date */ #define idevery "EVERY " /* special id that matches any id it is compared to */ /* end module dbpull.constant version = 2.32; (@ of dbpull 1985 apr 20 */ /* begin module dbpull.type */ /* a 'u' after the 'lc' or 'id' in a type name indicates that the array is unpacked; a 'p' indicates that the array is packed; an 's' indicates that the array has more than one dimension */ typedef Char idutype[idlength]; /* holds id for reading-writing before packing */ typedef Char idptype[idlength]; /* holds id for string comparisons */ typedef idptype alpha; /* holds computer system date */ typedef char lnrange; /* subrange for handling number of libraries */ typedef struct catrec { /* structure of each catalog entry */ idptype idp; /* holds id of entry */ lnrange libnum; /* identifies in which of 8 libraries entry is found */ long linenumber; /* holds the line in a library where an entry begins */ } catrec; typedef struct dbcat { FILE *f; FILEBUFNC(f,catrec); Char name[_FNSIZE]; } dbcat; /* structure of whole catalog */ typedef Char lcutype[lclength]; /* holds library line code for reading-writing before packing */ typedef Char lcptype[lclength]; /* holds line code for string comparisons */ typedef Char lcstype[lctotal][lclength]; /* holds fin line code requests */ typedef char countype; /* subrange for handling line codes */ typedef enum { embl, genb } libsused; /* used to indicate whether requested entry is of embl or genbank type */ typedef enum { notwc, xwc, wcx, xwcx } wctype; /* used to indicate whether or not an id request is wildcard and if wc whether the set characters are in front, in back, or in the middle of the variable characters. the 'x' represents the variable part of the id */ /* end module dbpull.type version = 2.32; (@ of dbpull 1985 apr 20 */ /* begin module dblo.var */ Static dbcat cat; /* the catalogue to be analyzed */ Static _TEXT list; /* the listing of the catalogue */ Static jmp_buf _JL1; /* end module dblo.var */ /* 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 = 'prgmod 3.97 85 may 5 tds'; */ /* begin module dblo.themain */ Static Void themain(cat, list) dbcat *cat; _TEXT *list; { /* the main procedure of dblo */ catrec anentry; /* the information about an entry in the catalogue */ long entries = 0; /* number of entries in the database */ long i; /* index to the name of each entry in the catalogue */ printf(" DBLO %4.2f\n", version); if (*cat->name != '\0') { if (cat->f != NULL) cat->f = freopen(cat->name, "rb", cat->f); else cat->f = fopen(cat->name, "rb"); } else rewind(cat->f); if (cat->f == NULL) _EscIO2(FileNotFound, cat->name); RESETBUF(cat->f, catrec); if (*list->name != '\0') { if (list->f != NULL) list->f = freopen(list->name, "w", list->f); else list->f = fopen(list->name, "w"); } else { if (list->f != NULL) rewind(list->f); else list->f = tmpfile(); } if (list->f == NULL) _EscIO2(FileNotFound, list->name); SETUPBUF(list->f, Char); fprintf(list->f, " DBLO %4.2f: LOOK AT A DATABASE CATALOGUE\n", version); fprintf(list->f, " ID%*c%*cLIBRARY%*cLINE\n", (int)(idlength - 2), ' ', (int)(libwidth - 6), ' ', (int)(linewidth - 3), ' '); while (!BUFEOF(cat->f)) { entries++; anentry = GETFBUF(cat->f, catrec); putc(' ', list->f); for (i = 0; i < idlength; i++) putc(anentry.idp[i], list->f); fprintf(list->f, " %*d", libwidth, anentry.libnum); fprintf(list->f, " %*ld\n", linewidth, anentry.linenumber); GET(cat->f, catrec); } printf(" %ld ENTRIES IN THE CATALOGUE\n", entries); } /* end module dblo.themain */ main(argc, argv) int argc; Char *argv[]; { PASCAL_MAIN(argc, argv); if (setjmp(_JL1)) goto _L1; list.f = NULL; strcpy(list.name, "list"); cat.f = NULL; strcpy(cat.name, "cat"); themain(&cat, &list); _L1: if (cat.f != NULL) fclose(cat.f); if (list.f != NULL) fclose(list.f); exit(EXIT_SUCCESS); } /* End. */