/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ /* From input file "auxmod.p" */ #include /* auxiliary modules Gary Stormo and Thomas Schneider Dr. Thomas D. Schneider National Cancer Institute Laboratory of Experimental and Computational Biology 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.lecb.ncifcrf.gov/~toms/ */ /* end of program */ /* begin module version */ #define version 1.41 /* of delila.p 2004 Sep 8 2004 Sep 8, 1.41 upgrade for GPC 1994 Sep 5, 1.40 last major change 1986 dec 12: origin */ /* end module version */ /* begin module describe.auxmod */ /* name auxmod: modules for auxiliary programs synopsis auxmod(hst: in, cmp: in, patt: in, output: out) files hst: a histogram from hist for testing, or empty cmp: a composition from comp for testing, or empty patt: a pattern matrix from patlrn for testing, or empty output: the version of auxmod is printed. test results are printed. successful compilation and running of the program indicates that the modules are correct. description auxmod is a collection of modules used only rarely in various auxiliary programs. it includes modules for reading compositions (comp.), histograms (hist.), helix lists (findcolon and gethelix) and pattern matrices (matrix.). see also delmod.p, module.p, hist.p, comp.p, patlrn.p author gary d. stormo and thomas d. schneider bugs none known */ /* end module describe.auxmod */ /* begin module hist.const */ #define maxhistwidth 120 /* end module hist.const */ /* begin module matrix.const */ #define maxmatrix 120 /* the maximum size of a pattern matrix */ /* end module matrix.const */ /* begin module base.type */ /* declare the type base to avoid need for modules from delmods */ typedef enum { a, c, g, t } base; /* end module base.type */ /* begin module hist.type */ typedef long histarray[maxhistwidth]; typedef struct histogram { long *zero; long *mono[4]; long *di[4][4]; long *tri[4][4][4]; } histogram; /* end module hist.type */ /* begin module comp.type */ /* the composition is stored in a tree of these nodes */ /* points to a node of the tree */ typedef struct compnode { /* a node of the composition tree */ long count; /* the number of oligos for this node */ struct compnode *son[4]; /* the pointers to 'descendants' of this node of the tree */ } compnode; /* spiders are used to make the composition tree */ /* points to a 'spider' */ typedef struct spider { /* a spider climbs the composition tree, its path determined by the sequences, and increments 'count' at all the nodes it passes, thereby determining the composition */ long depth; /* the level of the node now at */ compnode *place; /* a pointer to the current node */ struct spider *next; /* the next spider in the collection */ } spider; /* the total number of composition entries at a given level is stored in the linked list of type comptotal */ typedef struct comptotal { long count; /* the number at a given level */ struct comptotal *next; /* pointer to the next level totals */ } comptotal; /* 'path' is used in printing the tree */ /* pointer into a path on the tree */ typedef struct path { /* the path of bases to get to a particular node */ base bas; struct path *next; } path; /* end module comp.type version = 'auxmod 1.25 82 dec 12 gds/tds'; */ /* begin module matrix.type */ typedef long matrix[4][maxmatrix]; /* a pattern matrix */ /* end module matrix.type */ Static _TEXT hst; /* an input histogram */ Static _TEXT cmp; /* an input composition */ Static _TEXT patt; /* an input pattern matrix */ /* variables for histogram reading */ Static long histmin, histmax, histwidth, histbegin, numseqs; Static histogram histo; /* variables for composition reading */ Static long compmax, readmax; Static compnode *root; Static comptotal *monocomptotal; /* variables for pattern matrix reading */ Static long beginning, pattwidth; Static matrix wmatrix; 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 = 'prgmod 3.96 85 mar 18 tds'; */ /* begin module basetochar */ Static Char basetochar(ba) base ba; { /* convert a base into a character */ Char Result; switch (ba) { case a: Result = 'a'; break; case c: Result = 'c'; break; case g: Result = 'g'; break; case t: Result = 't'; break; } return Result; } /* end module basetochar */ /* begin module skipoligo */ Static Void skipoligo(thefile) _TEXT *thefile; { /* this procedure is used to skip over an oligonucleotide string. it reads until it comes to a base, and then continues to read until it comes to a blank. no checking is done for non-base characters in between. */ Char ch; do { ch = getc(thefile->f); if (ch == '\n') ch = ' '; } while (ch != 't' && ch != 'g' && ch != 'c' && ch != 'a'); do { ch = getc(thefile->f); if (ch == '\n') ch = ' '; } while (ch != ' '); } /* end module skipoligo */ /* begin module hist.readhist */ Static Void readhist(hist, histmin, histmax, histwidth, histbegin, numseqs, histo) _TEXT *hist; long *histmin, *histmax, *histwidth, *histbegin, *numseqs; histogram *histo; { /* this procedure requires modules: hist.const, hist.type, skipoligo; this procedure takes a file 'hist', which is the output of the hist program, and returns the information in that file. the variables are: histmin: the shortest oligo counted in the histogram; histmax: the longest oligo counted in the histogram; histwidth: the width of the histogram; histbegin: the first position in the histogram; numseqs: the number of sequences counted in the histogram. the actual histogram data is returned in the variable 'histo'. */ base b1, b2, b3; long i, FORLIM; /* get the histogram parameters */ if (*hist->name != '\0') { if (hist->f != NULL) hist->f = freopen(hist->name, "r", hist->f); else hist->f = fopen(hist->name, "r"); } else rewind(hist->f); if (hist->f == NULL) _EscIO2(FileNotFound, hist->name); RESETBUF(hist->f, Char); fscanf(hist->f, "%*[^\n]"); getc(hist->f); fscanf(hist->f, "%*[^\n]"); getc(hist->f); fscanf(hist->f, "%ld%*[^\n]", histmin); getc(hist->f); fscanf(hist->f, "%ld%*[^\n]", histmax); getc(hist->f); fscanf(hist->f, "%ld%*[^\n]", numseqs); getc(hist->f); fscanf(hist->f, "%ld%*[^\n]", histwidth); getc(hist->f); fscanf(hist->f, "%*[^\n]"); getc(hist->f); fscanf(hist->f, "%ld%*[^\n]", histbegin); getc(hist->f); fscanf(hist->f, "%*[^\n]"); getc(hist->f); /* get the histogram data from histmin to histmax */ if (*histmin == 0) { histo->zero = (long *)Malloc(sizeof(histarray)); FORLIM = *histwidth; for (i = 0; i < FORLIM; i++) fscanf(hist->f, "%ld", &histo->zero[i]); } else histo->zero = NULL; if (*histmin <= 1 && *histmax >= 1) { for (b1 = a; (long)b1 <= (long)t; b1 = (base)((long)b1 + 1)) { skipoligo(hist); histo->mono[(long)b1] = (long *)Malloc(sizeof(histarray)); FORLIM = *histwidth; for (i = 0; i < FORLIM; i++) fscanf(hist->f, "%ld", &histo->mono[(long)b1][i]); } } else { for (b1 = a; (long)b1 <= (long)t; b1 = (base)((long)b1 + 1)) histo->mono[(long)b1] = NULL; } if (*histmin <= 2 && *histmax >= 2) { for (b1 = a; (long)b1 <= (long)t; b1 = (base)((long)b1 + 1)) { for (b2 = a; (long)b2 <= (long)t; b2 = (base)((long)b2 + 1)) { skipoligo(hist); histo->di[(long)b1][(long)b2] = (long *)Malloc(sizeof(histarray)); FORLIM = *histwidth; for (i = 0; i < FORLIM; i++) fscanf(hist->f, "%ld", &histo->di[(long)b1][(long)b2][i]); } } } else { for (b1 = a; (long)b1 <= (long)t; b1 = (base)((long)b1 + 1)) { for (b2 = a; (long)b2 <= (long)t; b2 = (base)((long)b2 + 1)) histo->di[(long)b1][(long)b2] = NULL; } } if (*histmax >= 3) { for (b1 = a; (long)b1 <= (long)t; b1 = (base)((long)b1 + 1)) { for (b2 = a; (long)b2 <= (long)t; b2 = (base)((long)b2 + 1)) { for (b3 = a; (long)b3 <= (long)t; b3 = (base)((long)b3 + 1)) { skipoligo(hist); histo->tri[(long)b1][(long)b2] [(long)b3] = (long *)Malloc(sizeof(histarray)); FORLIM = *histwidth; for (i = 0; i < FORLIM; i++) fscanf(hist->f, "%ld", &histo->tri[(long)b1][(long)b2][(long)b3] [i]); } } } return; } for (b1 = a; (long)b1 <= (long)t; b1 = (base)((long)b1 + 1)) { for (b2 = a; (long)b2 <= (long)t; b2 = (base)((long)b2 + 1)) { for (b3 = a; (long)b3 <= (long)t; b3 = (base)((long)b3 + 1)) histo->tri[(long)b1][(long)b2][(long)b3] = NULL; } } } /* for efficient reading of the information into the tree, each node that has a successor is stored in a queue as well as put into the tree. the variables of the type list are the queue elements. */ typedef struct list { compnode *item; /* points to the composition tree node */ struct list *next; /* points to the next list item in the queue */ } list; /* Local variables for readcomp: */ struct LOC_readcomp { list *freeitem; /* the list of unused list pointers */ } ; /* getitem and clearitem provide efficient use of linked list storage by keeping a list of unused pointers that can be allocated instead of always creating 'new' ones */ Local Void getitem(l, LINK) list **l; struct LOC_readcomp *LINK; { /* obtain a listitem from the free list or by making a new one */ if (LINK->freeitem != NULL) { *l = LINK->freeitem; LINK->freeitem = LINK->freeitem->next; } else *l = (list *)Malloc(sizeof(list)); (*l)->next = NULL; } Local Void clearitem(l, LINK) list **l; struct LOC_readcomp *LINK; { /* return a listitem to the free list */ list *lptr; if (*l == NULL) return; lptr = *l; *l = (*l)->next; lptr->next = LINK->freeitem; LINK->freeitem = lptr; } /* end module hist.readhist */ /* begin module comp.readcomp */ /* begin module skipoligo */ /* end module skipoligo */ Static Void readcomp(comp, compmax, readmax, root, monocomptotal) _TEXT *comp; long *compmax, readmax; compnode **root; comptotal **monocomptotal; { /* this procedure requires modules: comp.type, skipoligo, halt; this procedure reads from file 'comp' a composition and puts it into the tree pointed to by the 'root' pointer. 'compmax' is the depth of the composition tree which is stored. it is the minimum of 'readmax', the requested depth, and 'detcomp', the depth for which the input file composition was determined. 'monocomptotal' points to the beginning (for the monos) of a linked list which gives the totals for each level of the composition. */ struct LOC_readcomp V; list *listitem; /* an item in the queue */ list *first; /* the first item in the queue */ list *last; /* the last item in the queue */ comptotal *comptot; /* the comp total for a given level */ comptotal *newcomptot; /* for adding to the string of comptot"s */ long detcomp; /* the level to which the input composition was determined */ long level; /* of the composition being read, i.e., monos, dis, ... */ long number; /* read from the 'comp' file */ Char ch; /* for reading from 'comp' */ base ba; /* an index */ if (*comp->name != '\0') { if (comp->f != NULL) comp->f = freopen(comp->name, "r", comp->f); else comp->f = fopen(comp->name, "r"); } else rewind(comp->f); if (comp->f == NULL) _EscIO2(FileNotFound, comp->name); RESETBUF(comp->f, Char); if (BUFEOF(comp->f)) { printf(" error: no composition file provided\n"); halt(); } fscanf(comp->f, "%*[^\n]"); getc(comp->f); /* skip the program identification */ fscanf(comp->f, "%*[^\n]"); getc(comp->f); /* skip the book identification */ fscanf(comp->f, "%ld%*[^\n]", &detcomp); getc(comp->f); /* obtain the determined composition */ fscanf(comp->f, "%*[^\n]"); getc(comp->f); /* skip the blank line */ /* determine the level of composition to be stored */ if (readmax < 1) { printf("\n warning: 0 or negative oligo length requested\n"); printf(" composition used is depth %ld\n\n", detcomp); *compmax = detcomp; } else if (readmax > detcomp) { printf("\n warning: requested composition oligo length (%ld)\n", readmax); printf(" is larger than the determined composition oligo length (%ld).\n", detcomp); printf(" composition used is to depth %ld\n\n", detcomp); *compmax = detcomp; } else *compmax = readmax; *root = (compnode *)Malloc(sizeof(compnode)); *monocomptotal = (comptotal *)Malloc(sizeof(comptotal)); comptot = (comptotal *)Malloc(sizeof(comptotal)); first = (list *)Malloc(sizeof(list)); Malloc(sizeof(list)); /* p2c: auxmod.p: Note: Eliminated unused assignment statement [338] */ first->item = *root; first->next = NULL; last = first; V.freeitem = (list *)Malloc(sizeof(list)); V.freeitem->next = NULL; /* read in the total number of bases from the composition */ fscanf(comp->f, "%*[^\n]"); getc(comp->f); /* skip the * */ fscanf(comp->f, "%*[^\n]"); getc(comp->f); /* skip the information line */ fscanf(comp->f, "%ld%*[^\n]", &number); getc(comp->f); (*root)->count = number; do { ch = getc(comp->f); /* skip the space */ if (ch == '\n') ch = ' '; ch = getc(comp->f); /* the ch determines what to do next */ if (ch == '\n') ch = ' '; if (ch == '*') { /* determine the level about to be read */ fscanf(comp->f, "%*[^\n]"); getc(comp->f); fscanf(comp->f, "%ld%*[^\n]", &level); getc(comp->f); if (level == 1) *monocomptotal = comptot; else { newcomptot = (comptotal *)Malloc(sizeof(comptotal)); comptot->next = newcomptot; comptot = newcomptot; } comptot->count = 0; comptot->next = NULL; } else { for (ba = a; (long)ba <= (long)t; ba = (base)((long)ba + 1)) { skipoligo(comp); fscanf(comp->f, "%ld", &number); if (number != 0) { first->item->son[(long)ba] = (compnode *)Malloc(sizeof(compnode)); first->item->son[(long)ba]->count = number; comptot->count += number; getitem(&listitem, &V); last->next = listitem; last = listitem; last->next = NULL; last->item = first->item->son[(long)ba]; } else first->item->son[(long)ba] = NULL; } clearitem(&first, &V); fscanf(comp->f, "%*[^\n]"); getc(comp->f); } } while (level != *compmax); /* read the composition values */ /* for the last level of compositions to be read we don"t need to store the nodes in the queue because their successors will not be read in. */ do { for (ba = a; (long)ba <= (long)t; ba = (base)((long)ba + 1)) { skipoligo(comp); fscanf(comp->f, "%ld", &number); if (number != 0) { first->item->son[(long)ba] = (compnode *)Malloc(sizeof(compnode)); first->item->son[(long)ba]->count = number; comptot->count += number; } else first->item->son[(long)ba] = NULL; } clearitem(&first, &V); fscanf(comp->f, "%*[^\n]"); getc(comp->f); } while (first != NULL); } /* readcomp */ Static long getcount(root, start) compnode *root; path *start; { /* this function follows the tree from the node 'root' (which may be the root of a subtree) along the path initiated with 'start', and returns the count of the resulting node. if the path through the tree ever hits a null node in the process the count is returned to be zero. */ compnode *place = root; /* a place in the composition tree */ path *point = start; /* a point in the path through the tree */ while (place != NULL && point != NULL) { place = place->son[(long)point->bas]; point = point->next; } if (place == NULL) return 0; else return (place->count); } Local Void die() { printf(" no helix list data\n"); halt(); } /* end module comp.readcomp version = 'auxmod 1.25 82 dec 12 gds/tds'; */ /* ************************************************************************ */ /* begin module findcolon */ Static Void findcolon(thefile) _TEXT *thefile; { /* move the file to the characters just past ': ' (colon, space) */ boolean found = false; while (!found) { if (BUFEOF(thefile->f)) { die(); continue; } if (P_peek(thefile->f) != ':') { getc(thefile->f); continue; } getc(thefile->f); if (BUFEOF(thefile->f)) die(); else if (P_peek(thefile->f) == ' ') { getc(thefile->f); found = true; } } } /* end module findcolon version = 3.13; (* of matrix 1985 march 13 */ /* begin module gethelix */ Static Void gethelix(hlist, x, y, length, getenergy, energy, done) _TEXT *hlist; long *x, *y, *length; boolean getenergy; double *energy; boolean *done; { /* get the (x,y,length) info on some helix listed in hlist. if the x,y pair changes, then done is true and no values are returned. checknames may be used at this point to start the next pair. if getenergy is true, then the routine expects that there will be an energy on the helix line */ if (BUFEOF(hlist->f)) { *done = true; return; } getc(hlist->f); /* skip the blank */ if (P_peek(hlist->f) != ' ') { *done = true; return; } *done = false; findcolon(hlist); fscanf(hlist->f, "%ld", x); findcolon(hlist); fscanf(hlist->f, "%ld", y); findcolon(hlist); fscanf(hlist->f, "%ld", length); if (getenergy) fscanf(hlist->f, "%lg", energy); else *energy = 0.0; fscanf(hlist->f, "%*[^\n]"); getc(hlist->f); } /* gethelix */ /* end module gethelix version = 3.13; (* of matrix 1985 march 13 */ /* begin module complines */ Static boolean complines(a_, b) _TEXT *a_, *b; { /* compare one line from each of files a and b starting at the current file positions. both lines are compared up to and including the end-of-line mark (i.e., they are both readln-ed). return true if the lines are identical and false if they are not. ignore trailing blanks. this is done by letting chara or charb assume the value of a blank when eoln is true. when both lines are eoln, the next line is inspected. if one line is at end-of-file and the other is not, 'false' is returned. if both lines are at eof, 'true' is returned. */ boolean Result; Char chara, charb; /* characters in files a and b */ boolean done = false; /* stop looking for identity */ if (BUFEOF(a_->f) & BUFEOF(b->f)) return true; if (BUFEOF(a_->f) | BUFEOF(b->f)) return false; while (!done) { if (P_eoln(a_->f)) chara = ' '; else { chara = getc(a_->f); if (chara == '\n') chara = ' '; } if (P_eoln(b->f)) charb = ' '; else { charb = getc(b->f); if (charb == '\n') charb = ' '; } if (P_eoln(a_->f) & P_eoln(b->f)) { done = true; Result = true; } else if (chara != charb) { done = true; Result = false; } } fscanf(a_->f, "%*[^\n]"); getc(a_->f); fscanf(b->f, "%*[^\n]"); getc(b->f); /* neither file is eof. */ return Result; } /* complines */ Local Void gettitleline(xbook, ybook, hlist) _TEXT *xbook, *ybook, *hlist; { /* gets to the lines in the xbook, ybook, and hlist input files that contain the titles and thus are to be compared */ if (*xbook->name != '\0') { if (xbook->f != NULL) xbook->f = freopen(xbook->name, "r", xbook->f); else xbook->f = fopen(xbook->name, "r"); } else rewind(xbook->f); if (xbook->f == NULL) _EscIO2(FileNotFound, xbook->name); RESETBUF(xbook->f, Char); if (*ybook->name != '\0') { if (ybook->f != NULL) ybook->f = freopen(ybook->name, "r", ybook->f); else ybook->f = fopen(ybook->name, "r"); } else rewind(ybook->f); if (ybook->f == NULL) _EscIO2(FileNotFound, ybook->name); RESETBUF(ybook->f, Char); if (*hlist->name != '\0') { if (hlist->f != NULL) hlist->f = freopen(hlist->name, "r", hlist->f); else hlist->f = fopen(hlist->name, "r"); } else rewind(hlist->f); if (hlist->f == NULL) _EscIO2(FileNotFound, hlist->name); RESETBUF(hlist->f, Char); fscanf(hlist->f, "%*[^\n]"); getc(hlist->f); } /* gettitleline */ Local Void findtitle(hlist) _TEXT *hlist; { /* places the cursor at the beginning of the title in hlist */ long n; /* counter for skipping characters */ for (n = 1; n <= 4; n++) getc(hlist->f); } /* findtitle */ /* end module complines version = 'prgmod 3.96 85 mar 18 tds'; */ /* begin module hlistvsbooks */ Static Void hlistvsbooks(hlist, xbook, ybook) _TEXT *hlist, *xbook, *ybook; { /* list of helices from helix */ /* the delila books */ /* checks the title line in xbook with the corresponding line in hlist, ditto ybook. if they are not identical, error messages are sent to output and the program halts. written by britta singer */ boolean xasx; /* true if xbook input file corresponds to xbook in hlist */ boolean yasy; /* true if ybook input file corresponds to ybook in hlist */ boolean xasy; /* true if xbook input file corresponds to ybook in hlist */ boolean yasx; /* true if ybook input file corresponds to xbook in hlist */ gettitleline(xbook, ybook, hlist); findtitle(hlist); xasx = complines(xbook, hlist); findtitle(hlist); yasy = complines(ybook, hlist); gettitleline(xbook, ybook, hlist); findtitle(hlist); yasx = complines(ybook, hlist); findtitle(hlist); xasy = complines(xbook, hlist); if (!xasx) printf(" xbook input file does not correspond to xbook in hlist.\n"); if (!yasy) printf(" ybook input file does not correspond to ybook in hlist.\n"); if (xasy && !xasx) printf(" xbook input file corresponds to ybook in hlist.\n"); if (yasx && !yasy) printf(" ybook input file corresponds to xbook in hlist.\n"); if (xasy && yasx && !xasx && !yasy) printf(" xbook and ybook input files are reversed. try again.\n"); if (!(xasx && yasy)) halt(); } /* hlistvsbooks */ #define learnmax 16 /* the size of learnend */ /* end module hlistvsbooks */ /* ************************************************************************ */ /* begin module matrix.readmatrix */ Static Void findlearnend(pattern) _TEXT *pattern; { /* locate the end of the cyclic learning part of the pattern file */ /* this array contains the pattern that defines the end */ Char learnend[learnmax]; long state = 1; /* how close we are to finding learnend */ if (*pattern->name != '\0') { if (pattern->f != NULL) pattern->f = freopen(pattern->name, "r", pattern->f); else pattern->f = fopen(pattern->name, "r"); } else rewind(pattern->f); if (pattern->f == NULL) _EscIO2(FileNotFound, pattern->name); RESETBUF(pattern->f, Char); memcpy(learnend, "end of learning.", (long)learnmax); while (!BUFEOF(pattern->f) && state < learnmax) { if (learnend[state-1] == P_peek(pattern->f)) state++; else state = 1; if (P_eoln(pattern->f)) { fscanf(pattern->f, "%*[^\n]"); getc(pattern->f); } else getc(pattern->f); } if (!BUFEOF(pattern->f)) return; printf("pattern matrix does not contain \""); printf("%.*s\" signal\n", learnmax, learnend); halt(); } /* findlearnend */ #undef learnmax Static Void getcolon(f) _TEXT *f; { /* move to the next colon in file f */ while (P_peek(f->f) != ':') { getc(f->f); if (BUFEOF(f->f)) { printf("pattern is missing colons\n"); halt(); } } getc(f->f); /* move past the colon */ } /* getcolon */ Static Void readmatrix(thefile, wmatrix, beginning, width) _TEXT *thefile; long (*wmatrix)[maxmatrix]; long *beginning, *width; { /* read a pattern matrix wmatrix from the file thefile, returning the aligned position for the first position (beginning) and the width */ long i; /* an index */ base ba; /* an index */ long FORLIM; findlearnend(thefile); /* skip min and max values */ getcolon(thefile); getcolon(thefile); getcolon(thefile); /* skip to range */ fscanf(thefile->f, "%ld", beginning); /* read first position of the matrix */ getcolon(thefile); /* skip to width */ fscanf(thefile->f, "%ld", width); /* read width of the matrix */ if (*width > maxmatrix) { printf("input matrix too large\n"); halt(); } FORLIM = *width; for (i = 0; i < FORLIM; i++) { /* read in matrix */ getcolon(thefile); /* skip position label */ for (ba = a; (long)ba <= (long)t; ba = (base)((long)ba + 1)) fscanf(thefile->f, "%ld", &wmatrix[(long)ba][i]); fscanf(thefile->f, "%*[^\n]"); getc(thefile->f); } /* set all the unused elements of wmatrix to 0 */ for (i = *width; i < maxmatrix; i++) { for (ba = a; (long)ba <= (long)t; ba = (base)((long)ba + 1)) wmatrix[(long)ba][i] = 0; } } /* readmatrix */ /* end module matrix.readmatrix */ /* begin module matrix.readthresholds */ Static Void readthresholds(pattern, funcmin, nfuncmax) _TEXT *pattern; long *funcmin, *nfuncmax; { /* find the funcmin and nfuncmax of the pattern */ if (*pattern->name != '\0') { if (pattern->f != NULL) pattern->f = freopen(pattern->name, "r", pattern->f); else pattern->f = fopen(pattern->name, "r"); } else rewind(pattern->f); if (pattern->f == NULL) _EscIO2(FileNotFound, pattern->name); RESETBUF(pattern->f, Char); findlearnend(pattern); getcolon(pattern); fscanf(pattern->f, "%ld%*[^\n]", funcmin); getc(pattern->f); getcolon(pattern); fscanf(pattern->f, "%ld%*[^\n]", nfuncmax); getc(pattern->f); } /* readthresholds */ /* end module matrix.readthresholds */ /* ************************************************************************ */ /* ************************************************************************ */ Static Void demohistread() { /* a demonstration of the hist reading procedures */ readhist(&hst, &histmin, &histmax, &histwidth, &histbegin, &numseqs, &histo); printf(" the histogram has the following features:\n"); printf("%10ld is the minimum oligo searched for\n", histmin); printf("%10ld is the maximum oligo searched for\n", histmax); printf("%10ld is the width of the histogram\n", histwidth); printf("%10ld is the first position of the histogram\n", histbegin); printf("%10ld is the number of sequences analyzed\n", numseqs); } Static Void democompread() { /* a demonstration of the composition reading procedures */ comptotal *comptot; /* the linked list of composition totals */ readmax = 100; /* to be sure we pick all the composition */ readcomp(&cmp, &compmax, readmax, &root, &monocomptotal); printf(" the composition has the following features:\n"); printf("%10ld is the maximum length determined\n", compmax); printf(" the total number of oligos at each level, beginning with the monos, is:\n"); Malloc(sizeof(comptotal)); /* p2c: auxmod.p: Note: Eliminated unused assignment statement [338] */ comptot = monocomptotal; while (comptot != NULL) { printf("%10ld\n", comptot->count); comptot = comptot->next; } } Static Void demomatrixread() { /* a demonstration of the pattern matrix reading procedures */ long funcmin, nfuncmax; /* for readthresholds */ printf(" the pattern matrix has the following features:\n"); readmatrix(&patt, wmatrix, &beginning, &pattwidth); printf("%10ld is the width of the matrix\n", pattwidth); printf("%10ld is the first position of the matrix\n", beginning); readthresholds(&patt, &funcmin, &nfuncmax); printf("%10ld is the functional minimum\n", funcmin); printf("%10ld is the non-functional maximum\n", nfuncmax); } main(argc, argv) int argc; Char *argv[]; { PASCAL_MAIN(argc, argv); if (setjmp(_JL1)) goto _L1; patt.f = NULL; strcpy(patt.name, "patt"); cmp.f = NULL; strcpy(cmp.name, "cmp"); hst.f = NULL; strcpy(hst.name, "hst"); printf("% .5E\n", version); printf("library of auxiliary modules\n"); if (*hst.name != '\0') hst.f = fopen(hst.name, "r"); else rewind(hst.f); if (hst.f == NULL) _EscIO2(FileNotFound, hst.name); RESETBUF(hst.f, Char); putchar('\n'); if (!BUFEOF(hst.f)) demohistread(); else printf("demonstration of histogram reading requires non-empty hst file.\n"); if (*cmp.name != '\0') { if (cmp.f != NULL) cmp.f = freopen(cmp.name, "r", cmp.f); else cmp.f = fopen(cmp.name, "r"); } else { rewind(cmp.f); } if (cmp.f == NULL) _EscIO2(FileNotFound, cmp.name); RESETBUF(cmp.f, Char); putchar('\n'); if (!BUFEOF(cmp.f)) democompread(); else printf("demonstration of composition reading requires non-empty cmp file.\n"); if (*patt.name != '\0') { if (patt.f != NULL) patt.f = freopen(patt.name, "r", patt.f); else patt.f = fopen(patt.name, "r"); } else { rewind(patt.f); } if (patt.f == NULL) _EscIO2(FileNotFound, patt.name); RESETBUF(patt.f, Char); putchar('\n'); if (!BUFEOF(patt.f)) demomatrixread(); else printf("demonstration of matrix reading requires non-empty patt file. \n"); _L1: if (hst.f != NULL) fclose(hst.f); if (cmp.f != NULL) fclose(cmp.f); if (patt.f != NULL) fclose(patt.f); exit(EXIT_SUCCESS); } /* auxmod */ /* End. */