boolean anyCdnaSeq(char *name, struct dnaSeq **retDna, struct wormCdnaInfo *retInfo) /* Get a single cDNA sequence. Optionally (if retInfo is non-null) get additional * info about the sequence. */ { static FILE *cdnaFa; static struct snof *cdnaSnof = NULL; long offset; char *faComment; char **pFaComment = (retInfo == NULL ? NULL : &faComment); if (cdnaSnof == NULL) { char buf[512]; cdnaSnof = snofMustOpen(cdnaName); sprintf(buf, "%s%s", cdnaName, ".fa"); cdnaFa = mustOpen(buf, "rb"); } if (!snofFindOffset(cdnaSnof, name, &offset)) return FALSE; fseek(cdnaFa, offset, SEEK_SET); if (!faReadNext(cdnaFa, name, TRUE, pFaComment, retDna)) return FALSE; if (retInfo != NULL) { /* Kludge - only look up info if format is more or less right. */ int fieldCount = countChars(faComment, '|'); if (fieldCount >= 8) wormFaCommentIntoInfo(faComment, retInfo); else zeroBytes(retInfo, sizeof(*retInfo)); } return TRUE; }
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; }
static void wormCdnaCache() /* Set up to read cDNAs */ { getDirs(); if (cdnaSnof == NULL) { char buf[512]; sprintf(buf, "%s%s", cdnaDir, "allcdna"); cdnaSnof = snofMustOpen(buf); sprintf(buf, "%s%s", cdnaDir, "allcdna.fa"); cdnaFa = mustOpen(buf, "rb"); } }
static void wormCacheSomeGdf(struct wormGdfCache *cache) /* Cache one gene prediction set. */ { if (cache->snof == NULL) { char fileName[512]; char *dir; bits32 sig; getDirs(); dir = *(cache->pDir); sprintf(fileName, "%sgenes", dir); cache->snof = snofMustOpen(fileName); sprintf(fileName, "%sgenes.gdf", dir); cache->file = mustOpen(fileName, "rb"); mustReadOne(cache->file, sig); if (sig != glSig) errAbort("%s is not a good file", fileName); } }
boolean flyCdnaSeq(char *name, struct dnaSeq **retDna, struct wormCdnaInfo *retInfo) /* Get a single fly cDNA sequence. Optionally (if retInfo is non-null) get additional * info about the sequence. */ { long offset; char *faComment; char **pFaComment = (retInfo == NULL ? NULL : &faComment); static struct snof *cdnaSnof = NULL; static FILE *cdnaFa; if (cdnaSnof == NULL) cdnaSnof = snofMustOpen("c:/biodata/fly/cDna/allcdna"); if (cdnaFa == NULL) cdnaFa = mustOpen("c:/biodata/fly/cDna/allcdna.fa", "rb"); if (!snofFindOffset(cdnaSnof, name, &offset)) return FALSE; fseek(cdnaFa, offset, SEEK_SET); if (!faReadNext(cdnaFa, name, TRUE, pFaComment, retDna)) return FALSE; flyFaCommentIntoInfo(faComment, retInfo); return TRUE; }
boolean wormGeneRange(char *name, char **retChrom, char *retStrand, int *retStart, int *retEnd) /* Return chromosome position of a chrom range, gene, ORF, cosmid, or nameless cluster. */ { static struct snof *c2gSnof = NULL, *c2cSnof = NULL; static FILE *c2gFile = NULL, *c2cFile = NULL; long offset; char fileName[512]; struct slName *syn = NULL; boolean ok; if (wormIsChromRange(name)) { *retStrand = '.'; return wormParseChromRange(name, retChrom, retStart, retEnd); } getDirs(); /* Translate biologist type name to cosmid.N name */ if (wormIsGeneName(name)) { syn = wormGeneToOrfNames(name); if (syn != NULL) { name = syn->name; } } if (wormFixupOrfName(name)) /* See if ORF, and if so make nice. */ { if (c2gSnof == NULL) { sprintf(fileName, "%sc2g", featDir); c2gSnof = snofMustOpen(fileName); sprintf(fileName, "%sc2g", featDir); c2gFile = mustOpen(fileName, "rb"); } ok = findAltSpliceRange(name, c2gSnof, c2gFile, retChrom, retStart, retEnd, retStrand); } else /* Lets say it's a cosmid. */ { char lineBuf[128]; char *words[3]; int wordCount; touppers(name); if (c2cSnof == NULL) { sprintf(fileName, "%sc2c", featDir); c2cSnof = snofMustOpen(fileName); sprintf(fileName, "%sc2c", featDir); c2cFile = mustOpen(fileName, "rb"); } if (!snofFindOffset(c2cSnof, name, &offset) ) return FALSE; fseek(c2cFile, offset, SEEK_SET); mustGetLine(c2cFile, lineBuf, sizeof(lineBuf)); wordCount = chopLine(lineBuf, words); assert(wordCount == 3); assert(strcmp(words[2], name) == 0); assert(wormIsChromRange(words[0])); *retStrand = words[1][0]; ok = wormParseChromRange(words[0], retChrom, retStart, retEnd); } slFreeList(&syn); return ok; }