8c908f948b09826c6cb4452ee5b282aca41be85e galt Tue Dec 8 21:52:59 2015 -0800 Multi-region (exonMostly). This work allows people to look at virtual chromosomes from a list of regions and then navigate and perform all of the usual functions on it. diff --git src/hg/hgTracks/bedTrack.c src/hg/hgTracks/bedTrack.c index 5b6c92d..0109d23 100644 --- src/hg/hgTracks/bedTrack.c +++ src/hg/hgTracks/bedTrack.c @@ -517,31 +517,31 @@ color = tg->colorShades[grayInRange(bed->score, scoreMin, scoreMax)]; } /* Keep the item at least 4 pixels wide at all viewpoints */ if (thickDrawItem && (w < 4)) { x1 -= ((5-w) >> 1); w = 4; x2 = x1 + w; } if (color) { hvGfxBox(hvg, x1, y, w, heightPer, color); if (tg->drawLabelInBox) { char *label = tg->itemName(tg, bed); - drawScaledBoxSampleLabel(hvg, s, e, scale, xOff, y, heightPer, color, font, label); + drawScaledBoxLabel(hvg, s, e, scale, xOff, y, heightPer, color, font, label); } else if (tg->drawName && vis != tvSquish) { /* Clip here so that text will tend to be more visible... */ char *s = tg->itemName(tg, bed); w = x2-x1; if (w > mgFontStringWidth(font, s)) { Color textColor = hvGfxContrastingColor(hvg, color); hvGfxTextCentered(hvg, x1, y, w, heightPer, textColor, font, s); } mapBoxHgcOrHgGene(hvg, bed->chromStart, bed->chromEnd, x1, y, x2 - x1, heightPer, tg->track, tg->mapItemName(tg, bed), NULL, directUrl, withHgsid, NULL); } } @@ -611,58 +611,79 @@ int bedItemEnd(struct track *tg, void *item) /* Return end position of item. */ { struct bed *bed = item; return bed->chromEnd; } void freeSimpleBed(struct track *tg) /* Free the beds in a track group that has beds as its items. */ { bedFreeList(((struct bed **)(&tg->items))); } -void simpleBedNextPrevEdge(struct track *tg, struct hvGfx *hvg, void *item, int x, int y, int w, +boolean simpleBedNextPrevEdge(struct track *tg, struct hvGfx *hvg, void *item, int x, int y, int w, int h, boolean next) /* Like linkedFeaturesNextPrevItem, but for simple bed which has no block structure so * this simply zaps us to the right/left edge of the feature. Arrows have already been * drawn; here we figure out coords and draw a mapBox. */ { +boolean result = FALSE; struct bed4 *bed = item; char *mouseOverText = NULL; if (next) mouseOverText = trackDbSettingClosestToHomeOrDefault(tg->tdb, "nextExonText", revCmplDisp ? "Left Edge" : "Right Edge"); else mouseOverText = trackDbSettingClosestToHomeOrDefault(tg->tdb, "prevExonText", revCmplDisp ? "Right Edge" : "Left Edge"); int winSize = winEnd - winStart; int bufferToEdge = 0.05 * winSize; int newWinStart, newWinEnd; if (next) { newWinEnd = bed->chromEnd + bufferToEdge; newWinStart = newWinEnd - winSize; } else { newWinStart = bed->chromStart - bufferToEdge; newWinEnd = newWinStart + winSize; } -mapBoxJumpTo(hvg, x, y, w, h, tg, chromName, newWinStart, newWinEnd, mouseOverText); +struct convertRange *cr=NULL; +AllocVar(cr); +if (( next && newWinEnd > winStart) + || (!next && newWinStart < winEnd )) + { + cr->start = newWinStart; + cr->end = newWinEnd; + } +else + { + cr->skipIt = TRUE; + } +linkedFeaturesNextPrevExonFind(tg, next, cr); +long newVirtWinStart = cr->vStart; +long newVirtWinEnd = cr->vEnd; +if (newVirtWinStart != -1) // found it + { + mapBoxJumpTo(hvg, x, y, w, h, tg, virtChromName, newVirtWinStart, newVirtWinEnd, mouseOverText); + result = TRUE; + } +return result; } void bedMethods(struct track *tg) /* Fill in methods for (simple) bed tracks. */ { tg->drawItems = bedDrawSimple; tg->drawItemAt = bedDrawSimpleAt; tg->itemName = bedName; tg->mapItemName = bedName; tg->totalHeight = tgFixedTotalHeightNoOverflow; tg->itemHeight = tgFixedItemHeight; tg->itemStart = bedItemStart; tg->itemEnd = bedItemEnd; // Adding "tg->nextPrevExon = simpleBedNextPrevEdge;" opened a can of worms: too many // bed-based tracks have their own drawItems methods that don't hook into nextItem stuff,