0c1d13ef4e3214c4029e098ed5ef708d15e6096f max Mon Nov 21 16:34:53 2016 -0800 CIRM: As per Jim: adding the trackDb tag 'bigDataIndex'. It allows to specify the URL of the .tbi or .bai file, in case you cannot put it alongside the .bam or .vcf.gz file. diff --git src/lib/linefile.c src/lib/linefile.c index a307f36..eeeefed 100644 --- src/lib/linefile.c +++ src/lib/linefile.c @@ -200,40 +200,55 @@ * is closed. */ { struct lineFile *lf; AllocVar(lf); lf->fileName = cloneString(name); lf->fd = -1; lf->bufSize = lf->bytesInBuf = strlen(s); lf->zTerm = zTerm; lf->buf = s; return lf; } struct lineFile *lineFileTabixMayOpen(char *fileOrUrl, bool zTerm) /* Wrap a line file around a data file that has been compressed and indexed - * by the tabix command line program. The index file <fileOrUrl>.tbi must be - * readable in addition to fileOrUrl. If there's a problem, warn & return NULL. + * by the tabix command line program. <fileOrUrl>.tbi must be readable in + * addition to fileOrUrl. If there's a problem, warn & return NULL. This works + * only if kent/src has been compiled with USE_TABIX=1 and linked + * with the tabix C library. */ +{ +return lineFileTabixAndIndexMayOpen(fileOrUrl, NULL, zTerm); +} + + +struct lineFile *lineFileTabixAndIndexMayOpen(char *fileOrUrl, char *tbiFileOrUrl, bool zTerm) +/* Wrap a line file around a data file that has been compressed and indexed + * by the tabix command line program. tbiFileOrUrl can be NULL, it defaults to <fileOrUrl>.tbi. + * It must be readable in addition to fileOrUrl. If there's a problem, warn & return NULL. * This works only if kent/src has been compiled with USE_TABIX=1 and linked * with the tabix C library. */ { if (fileOrUrl == NULL) errAbort("lineFileTabixMayOpen: fileOrUrl is NULL"); -int tbiNameSize = strlen(fileOrUrl) + strlen(".tbi") + 1; -char tbiName[tbiNameSize]; + +char tbiName[4096]; +if (tbiFileOrUrl==NULL) safef(tbiName, sizeof(tbiName), "%s.tbi", fileOrUrl); +else + safef(tbiName, sizeof(tbiName), "%s", tbiFileOrUrl); + htsFile *htsFile = hts_open(fileOrUrl, "r"); if (htsFile == NULL) { warn("Unable to open \"%s\"", fileOrUrl); return NULL; } tbx_t *tabix; if ((tabix = tbx_index_load2(fileOrUrl, tbiName)) == NULL) { warn("Unable to load tabix index from \"%s\"", tbiName); if (tabix) ti_close(tabix); tabix = NULL; return NULL; }