0544059f3df004f2d54e8978809ddfcbdee23645 braney Mon Feb 25 14:36:53 2013 -0800 modify twoBit library to auto-recognize whether it's dealing with a URL or local file (per code review #10237) diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c index ed2bccf..7b8eba9 100644 --- src/hg/lib/hdb.c +++ src/hg/lib/hdb.c @@ -992,105 +992,88 @@ 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 *fetchTwoBitSeqExt(char *fileName, char *seqName, int start, int end, boolean useUdc) +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 = twoBitOpenExt(fileName, useUdc); + tbf = twoBitOpen(fileName); } struct dnaSeq *seq = twoBitReadSeqFrag(tbf, seqName, start, end); return seq; } -static struct dnaSeq *fetchTwoBitSeq(char *fileName, char *seqName, int start, int end) -/* fetch a sequence from a 2bit, caching open of the file */ -{ -return fetchTwoBitSeqExt(fileName, seqName, start, end, FALSE); -} - struct dnaSeq *hFetchSeqMixed(char *fileName, char *seqName, int start, int end) /* Fetch mixed case sequence. */ { if (twoBitIsFile(fileName)) return fetchTwoBitSeq(fileName, seqName, start, end); else return nibLoadPartMasked(NIB_MASK_MIXED, fileName, start, end-start); } struct dnaSeq *hFetchSeq(char *fileName, char *seqName, int start, int end) /* Fetch sequence from file. If it is a .2bit file then fetch the named sequence. If it is .nib then just ignore seqName. */ { if (twoBitIsFile(fileName)) { 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); -if(trackHubDatabase(db)) - { - struct dnaSeq *seq = fetchTwoBitSeqExt(fileName, chrom, start, end, TRUE); - return seq; - } 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); -if(trackHubDatabase(db)) - { - struct dnaSeq *seq = fetchTwoBitSeqExt(fileName, chrom, start, end, TRUE); - tolowers(seq->dna); - return seq; - } 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. */