ead294ac0ef6c54887676ac1fcb06172d3c71d9f braney Wed May 18 17:23:00 2022 -0700 first cut at sequence logo with four bases diff --git src/hg/hgTracks/wigTrack.c src/hg/hgTracks/wigTrack.c index 1563fd6..16782fc 100644 --- src/hg/hgTracks/wigTrack.c +++ src/hg/hgTracks/wigTrack.c @@ -1198,31 +1198,31 @@ Color clipColor = MG_MAGENTA; WigVerticalLineVirtual vLine = wgo->vLine; void *image = wgo->image; #define doLine(image, x, y, height, color) {vLine(image, x, y, height, color); } int h = tg->lineHeight; /* the height of our drawing window */ double scaleFactor = h/graphRange; struct wigMouseOver *mouseOverData = getMouseOverData(tg, preDraw, width, xOff, preDrawZero); double xIncr = (double)width / numBases; unsigned baseNum; for(baseNum = 0; baseNum < numBases; baseNum++) { int x1 = ceil(baseNum * xIncr); int x = x1 + xOff; - int width = xIncr; + int baseWidth = xIncr; int base = seq->dna[baseNum]; int preDrawIndex = x1 + preDrawZero; struct preDrawElement *p = &preDraw[preDrawIndex]; assert(x1/pixelBins->binSize < pixelBins->binCount); unsigned long *bitCount = &pixelBins->bins[x1/pixelBins->binSize]; /* count is non-zero meaning valid data exists here */ if (p->count) { /* data value has been picked by previous scanning. * Could be smoothed, maybe not. */ double dataValue = p->smooth; @@ -1262,58 +1262,64 @@ if (numTrack > 0) { y0 = (graphUpperLimit - yOffsets[(numTrack-1) * width + x1]) *scaleFactor; y1 = (graphUpperLimit - dataValue - yOffsets[(numTrack-1) * width + x1])*scaleFactor; } } int boxHeight = max(1,abs(y1 - y0)); int boxTop = min(y1,y0); // positive data value exactly equal to Bottom pixel // make sure it draws at least a pixel there if (boxTop == h) boxTop = h - 1; + if (tg->tdb->parent && startsWith("multiWig", trackDbSetting(tg->tdb->parent,"container"))) + { + switch(numTrack) + { + case 3: base='a';break; + case 2: base='c';break; + case 1: base='g';break; + case 0: base='t';break; + } + } char string[2]; string[0] = toupper(base); string[1] = 0; MgFont *font = tl.font; int height = dataValue * scaleFactor; unsigned color = MG_BLACK; if (base == 'a') color = MG_RED; else if (base == 't') color = MG_GREEN; else if (base == 'c') color = MG_BROWN; else if (base == 'g') color = MG_BLUE; if (height != 0) { if (dataValue < 0) { - // useful for debug, fills a box where letter goes - // hvGfxBox(hvg, x, yOff+graphUpperLimit * scaleFactor, width, -height, MG_BLACK); - hvGfxTextInBox(hvg, x, yOff+graphUpperLimit * scaleFactor, width - 1, height, + hvGfxTextInBox(hvg, x, yOff+boxTop, baseWidth - 1, -boxHeight, color, font, string); } else { - // useful for debug, fills a box where letter goes - // hvGfxBox(hvg, x, yOff-height+graphUpperLimit * scaleFactor, width, height, MG_BLACK); - hvGfxTextInBox(hvg, x, yOff-height+graphUpperLimit * scaleFactor, width - 1, height, + hvGfxTextInBox(hvg, x, yOff+boxTop, baseWidth - 1, boxHeight, color, font, string); } } if (((boxTop+boxHeight) == 0) && !isnan(dataValue)) boxHeight += 1; } double stackValue = dataValue; if ((yOffsets != NULL) && (numTrack > 0)) stackValue += yOffsets[(numTrack-1) * width + x1]; if (stackValue > graphUpperLimit) { doLine(image, x, yOff, 2, clipColor); } else if (stackValue < graphLowerLimit)