ea5b4301814c1df9f2a0f3b2d9e0d2f06b22635e braney Tue May 24 18:37:10 2016 -0700 hgTables support , some display changes, and a better hgc page for longTabix diff --git src/hg/hgTracks/longRangeTrack.c src/hg/hgTracks/longRangeTrack.c index d799093..65acb98 100644 --- src/hg/hgTracks/longRangeTrack.c +++ src/hg/hgTracks/longRangeTrack.c @@ -21,59 +21,69 @@ { double scale = scaleForWindow(width, seqStart, seqEnd); struct bed *beds = tg->items; unsigned int maxWidth; struct longRange *longRange; char buffer[1024]; safef(buffer, sizeof buffer, "%s.%s", tg->tdb->track, LONG_MINSCORE); double minScore = sqlDouble(cartUsualString(cart, buffer, LONG_DEFMINSCORE)); struct longRange *longRangeList = parseLongTabix(beds, &maxWidth, minScore); for(longRange=longRangeList; longRange; longRange=longRange->next) { if (sameString(longRange->sChrom, longRange->eChrom)) { - int sx = (longRange->s - seqStart) * scale + xOff; - int ex = (longRange->e - seqStart) * scale + xOff; - double longRangeWidth = longRange->e - longRange->s; - int height = (tg->height - 15) * ((double)longRangeWidth / maxWidth) + yOff + 10; - int tsx = sx; - int tex = ex; + boolean sOnScreen = (longRange->s >= seqStart) && (longRange->s < seqEnd); + boolean eOnScreen = (longRange->e >= seqStart) && (longRange->e < seqEnd); - if (tsx > tex) - { - tsx = sx; - tex = ex; - } + if (!(sOnScreen || eOnScreen)) + continue; + + unsigned sx, ex; + if (sOnScreen) + sx = (longRange->s - seqStart) * scale + xOff; + if (eOnScreen) + ex = (longRange->e - seqStart) * scale + xOff; - hvGfxLine(hvg, sx, yOff, tsx, height, color); - hvGfxLine(hvg, ex, yOff, tex, height, color); + double longRangeWidth = longRange->e - longRange->s; + int peak = (tg->height - 15) * ((double)longRangeWidth / maxWidth) + yOff + 10; + + if (sOnScreen) + hvGfxLine(hvg, sx, yOff, sx, peak, color); + if (eOnScreen) + hvGfxLine(hvg, ex, yOff, ex, peak, color); if (tg->visibility == tvFull) { - hvGfxLine(hvg, tsx, height, tex, height, color); + unsigned sPeak = sOnScreen ? sx : xOff; + unsigned ePeak = eOnScreen ? ex : xOff + width; + + hvGfxLine(hvg, sPeak, peak, ePeak, peak, color); char statusBuf[2048]; - safef(statusBuf, sizeof statusBuf, "%g %s:%d", longRange->score, longRange->eChrom, longRange->e); + safef(statusBuf, sizeof statusBuf, "%g %s:%d %s:%d", longRange->score, longRange->sChrom, longRange->s, longRange->eChrom, longRange->e); char itemBuf[2048]; safef(itemBuf, sizeof itemBuf, "%d", longRange->id); - mapBoxHgcOrHgGene(hvg, longRange->s, longRange->e,tsx, height-2, tex-tsx, 4, + if (sOnScreen) + mapBoxHgcOrHgGene(hvg, longRange->s, longRange->e, sx - 2, yOff, 4, peak - yOff, tg->track, itemBuf, statusBuf, NULL, TRUE, NULL); - mapBoxHgcOrHgGene(hvg, longRange->s, longRange->e,tsx - 2, yOff, 4, height - yOff, + if (eOnScreen) + mapBoxHgcOrHgGene(hvg, longRange->s, longRange->e, ex - 2, yOff, 4, peak - yOff, tg->track, itemBuf, statusBuf, NULL, TRUE, NULL); - mapBoxHgcOrHgGene(hvg, longRange->s, longRange->e,tex - 2, yOff, 4, height - yOff, + + mapBoxHgcOrHgGene(hvg, longRange->s, longRange->e, sPeak, peak-2, ePeak - sPeak, 4, tg->track, itemBuf, statusBuf, NULL, TRUE, NULL); } } } } void longRangeDrawLeftLabels(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) { } void longRangeMethods(struct track *tg, struct trackDb *tdb)