b18dedbef637679fdf72b86f2243954fa302aa1e braney Mon Apr 8 14:54:46 2019 -0700 deal with NO_DATA situation in left labels of lollipops. Move the bigBed diff --git src/hg/hgTracks/lolly.c src/hg/hgTracks/lolly.c index 895599d..3b4c7f7 100644 --- src/hg/hgTracks/lolly.c +++ src/hg/hgTracks/lolly.c @@ -69,30 +69,38 @@ void lollyLeftLabels(struct track *tg, int seqStart, int seqEnd, struct hvGfx *hvg, int xOff, int yOff, int width, int height, boolean withCenterLabels, MgFont *font, Color color, enum trackVisibility vis) { int fontHeight = tl.fontHeight+1; int centerLabel = (height/2)-(fontHeight/2); if ( tg->visibility == tvDense) { hvGfxText(hvg, xOff, yOff+fontHeight, color, font, tg->shortLabel); return; } hvGfxText(hvg, xOff, yOff+centerLabel, color, font, tg->shortLabel); + +if (isnan(tg->lollyCart->upperLimit)) + { + hvGfxTextRight(hvg, xOff, yOff + 2 * 5 , width - 1, fontHeight, color, + font, "NO DATA"); + return; + } + char upper[1024]; safef(upper, sizeof(upper), "%g -", tg->lollyCart->upperLimit); hvGfxTextRight(hvg, xOff, yOff + 2 * 5 , width - 1, fontHeight, color, font, upper); char lower[1024]; if (tg->lollyCart->lowerLimit < tg->lollyCart->upperLimit) { safef(lower, sizeof(lower), "%g _", tg->lollyCart->lowerLimit); hvGfxTextRight(hvg, xOff, yOff+height-fontHeight - 2 * 5, width - 1, fontHeight, color, font, lower); } } static int lollyHeight(struct track *tg, enum trackVisibility vis) @@ -128,32 +136,30 @@ void lollyLoadItems(struct track *tg) { struct lm *lm = lmInit(0); struct bbiFile *bbi = fetchBbiForTrack(tg); struct bigBedInterval *bb, *bbList = bigBedIntervalQuery(bbi, chromName, winStart, winEnd, 0, lm); char *bedRow[bbi->fieldCount]; char startBuf[16], endBuf[16]; struct lolly *popList = NULL, *pop; unsigned lollyField = 5; struct lollyCartOptions *lollyCart = tg->lollyCart; char *setting = trackDbSetting(tg->tdb, "lollyField"); if (setting != NULL) lollyField = atoi(setting); double minVal = DBL_MAX, maxVal = -DBL_MAX; - - double sumData = 0.0, sumSquares = 0.0; unsigned count = 0; int trackHeight = tg->lollyCart->height; struct bigBedFilter *filters = bigBedBuildFilters(cart, bbi, tg->tdb); for (bb = bbList; bb != NULL; bb = bb->next) { bigBedIntervalToRow(bb, chromName, startBuf, endBuf, bedRow, ArraySize(bedRow)); if (!bigBedFilterInterval(bedRow, filters)) continue; double val = atof(bedRow[lollyField - 1]); if (!((lollyCart->autoScale == wiggleScaleAuto) || ((val >= lollyCart->minY) && (val <= lollyCart->maxY) ))) @@ -162,32 +168,38 @@ AllocVar(pop); slAddHead(&popList, pop); pop->val = val; pop->start = atoi(bedRow[1]); pop->end = atoi(bedRow[2]); pop->name = cloneString(bedRow[3]); count++; sumData += val; sumSquares += val * val; if (val > maxVal) maxVal = val; if (val < minVal) minVal = val; } +if (count == 0) + tg->lollyCart->upperLimit = tg->lollyCart->lowerLimit = NAN; +else + { tg->lollyCart->upperLimit = maxVal; tg->lollyCart->lowerLimit = minVal; + } + double range = maxVal - minVal; int usableHeight = trackHeight - 2 * 5 * 2; for(pop = popList; pop; pop = pop->next) { pop->radius = 5; pop->color = MG_RED; if (range == 0.0) { pop->height = usableHeight ; pop->color = lollyPalette[0] | 0xff000000; } else { pop->height = usableHeight * (pop->val - minVal) / range + 5 * 2; int colorIndex = 8 * (pop->val - minVal) / range;