946ad6602b09a56d6ccc661a0bfc84de9c345eac cline Fri Sep 23 15:26:25 2011 -0700 Updated the process of building the kegg pathway tables, modeling after what Fan did for hg19 diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c index e449473..d102a9e 100644 --- src/hg/lib/hdb.c +++ src/hg/lib/hdb.c @@ -941,30 +941,49 @@ if (!fileExists(retNibName)) { /* if 2bit file isn't there, try up one directory */ safef(retNibName, HDB_MAX_PATH_STRING, "%s/../%s.2bit", hDbDbNibPath(db), db); if (!fileExists(retNibName)) { /* still no 2bit, let's just try to find a nib */ safef(retNibName, HDB_MAX_PATH_STRING, "%s/%s.nib", hDbDbNibPath(db), chromName); } } } } +void hNibForChromFromPath(char *nibPath, char *db, char *chromName, + char retNibName[HDB_MAX_PATH_STRING]) +/* Get .nib file associated with chromosome, given a nib file path. */ +{ +safef(retNibName, HDB_MAX_PATH_STRING, "%s/%s.2bit", nibPath, db); +if (!fileExists(retNibName)) + { + /* if 2bit file isn't there, try up one directory */ + safef(retNibName, HDB_MAX_PATH_STRING, "%s/../%s.2bit", + nibPath, db); + if (!fileExists(retNibName)) + { + /* still no 2bit, let's just try to find a nib */ + safef(retNibName, HDB_MAX_PATH_STRING, "%s/%s.nib", + nibPath, chromName); + } + } +} + static struct dnaSeq *fetchTwoBitSeq(char *fileName, char *seqName, int start, int end) /* fetch a sequence from a 2bit, caching open of the file */ { static struct twoBitFile *tbf = NULL; // cache of open file if ((tbf == NULL) || !sameString(fileName, tbf->fileName)) { twoBitClose(&tbf); tbf = twoBitOpen(fileName); } struct dnaSeq *seq = twoBitReadSeqFrag(tbf, seqName, start, end); return seq; } struct dnaSeq *hFetchSeqMixed(char *fileName, char *seqName, int start, int end) /* Fetch mixed case sequence. */ @@ -984,38 +1003,57 @@ struct dnaSeq *seq = fetchTwoBitSeq(fileName, seqName, start, end); tolowers(seq->dna); return seq; } return nibLoadPart(fileName, start, end-start); } struct dnaSeq *hChromSeqMixed(char *db, char *chrom, int start, int end) /* Return mixed case (repeats in lower case) DNA from chromosome. */ { char fileName[HDB_MAX_PATH_STRING]; hNibForChrom(db, chrom, fileName); return hFetchSeqMixed(fileName, chrom, start, end); } +struct dnaSeq *hChromSeqMixedFromPath(char *nibPath, char *db, char *chrom, + int start, int end) +/* Return mixed case (repeats in lower case) DNA from chromosome, given an + * input nib path. */ +{ +char fileName[HDB_MAX_PATH_STRING]; +hNibForChromFromPath(nibPath, db, chrom, fileName); +return hFetchSeqMixed(fileName, chrom, start, end); +} + struct dnaSeq *hChromSeq(char *db, char *chrom, int start, int end) /* Return lower case DNA from chromosome. */ { char fileName[HDB_MAX_PATH_STRING]; hNibForChrom(db, chrom, fileName); return hFetchSeq(fileName, chrom, start, end); } +struct dnaSeq *hChromSeqFromPath(char *nibPath, char *db, char *chrom, + int start, int end) +/* Return lower case DNA from chromosome. */ +{ +char fileName[HDB_MAX_PATH_STRING]; +hNibForChromFromPath(nibPath, db, chrom, fileName); +return hFetchSeq(fileName, chrom, start, end); +} + struct dnaSeq *hSeqForBed(char *db, struct bed *bed) /* Get the sequence associated with a particular bed concatenated together. */ { char fileName[HDB_MAX_PATH_STRING]; struct dnaSeq *block = NULL; struct dnaSeq *bedSeq = NULL; int i = 0 ; assert(bed); /* Handle very simple beds and beds with blocks. */ if(bed->blockCount == 0) { bedSeq = hChromSeq(db, bed->chrom, bed->chromStart, bed->chromEnd); freez(&bedSeq->name); bedSeq->name = cloneString(bed->name); }