static struct annoRow *aswNextRow(struct annoStreamer *vSelf, char *minChrom, uint minEnd, struct lm *callerLm) /* Return an annoRow encoding the next chunk of wiggle data, or NULL if there are no more items. */ { struct annoStreamWig *self = (struct annoStreamWig *)vSelf; struct annoRow *rowOut = NULL; boolean done = FALSE; while (!done) { struct annoRow *wigRow = self->wigStr->nextRow(self->wigStr, minChrom, minEnd, callerLm); if (wigRow == NULL) return NULL; struct wiggle wiggle; wiggleStaticLoad((char **)wigRow->data, &wiggle); checkWibFile(self, wiggle.file); // translate wigRow + bytes to float vector boolean rightFail = FALSE; int validCount = 0; int bpLen = wiggle.chromEnd - wiggle.chromStart; float vector[bpLen]; getFloatArray(self, &wiggle, &rightFail, &validCount, vector); if (rightFail || validCount > 0) { rowOut = annoRowWigVecNew(wigRow->chrom, wigRow->start, wigRow->end, rightFail, vector, callerLm); done = TRUE; } } return rowOut; }
static struct annoRow *annoRowFromContigBbiIntervals(char *name, char *chrom, struct bbiInterval *startIv, struct bbiInterval *endIv, boolean rightJoinFail, struct lm *callerLm) /* Given a range of non-NULL contiguous bbiIntervals (i.e. no gaps between intervals), * translate into annoRow with annoVector as data. */ { float *vals; int baseCount = endIv->end - startIv->start; AllocArray(vals, baseCount); int vecOff = 0; struct bbiInterval *iv; for (iv = startIv; iv != endIv->next; iv = iv->next) { 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 annoRowWigVecNew(chrom, startIv->start, endIv->end, rightJoinFail, vals, callerLm); }