5af25d5af09cf586acbcf1c8a54d175deede25e7 braney Thu Jun 23 15:07:49 2016 -0700 some tweaks in response to code review with Jonathan. diff --git src/lib/bedTabix.c src/lib/bedTabix.c index dcd0c10..d9a28a2 100644 --- src/lib/bedTabix.c +++ src/lib/bedTabix.c @@ -1,34 +1,46 @@ #include "bedTabix.h" struct bedTabixFile *bedTabixFileMayOpen(char *fileOrUrl, char *chrom, int start, int end) +/* Open a bed file that has been compressed and indexed by tabix */ { struct lineFile *lf = lineFileTabixMayOpen(fileOrUrl, TRUE); if (lf == NULL) return NULL; struct bedTabixFile *btf; AllocVar(btf); btf->lf = lf; if (isNotEmpty(chrom) && start != end) { lineFileSetTabixRegion(lf, chrom, start, end); } return btf; } +struct bedTabixFile *bedTabixFileOpen(char *fileOrUrl, char *chrom, int start, int end) +/* Attempt to open bedTabix file. errAbort on failure. */ +{ +struct bedTabixFile *btf = bedTabixFileMayOpen(fileOrUrl, chrom, start, end); + +if (btf == NULL) + errAbort("Cannot open bed tabix file %s\n", fileOrUrl); + +return btf; +} + struct bed *bedTabixReadFirstBed(struct bedTabixFile *btf, char *chrom, int start, int end, struct bed * (*loadBed)(void *tg)) /* Read in first bed in range (for next item).*/ { int wordCount; char *words[100]; if (!lineFileSetTabixRegion(btf->lf, chrom, start, end)) return NULL; if ((wordCount = lineFileChopTab(btf->lf, words)) > 0) return loadBed(words); return NULL; } struct bed *bedTabixReadBeds(struct bedTabixFile *btf, char *chrom, int start, int end, struct bed * (*loadBed)(void *tg)) /* Read in all beds in range.*/