bfdef4b81463c8e17b972da81c3fa7d94118af22 kate Wed Oct 10 14:04:37 2018 -0700 Cleanup. diff --git src/hg/hgTracks/interactTrack.c src/hg/hgTracks/interactTrack.c index ecf21f5..6994269 100644 --- src/hg/hgTracks/interactTrack.c +++ src/hg/hgTracks/interactTrack.c @@ -145,69 +145,68 @@ return (struct interactLfEndNames *)lf->original; } void interactFreeItems(struct track *tg) /* Free up interact items track */ { interactFreeList((struct interact **)(&tg->items)); } static struct linkedFeatures *interactToLf(struct interact *inter, boolean doColor) /* Convert interact BED to linkedFeatures */ { struct bed *bed = interactToBed(inter); struct linkedFeatures *lf = lfFromBed(bed); -// save source and target names to extra field of linked feature, so we can display them in pack mode +// save source and target names to extra field of linked feature, so we can display them +// in pack mode // TODO: code to free setInteractLfEndNames(lf, cloneString(inter->sourceName), cloneString(inter->targetName)); // not sure why this is needed -- lfFromBed seems to reorder blocks, sometimes ? linkedFeaturesSortAndBound(lf); if (doColor) { lf->extra = (void *)USE_ITEM_RGB; /* signal for coloring */ lf->filterColor = bed->itemRgb; } bedFree(&bed); -// TODO: use lfFromBedExtra with scoreMin, scoreMax ? return lf; } static boolean isLinkedFeaturesMode(struct track *tg) /* Determine if linked feature display will be used */ { return (tg->visibility != tvFull); } int interactSize(struct interact *inter) /* Compute length of interaction (distance between middle of each region) in bp */ { int sourceCenter = 0, targetCenter = 0; interactRegionCenters(inter, &sourceCenter, &targetCenter); return abs(targetCenter - sourceCenter); } int getX(int pos, int seqStart, double scale, int xOff) /* Get x coordinate of a genomic location. Return -1 if off-screen */ { if (pos < seqStart) return -1; return ((double)(pos - seqStart + .5) * scale) + xOff; } - static void setYOff(struct track *tg, int yOff) /* Stash y offset for this track */ { tg->customInt = yOff; } static int getYOff(struct track *tg) /* Get y offset for this track (stashed by DrawItems) */ { return tg->customInt; } static int flipY(struct track *tg, int y) /* Invert y coordinate if flipped display is requested */ { @@ -286,39 +285,30 @@ struct interactLfEndNames *ends = getInteractLfEndNames(lf); char *rightLabel = ends->target; if (lf->orientation != 0) rightLabel = (lf->orientation < 0 ? ends->source : ends->target); return mgFontStringWidth(tl.font, rightLabel); } static char *interactLfLeftEndName(struct track *tg, void *item) /* Return name of left end in single interaction linked feature, for left label */ { struct linkedFeatures *lf = (struct linkedFeatures *)item; struct interactLfEndNames *ends = getInteractLfEndNames(lf); return (lf->orientation < 0 ? ends->target : ends->source); } -#ifdef FOO -static char *interactLfItemName(struct track *tg, void *item) -/* Return item name of interaction linked feature, for map */ -{ -struct linkedFeatures *lf = (struct linkedFeatures *)item; -return lf->name; -} -#endif - static void interactLfMapItem(struct track *tg, struct hvGfx *hvg, void *item, char *itemName, char *mapItemName, int start, int end, int x, int y, int width, int height) /* Draw mapbox on interact item when displayed as linked feature */ { struct linkedFeatures *lf = (struct linkedFeatures *)item; // restore full item name (using end name for label) itemName = mapItemName = lf->name; linkedFeaturesMapItem(tg, hvg, item, itemName, mapItemName, start, end, x, y, width, height); } void interactLoadItems(struct track *tg) /* Load interact items in interact format */ { loadAndFilterItems(tg); @@ -332,31 +322,30 @@ tInfo->clusterMode = interactUiClusterMode(cart, tg->track, tg->tdb); if (!tInfo->clusterMode && !isLinkedFeaturesMode(tg)) { // draw curve display tg->mapsSelf = TRUE; tg->totalHeight = interactTotalHeight; tg->drawLeftLabels = interactNoLeftLabels; tg->freeItems = interactFreeItems; return; } // convert to BEDs for linked feature display tg->itemName = interactLfLeftEndName; tg->mapItem = interactLfMapItem; -//tg->mapItemName = interactLfItemName; struct interact *inters = tg->items, *inter; struct linkedFeatures *lfs = NULL, *lf; struct hash *intersCluster = hashNew(0); boolean doColor = !tg->colorShades; for (inter = inters; inter; inter = inter->next) { if (tInfo->clusterMode) { boolean byTarget = sameString(tInfo->clusterMode, INTERACT_CLUSTER_TARGET); // hash by source or target name char *name = (byTarget ? inter->targetName : inter->sourceName); lf = (struct linkedFeatures *) hashFindVal(intersCluster, name); if (lf) { // add a simple feature for the other end (source or target) to the linked feature @@ -554,31 +543,31 @@ char buffer[1024]; char itemBuf[2048]; // Gather info for layout interactGetLayoutInfo(tg, seqStart, hvg, xOff, font, scale); struct interactTrackInfo *tInfo = (struct interactTrackInfo *)tg->customPt; setYOff(tg, yOff); // TODO: better to stash this in tInfo, and save that in track struct */ int highlightColor = MG_WHITE; boolean drawUp = trackDbSettingClosestToHomeOn(tg->tdb, INTERACT_UP) && vis == tvFull; // Get spectrum range int scoreMin = atoi(trackDbSettingClosestToHomeOrDefault(tg->tdb, "scoreMin", "0")); int scoreMax = atoi(trackDbSettingClosestToHomeOrDefault(tg->tdb, "scoreMax", "1000")); // Draw items -struct hash *footHash = hashNew(0); // track feet so we can override color to black for overlapping +struct hash *footHash = hashNew(0); // track feet so we can override color to black struct hash *footHashOther = hashNew(0); // has for items on other chrom for (inter = (struct interact *)tg->items; inter; inter = inter->next) { char *otherChrom = interactOtherChrom(inter); safef(itemBuf, sizeof itemBuf, "%s", inter->name); char *statusBuf = interactMouseover(inter, otherChrom); // Pick colors #define MG_LIGHT_MAGENTA 0xffffbbff #define MG_LIGHT_GRAY 0xff909090 color = interactItemColor(tg, inter, hvg, scoreMin, scoreMax); if (vis == tvDense && otherChrom && color == MG_BLACK) // use highlight color for other chrom items in dense mode color = MG_LIGHT_MAGENTA; @@ -598,31 +587,32 @@ else { height = tInfo->otherHeight/2; yOffOther = yOff + tInfo->sameHeight; } unsigned r = interactRegionCenter(inter->chromStart, inter->chromEnd); int x = getX(r, seqStart, scale, xOff); int footWidth = regionFootWidth(inter->chromStart, inter->chromEnd, scale); unsigned yPos = yOffOther + height; // draw the foot (2 pixels high) drawFoot(tg, hvg, inter->chrom, inter->chromStart, inter->chromEnd, x - footWidth, yOffOther, footWidth + footWidth + 1, color, drawUp, footHashOther); // draw the vertical - boolean isReversed = tInfo->isDirectional && differentString(inter->chrom, inter->sourceChrom); + boolean isReversed = tInfo->isDirectional && + differentString(inter->chrom, inter->sourceChrom); drawLine(tg, hvg, x, yOffOther, x, yPos, color, isReversed && doDashes, drawUp); if (vis == tvDense) continue; // add map box to foot char *nameBuf = (inter->chromStart == inter->sourceStart ? inter->sourceName : inter->targetName); drawFootMapbox(tg, hvg, inter->chromStart, inter->chromEnd, nameBuf, statusBuf, x - footWidth, yOffOther, footWidth, peakColor, highlightColor, drawUp); // add map box to vertical mapBoxHgcOrHgGene(hvg, inter->chromStart, inter->chromEnd, x - 2, yOffOther, 4, height, tg->track, itemBuf, statusBuf, NULL, TRUE, NULL); @@ -780,31 +770,31 @@ } hvGfxEllipseDraw(hvg, lowerX, yLeft, upperX, yTop, color, ellipseOrient, isReversed && doDashes); // draw grab box and map box on peak int maxY = peakHeight + yOff; int peakX = ((upperX - lowerX + 1) / 2) + lowerX; drawPeakMapbox(tg, hvg, inter->chromStart, inter->chromEnd, inter->name, statusBuf, peakX, maxY, peakColor, highlightColor, drawUp); } } } void interactLinkedFeaturesDrawAt(struct track *tg, void *item, struct hvGfx *hvg, int xOff, int y, double scale, MgFont *font, Color color, enum trackVisibility vis) -/* Draw a item with target in contrasting color */ +/* Draw an item with target in contrasting color */ { struct linkedFeatures *lf = item; if (vis == tvDense) { lf->filterColor = slightlyDarkerColor(hvg, MG_GRAY); // can't distinguish overlapping colors, so force to gray } struct interactTrackInfo *tInfo = tg->customPt; linkedFeaturesDrawAt(tg, item, hvg, xOff, y, scale, font, color, vis); // draw overlapping items in white and add right label if (tInfo->clusterMode) { struct simpleFeature *sf;