void wormCdnaUncache() /* Tear down structure for reading cDNAs. */ { snofClose(&cdnaSnof); carefulClose(&cdnaFa); freez(&cdnaDir); }
struct xaAli *getOneXaAli(char *organism, char *xaName) /* Return a single named xaAli for organism. */ { char ixFileName[512]; char dataFileName[512]; char *xDir; struct snof *snof; long offset; FILE *f; struct xaAli *xa; xDir = wormXenoDir(); sprintf(ixFileName, "%s%s/all", xDir, organism); sprintf(dataFileName, "%s%s/all%s", xDir, organism, xaAlignSuffix()); snof = snofMustOpen(ixFileName); if (!snofFindOffset(snof, xaName, &offset)) errAbort("Couldn't find %s", xaName); snofClose(&snof); f = xaOpenVerify(dataFileName); fseek(f, offset, SEEK_SET); xa = xaReadNext(f, FALSE); fclose(f); return xa; }
struct snof *snofOpen(char *indexName) /* Open up the index file. Returns NULL if there's any problem. */ { struct snof *snof; int sigBuf[4]; FILE *f; char fileName[512]; if (!makeSnofName(fileName, indexName)) return NULL; if ((snof = needMem(sizeof(*snof))) == NULL) return NULL; if ((snof->file = f = fopen(fileName, "rb")) == NULL) { freeMem(snof); return NULL; } if ((fread(sigBuf, sizeof(sigBuf), 1, f)) != 1) { snofClose(&snof); return NULL; } if (!isSnofSig(&sigBuf)) { snofClose(&snof); return NULL; } if ((fread(&snof->maxNameSize, sizeof(snof->maxNameSize), 1, f)) != 1) { snofClose(&snof); return NULL; } snof->headSize = ftell(f); snof->itemSize = snof->maxNameSize + sizeof(unsigned); if ((snof->first = needMem(5*snof->itemSize)) == NULL) { snofClose(&snof); return NULL; } snof->last = snof->first + snof->itemSize; snof->less = snof->last + snof->itemSize; snof->mid = snof->less + snof->itemSize; snof->more = snof->mid + snof->itemSize; if (fread(snof->first, snof->itemSize, 1, f) != 1) { snofClose(&snof); return NULL; } fseek(f, -snof->itemSize, SEEK_END); snof->endIx = (ftell(f)-snof->headSize)/snof->itemSize; if (fread(snof->last, snof->itemSize, 1, f) != 1) { snofClose(&snof); return NULL; } return snof; }
void wormUncacheSomeGdf(struct wormGdfCache *cache) /* Uncache some gene prediction set. */ { snofClose(&cache->snof); carefulClose(&cache->file); }