f7d7d19f5160b5553f500ce99a2e47621cb7c2dc kate Wed Jul 22 18:15:17 2015 -0700 1. Fix pack problem. 2. Fix map box in dense/squish. refs #15645 diff --git src/hg/hgTracks/gtexTracks.c src/hg/hgTracks/gtexTracks.c index d54fb51..ba91a5a 100644 --- src/hg/hgTracks/gtexTracks.c +++ src/hg/hgTracks/gtexTracks.c @@ -212,31 +212,32 @@ struct rgbColor lineColor = {.r=0}; int lineColorIx = hvGfxFindColorIx(hvg, lineColor.r, lineColor.g, lineColor.b); int heightPer = tg->heightPer; int graphX = gtexGraphX(geneBed); if (graphX < 0) return; // x1 is at left of graph int x1 = xOff + graphX; // yZero is at bottom of graph int yZero = gtexGraphHeight() + y - 1; // draw faint line under graph to delineate extent when bars are missing (tissue w/ 0 expression) Color lightGray = MAKECOLOR_32(0xD1, 0xD1, 0xD1); -hvGfxBox(hvg, x1, yZero+1, gtexGraphWidth(geneBed), 1, lightGray); +int graphWidth = gtexGraphWidth(geneBed); +hvGfxBox(hvg, x1, yZero+1, graphWidth, 1, lightGray); //uglyf("DRAW: xOff=%d, x1=%d, y=%d, yZero=%d<br>", xOff, x1, y, yZero); int barWidth = gtexBarWidth(); int graphPadding = gtexGraphPadding(); char *colorScheme = cartUsualStringClosestToHome(cart, tg->tdb, FALSE, GTEX_COLORS, GTEX_COLORS_DEFAULT); struct rgbColor *colors; if (sameString(colorScheme, GTEX_COLORS_GTEX)) { // retrieve from table // TODO: cache this colors = getGtexTissueColors(); } else @@ -262,75 +263,69 @@ //int height = yZero - yMedian + 1; int height = yZero - yMedian; // TODO: adjust yGene instead of yMedian+1 to get gene track distance as desired //if (i ==0) uglyf("DRAW: expScore=%.2f, maxExp=%.2f, graphHeight=%d, y=%d<br>", expScore, maxExp, gtexGraphHeight(), y); //if (i ==0) uglyf("DRAW: yZero=%d, yMedian=%d, height=%d<br>", yZero, yMedian, height); if (graphPadding == 0 || sameString(colorScheme, GTEX_COLORS_GTEX)) hvGfxBox(hvg, x1, yMedian+1, barWidth, height, fillColorIx); else hvGfxOutlinedBox(hvg, x1, yMedian+1, barWidth, height, fillColorIx, lineColorIx); x1 = x1 + barWidth + graphPadding; } // mark gene extent int yGene = yZero + gtexGeneMargin() - 1; -#ifdef NO_GENE -// underline -int start = max(geneBed->chromStart, winStart); -int end = min(geneBed->chromEnd, winEnd); -if (start > end) - return; -int xStart = round((start - winStart) * scale)+xOff; -int width = round((end-start)*scale); -hvGfxBox(hvg, xStart, yGene, width, gtexGeneHeight(), lineColorIx); -//uglyf("DRAW: xStart=%d, yGene=%d, width=%d, height=%d<br> ", xStart, yGene, width, gtexGeneHeight()); -#endif - // load & draw gene model char query[1024]; char **row; sqlSafef(query, sizeof query, "select * from gtexGeneModel where name='%s'", geneBed->geneId); struct sqlConnection *conn = hAllocConn(database); if (conn == NULL) return; //uglyf("query: %s<br>", query); struct sqlResult *sr = sqlGetResult(conn, query); struct genePred *geneModel = NULL; if (sr != NULL) { if ((row = sqlNextRow(sr)) != NULL) geneModel = genePredLoad(row); sqlFreeResult(&sr); } if (geneModel == NULL) return; struct linkedFeatures *lf = linkedFeaturesFromGenePred(tg, geneModel, FALSE); tg->heightPer = gtexGeneHeight()+1; lf->filterColor = statusColor; linkedFeaturesDrawAt(tg, lf, hvg, xOff, yGene, scale, font, color, tvSquish); tg->heightPer = heightPer; hFreeConn(&conn); } static void gtexGeneMapItem(struct track *tg, struct hvGfx *hvg, void *item, char *itemName, char *mapItemName, int start, int end, int x, int y, int width, int height) -/* Create a map box for each tissue (bar in the graph) */ +/* Create a map box for each tissue (bar in the graph) or a single map for squish/dense modes */ { //uglyf("map item: itemName=%s, mapItemName=%s, start=%d, end=%d, x=%d, y=%d, width=%d, height=%d, insideX=%d<br>", //itemName, mapItemName, start, end, x, y, width, height, insideX); + +if (tg->visibility == tvDense || tg->visibility == tvSquish) + { + genericMapItem(tg, hvg, item, itemName, itemName, start, end, x, y, width, height); + } + struct gtexTissue *tissues = getGtexTissues(); struct gtexTissue *tissue = NULL; struct gtexGeneBed *gtex = item; int barWidth = gtexBarWidth(); int padding = gtexGraphPadding(); double maxExp = ((struct gtexGeneExtras *)tg->extraUiData)->maxExp; int graphX = gtexGraphX((struct gtexGeneBed *)item); if (graphX < 0) return; // x1 is at left of graph int x1 = insideX + graphX; int i = 0; int yZero = gtexGraphHeight() + y - 1; @@ -355,46 +350,58 @@ } static void gtexGeneLoadItems(struct track *track) { bedLoadItem(track, track->table, (ItemLoader)loadGtexGeneBed); double maxExp = 0.0; int i; struct gtexGeneBed *geneBed; for (geneBed = track->items; geneBed != NULL; geneBed = geneBed->next) for (i=0; i<geneBed->expCount; i++) maxExp = (geneBed->expScores[i] > maxExp ? geneBed->expScores[i] : maxExp); struct gtexGeneExtras *extras; AllocVar(extras); extras->maxExp = maxExp; track->extraUiData = extras; + } static int gtexGeneItemHeight(struct track *track, void *item) { if ((item == NULL) || (track->visibility == tvSquish) || (track->visibility == tvDense)) return 0; return gtexGraphHeight() + + gtexGeneMargin() + gtexGeneHeight(); } static int gtexTotalHeight(struct track *track, enum trackVisibility vis) /* Figure out total height of track */ { int height; if (track->visibility == tvSquish || track->visibility == tvDense) height = 10; else height = gtexGraphHeight() + gtexGeneMargin() + gtexGeneHeight(); return tgFixedTotalHeightOptionalOverflow(track, vis, height, height, FALSE); } +static int gtexGeneItemEnd(struct track *track, void *item) +/* Return end chromosome coordinate of item, including graph */ +{ +struct gtexGeneBed *geneBed = (struct gtexGeneBed *)item; +double scale = scaleForWindow(insideWidth, winStart, winEnd); +int graphWidth = gtexGraphWidth(geneBed); +return max(geneBed->chromEnd, max(winStart, geneBed->chromStart) + graphWidth/scale); +} + + void gtexGeneMethods(struct track *track) { track->drawItemAt = gtexGeneDrawAt; track->loadItems = gtexGeneLoadItems; track->mapItem = gtexGeneMapItem; track->itemHeight = gtexGeneItemHeight; +track->itemEnd = gtexGeneItemEnd; track->totalHeight = gtexTotalHeight; }