c0e6b7bbd33d78d546f6db582b56cab219f32536 angie Wed Aug 5 11:41:25 2015 -0700 Fixed a bug that caused us to quit after the first chrom in whole-genome mode. That required using a different method to tell when we're done querying for region mode. fixes #15813 diff --git src/lib/annoStreamBigWig.c src/lib/annoStreamBigWig.c index 8f8298f..c3681e8 100644 --- src/lib/annoStreamBigWig.c +++ src/lib/annoStreamBigWig.c @@ -110,61 +110,68 @@ int i; for (i = 0; i < (iv->end - iv->start); i++) vals[vecOff++] = iv->val; if (vecOff > baseCount) errAbort("annoStreamBigWig %s: overflowed baseCount (%s:%d-%d)", name, chrom, startIv->start, endIv->end); } return annoRowWigNew(chrom, startIv->start, endIv->end, rightJoinFail, vals, callerLm); } static struct annoRow *asbwNextRow(struct annoStreamer *sSelf, char *minChrom, uint minEnd, struct lm *callerLm) /* Return a single annoRow, or NULL if there are no more items. */ { struct annoStreamBigWig *self = (struct annoStreamBigWig *)sSelf; -if (self->intervalList == NULL) +if (self->eof) + return NULL; +else if (self->nextInterval == NULL) + { asbwDoQuery(self, minChrom, minEnd); -if (self->nextInterval == NULL) + if (self->eof) return NULL; + } // Skip past any left-join failures until we get a right-join failure, a passing interval, or EOF. boolean rightFail = FALSE; struct bbiInterval *startIv = self->nextInterval; while (annoFilterWigValueFails(sSelf->filters, self->nextInterval->val, &rightFail)) { if (rightFail) break; startIv = self->nextInterval = self->nextInterval->next; if (self->nextInterval == NULL) return NULL; } char *chrom = sSelf->chrom ? sSelf->chrom : self->queryChrom->name; if (rightFail) return annoRowFromContigBbiIntervals(sSelf->name, chrom, startIv, startIv, rightFail, callerLm); +// Collect up to maxCount contiguous intervals; then make annoRow with vector. struct bbiInterval *endIv = startIv, *iv; int maxCount = 16 * 1024, count; for (iv = startIv->next, count = 0; iv != NULL && count < maxCount; iv = iv->next, count++) { - // collect contiguous intervals; then make annoRow with vector. if (annoFilterWigValueFails(sSelf->filters, iv->val, &rightFail)) break; if (iv->start == endIv->end) endIv = iv; else break; } +// If there's a query region and we have reached the end of its intervals, we're done. +if (sSelf->chrom != NULL && endIv->next == NULL) + self->eof = TRUE; self->nextInterval = endIv->next; return annoRowFromContigBbiIntervals(sSelf->name, chrom, startIv, endIv, rightFail, callerLm); } static void asbwClose(struct annoStreamer **pVSelf) /* Close bbi handle and free self. */ { if (pVSelf == NULL) return; struct annoStreamBigWig *self = *(struct annoStreamBigWig **)pVSelf; bigWigFileClose(&(self->bbi)); self->intervalList = NULL; lmCleanup(&(self->intervalQueryLm)); annoStreamerFree(pVSelf); }