fd877baf9f8076f760de6d00931347b9db2a7053
kate
  Wed Nov 25 11:31:38 2015 -0800
Remove ifdefs for multi-region.

diff --git src/hg/hgTracks/gtexTracks.c src/hg/hgTracks/gtexTracks.c
index 2d12b65..30acd84 100644
--- src/hg/hgTracks/gtexTracks.c
+++ src/hg/hgTracks/gtexTracks.c
@@ -1,67 +1,60 @@
 /* GTEx (Genotype Tissue Expression) tracks  */
 
 /* Copyright (C) 2015 The Regents of the University of California 
  * See README in this or parent directory for licensing information. */
 
 #include "common.h"
 #include "hgTracks.h"
 #include "hvGfx.h"
 #include "rainbow.h"
 #include "gtexInfo.h"
 #include "gtexGeneBed.h"
 #include "gtexTissue.h"
 #include "gtexTissueData.h"
 #include "gtexUi.h"
-// TODO: move spaceSaver code to simpleTracks
 #include "spaceSaver.h"
 
-// NOTE: Sections to change for multi-region (vertical slice) display 
-//       are marked with #ifdef MULTI_REGION.  WARNING: These sections
-//       are a bit out-of-date (refer to #ifndef MULTI code when integrating)
-
 struct gtexGeneExtras 
 /* Track info */
     {
     double maxMedian;           /* Maximum median rpkm for all tissues */
     boolean isComparison;       /* Comparison of two sample sets (e.g. male/female). */
     boolean isDifference;       /* True if comparison is shown as a single difference graph. 
                                    False if displayed as two graphs, one oriented downward */
     char *graphType;            /* Additional info about graph (e.g. type of comparison graph */
     struct rgbColor *colors;    /* Color palette for tissues */
     boolean doLogTransform;     /* Log10(x+1) */
     struct gtexTissue *tissues; /* Cache tissue names, descriptions */
     struct hash *tissueFilter;  /* For filter. NULL out excluded tissues */
     };
 
 struct gtexGeneInfo
 /* GTEx gene model, names, and expression medians */
     {
     struct gtexGeneInfo *next;  /* Next in singly linked list */
     struct gtexGeneBed *geneBed;/* Gene name, id, canonical transcript, exp count and medians 
                                         from BED table */
     struct genePred *geneModel; /* Gene structure from model table */
     double *medians1;            /* Computed medians */
     double *medians2;            /* Computed medians for comparison (inverse) graph */
     int height;                  /* Item height in pixels */
     };
 
 /***********************************************/
 /* Color gene models using GENCODE conventions */
 
-// TODO: reuse GENCODE code for some/all of this ??
-// MAKE_COLOR_32 ?
 struct rgbColor codingColor = {12, 12, 120}; // #0C0C78
 struct rgbColor noncodingColor = {0, 100, 0}; // #006400
 struct rgbColor problemColor = {254, 0, 0}; // #FE0000
 struct rgbColor unknownColor = {1, 1, 1};
 
 static struct statusColors
 /* Color values for gene models */
     {
     Color coding;
     Color noncoding;
     Color problem;
     Color unknown;
     } statusColors = {0,0,0,0};
 
 static void initGeneColors(struct hvGfx *hvg)
@@ -232,34 +225,30 @@
                 {
                 medians1[i] -= medians2[i];
                 medians2[i] = 0;
                 }
             else
                 {
                 medians2[i] -= medians1[i];
                 medians1[i] = 0;
                 }
             }
         }
     geneInfo->medians1 = medians1;
     geneInfo->medians2 = medians2;
 
     }
-else
-    {
-    // TODO: compute median for single graph based on filtering of sample set
-    }
 }
 
 static int gtexGeneItemHeight(struct track *tg, void *item);
 
 static void filterTissues(struct track *tg)
 /* Check cart for tissue selection.  NULL out unselected tissues in tissue list */
 {
 struct gtexGeneExtras *extras = (struct gtexGeneExtras *)tg->extraUiData;
 struct gtexTissue *tis = NULL;
 extras->tissues = getTissues();
 extras->tissueFilter = hashNew(0);
 if (cartListVarExistsAnyLevel(cart, tg->tdb, FALSE, GTEX_TISSUE_SELECT))
     {
     struct slName *selectedValues = cartOptionalSlNameListClosestToHome(cart, tg->tdb, 
                                                         FALSE, GTEX_TISSUE_SELECT);
@@ -362,66 +351,53 @@
 #define MAX_GRAPH_PADDING 2
 
 #define WIN_MED_GRAPH 500000
 #define MED_GRAPH_HEIGHT 60
 #define MED_BAR_WIDTH 3
 #define MED_GRAPH_PADDING 1
 
 #define MIN_GRAPH_HEIGHT 20
 #define MIN_BAR_WIDTH 1
 #define MIN_GRAPH_PADDING 0
 
 #define MARGIN_WIDTH 1
 
 static int gtexBarWidth()
 {
-#ifdef MULTI_REGION
-int winSize = virtWinBaseCount; // GALT CHANGED OLD winEnd - winStart;
-#else
 int winSize = winEnd - winStart;
-#endif
 if (winSize < WIN_MAX_GRAPH)
     return MAX_BAR_WIDTH;
 else if (winSize < WIN_MED_GRAPH)
     return MED_BAR_WIDTH;
 else
     return MIN_BAR_WIDTH;
 }
 
 static int gtexGraphPadding()
 {
-#ifdef MULTI_REGION
-int winSize = virtWinBaseCount; // GALT CHANGED OLD winEnd - winStart;
-#else
 int winSize = winEnd - winStart;
-#endif
-
 if (winSize < WIN_MAX_GRAPH)
     return MAX_GRAPH_PADDING;
 else if (winSize < WIN_MED_GRAPH)
     return MED_GRAPH_PADDING;
 else
     return MIN_GRAPH_PADDING;
 }
 
 static int gtexMaxGraphHeight()
 {
-#ifdef MULTI_REGION
-int winSize = virtWinBaseCount; // GALT CHANGED OLD winEnd - winStart;
-#else
 int winSize = winEnd - winStart;
-#endif
 if (winSize < WIN_MAX_GRAPH)
     return MAX_GRAPH_HEIGHT;
 else if (winSize < WIN_MED_GRAPH)
     return MED_GRAPH_HEIGHT;
 else
     return MIN_GRAPH_HEIGHT;
 }
 
 static int gtexGraphWidth(struct track *tg, struct gtexGeneInfo *geneInfo)
 /* Width of GTEx graph in pixels */
 {
 int barWidth = gtexBarWidth();
 int padding = gtexGraphPadding();
 int count = filteredTissueCount(tg);
 int labelWidth = geneInfo->medians2 ? tl.mWidth : 0;
@@ -521,249 +497,126 @@
 if (vis != tvFull && vis != tvPack)
     {
     bedDrawSimpleAt(tg, geneBed, hvg, xOff, y, scale, font, statusColor, vis);
     return;
     }
 
 int heightPer = tg->heightPer;
 int graphX = gtexGraphX(geneBed);
 if (graphX < 0)
     return;
 
 int topGraphHeight = gtexGeneGraphHeight(tg, geneInfo, TRUE);
 topGraphHeight = max(topGraphHeight, tl.fontHeight);
 int yZero = topGraphHeight + y - 1;  // yZero is bottom of graph
 
-#ifndef MULTI_REGION
 int x1 = xOff + graphX;         // x1 is at left of graph
-int keepX = x1;                 // FIXME:  Too many X's!
+int keepX = x1;
 drawGraphBase(tg, geneInfo, hvg, keepX, yZero+1);
 
 int startX = x1;
 struct rgbColor lineColor = {.r=0};
 int lineColorIx = hvGfxFindColorIx(hvg, lineColor.r, lineColor.g, lineColor.b);
 int barWidth = gtexBarWidth();
 int graphPadding = gtexGraphPadding();
 char *colorScheme = cartUsualStringClosestToHome(cart, tg->tdb, FALSE, GTEX_COLORS, 
                         GTEX_COLORS_DEFAULT);
 Color labelColor = MG_GRAY;
 Color clipColor = MG_MAGENTA;
 
 // add labels to comparison graphs
-// TODO: generalize
 if (geneInfo->medians2)
     {
     hvGfxText(hvg, x1, yZero - tl.fontHeight + 1, labelColor, font, "F");
     hvGfxText(hvg, x1, yZero + gtexGeneModelHeight() + gtexGeneMargin() + 1, labelColor, font, "M");
     startX = startX + tl.mWidth+2;
     x1 = startX;
     }
 
 // draw bar graph
-// TODO: share this code with other graph
 double viewMax = (double)cartUsualIntClosestToHome(cart, tg->tdb, FALSE, 
                                 GTEX_MAX_LIMIT, GTEX_MAX_LIMIT_DEFAULT);
 double maxMedian = ((struct gtexGeneExtras *)tg->extraUiData)->maxMedian;
 int i;
 int expCount = geneBed->expCount;
 struct gtexGeneExtras *extras = (struct gtexGeneExtras *)tg->extraUiData;
 struct gtexTissue *tis;
 for (i=0, tis=extras->tissues; i<expCount; i++, tis=tis->next)
     {
     if (!filterTissue(tg, tis->name))
         continue;
     struct rgbColor fillColor = extras->colors[i];
     if (barWidth == 1 && sameString(colorScheme, GTEX_COLORS_GTEX))
         {
         // brighten colors a bit so they'll be more visible at this scale
         fillColor = gtexTissueBrightenColor(fillColor);
         }
     int fillColorIx = hvGfxFindColorIx(hvg, fillColor.r, fillColor.g, fillColor.b);
     double expScore = (geneInfo->medians1 ? geneInfo->medians1[i] : geneBed->expScores[i]);
     int height = valToClippedHeight(expScore, maxMedian, viewMax, 
                                         gtexMaxGraphHeight(), extras->doLogTransform);
     if (graphPadding == 0 || sameString(colorScheme, GTEX_COLORS_GTEX))
         hvGfxBox(hvg, x1, yZero-height+1, barWidth, height, fillColorIx);
     else
         hvGfxOutlinedBox(hvg, x1, yZero-height+1, barWidth, height, fillColorIx, lineColorIx);
     // mark clipped bar with magenta tip
     if (!extras->doLogTransform && expScore > viewMax)
         hvGfxBox(hvg, x1, yZero-height+1, barWidth, 1, clipColor);
     x1 = x1 + barWidth + graphPadding;
     }
-#endif
 
 // draw gene model
 int yGene = yZero + gtexGeneMargin() - 1;
 tg->heightPer = gtexGeneModelHeight() + 1;
 struct linkedFeatures *lf = linkedFeaturesFromGenePred(tg, geneInfo->geneModel, FALSE);
 lf->filterColor = statusColor;
 linkedFeaturesDrawAt(tg, lf, hvg, xOff, yGene, scale, font, color, tvSquish);
 tg->heightPer = heightPer;
 
 if (!geneInfo->medians2)
     return;
 
-#ifndef MULTI_REGION
 // draw comparison bar graph (upside down)
 x1 = startX;
 yZero = yGene + gtexGeneModelHeight() + 1; // yZero is at top of graph
 drawGraphBase(tg, geneInfo, hvg, keepX, yZero-1);
 
 for (i=0, tis=extras->tissues; i<expCount; i++, tis=tis->next)
     {
     if (!filterTissue(tg, tis->name))
         continue;
     struct rgbColor fillColor = extras->colors[i];
     if (barWidth == 1 && sameString(colorScheme, GTEX_COLORS_GTEX))
         {
         // brighten colors a bit so they'll be more visible at this scale
         struct hslColor hsl = mgRgbToHsl(fillColor);
         hsl.s = min(1000, hsl.s + 300);
         fillColor = mgHslToRgb(hsl);
         }
     int fillColorIx = hvGfxFindColorIx(hvg, fillColor.r, fillColor.g, fillColor.b);
     double expScore = geneInfo->medians2[i];
     int height = valToClippedHeight(expScore, maxMedian, viewMax, gtexMaxGraphHeight(), 
                                         extras->doLogTransform);
     if (graphPadding == 0 || sameString(colorScheme, GTEX_COLORS_GTEX))
         hvGfxBox(hvg, x1, yZero, barWidth, height, fillColorIx);
     else
         hvGfxOutlinedBox(hvg, x1, yZero, barWidth, height, fillColorIx, lineColorIx);
     if (!extras->doLogTransform && expScore > viewMax)
         hvGfxBox(hvg, x1, yZero + height, barWidth, 1, clipColor);
     x1 = x1 + barWidth + graphPadding;
     }
-#endif
-}
-
-#ifdef MULTI_REGION
-static int gtexGeneNonPropPixelWidth(struct track *tg, void *item)
-/* Return end chromosome coordinate of item, including graph */
-{
-struct gtexGeneInfo *geneInfo = (struct gtexGeneInfo *)item;
-int graphWidth = gtexGraphWidth(geneInfo);
-return graphWidth;
-}
-#endif
-
-#ifdef MULTI_REGION
-static void gtexGeneNonPropDrawAt(struct track *tg, void *item, struct hvGfx *hvg, int xOff, int y,
-                double scale, MgFont *font, Color color, enum trackVisibility vis)
-{
-struct gtexGeneInfo *geneInfo = (struct gtexGeneInfo *)item;
-struct gtexGeneBed *geneBed = geneInfo->geneBed;
-
-// Color in dense mode using transcriptClass
-// GALT REMOVE Color statusColor = getTranscriptStatusColor(hvg, geneBed);
-if (vis != tvFull && vis != tvPack)
-    {
-    //GALT bedDrawSimpleAt(tg, geneBed, hvg, xOff, y, scale, font, statusColor, vis);
-    return;
-    }
-int i;
-int expCount = geneBed->expCount;
-double maxMedian = ((struct gtexGeneExtras *)tg->extraUiData)->maxMedian;
-struct rgbColor lineColor = {.r=0};
-int lineColorIx = hvGfxFindColorIx(hvg, lineColor.r, lineColor.g, lineColor.b);
-// GALT REMOVE int heightPer = tg->heightPer;
-
-int graphX = gtexGraphX(geneBed);
-if (graphX < 0)
-    return;
-int x1 = xOff + graphX; // x1 is at left of graph
-int startX = x1;
-int yZero = gtexMaxGraphHeight() + y - 1; // yZero is at bottom of graph
-
-// draw faint line under graph to delineate extent when bars are missing (tissue w/ 0 expression)
-// TODO: skip missing bars
-Color lightGray = MAKECOLOR_32(0xD1, 0xD1, 0xD1);
-int graphWidth = gtexGraphWidth(geneInfo);
-hvGfxBox(hvg, x1, yZero+1, graphWidth, 1, lightGray);
-
-int barWidth = gtexBarWidth();
-int graphPadding = gtexGraphPadding();
-
-char *colorScheme = cartUsualStringClosestToHome(cart, tg->tdb, FALSE, GTEX_COLORS,
-                        GTEX_COLORS_DEFAULT);
-Color labelColor = MG_GRAY;
-
-if (geneInfo->medians2)
-    {
-    // add labels to comparison graphs
-    // TODO: generalize
-    hvGfxText(hvg, x1, yZero-tl.fontHeight, labelColor, font, "F");
-    hvGfxText(hvg, x1, yZero + gtexGeneModelHeight() + gtexGeneMargin(), labelColor, font, "M");
-    startX = startX + tl.mWidth + 2;
-    x1 = startX;
-    }
-for (i=0; i<expCount; i++)
-    {
-    struct rgbColor fillColor = extras->colors[i];
-    if (barWidth == 1 && sameString(colorScheme, GTEX_COLORS_GTEX))
-        {
-        // brighten colors a bit so they'll be more visible at this scale
-        fillColor = gtexTissueBrightenColor(fillColor);
-        }
-    int fillColorIx = hvGfxFindColorIx(hvg, fillColor.r, fillColor.g, fillColor.b);
-
-    double expScore = (geneInfo->medians1 ? geneInfo->medians1[i] : geneBed->expScores[i]);
-    int height = valToHeight(expScore, maxMedian, gtexMaxGraphHeight(), extras->doLogTransform);
-    if (graphPadding == 0 || sameString(colorScheme, GTEX_COLORS_GTEX))
-        hvGfxBox(hvg, x1, yZero-height, barWidth, height, fillColorIx);
-    else
-        hvGfxOutlinedBox(hvg, x1, yZero-height, barWidth, height, fillColorIx, lineColorIx);
-    x1 = x1 + barWidth + graphPadding;
-    }
-
-// mark gene extent
-int yGene = yZero + gtexGeneMargin() - 1;
-
-/* GALT NOT DONE HERE NOW
-// draw gene model
-tg->heightPer = gtexGeneModelHeight()+1;
-struct linkedFeatures *lf = linkedFeaturesFromGenePred(tg, geneInfo->geneModel, FALSE);
-lf->filterColor = statusColor;
-// GALT linkedFeaturesDrawAt(tg, lf, hvg, xOff, yGene, scale, font, color, tvSquish);
-tg->heightPer = heightPer;
-*/
-if (!geneInfo->medians2)
-    return;
-// draw comparison graph (upside down)
-x1 = startX;
-yZero = yGene + gtexGeneModelHeight(); // yZero is at top of graph
-for (i=0; i<expCount; i++)
-    {
-    struct rgbColor fillColor = extras->colors[i];
-    if (barWidth == 1 && sameString(colorScheme, GTEX_COLORS_GTEX))
-        {
-        // brighten colors a bit so they'll be more visible at this scale
-        struct hslColor hsl = mgRgbToHsl(fillColor);
-        hsl.s = min(1000, hsl.s + 300);
-        fillColor = mgHslToRgb(hsl);
-        }
-    int fillColorIx = hvGfxFindColorIx(hvg, fillColor.r, fillColor.g, fillColor.b);
-    double expScore = geneInfo->medians2[i];
-    int height = valToHeight(expScore, maxMedian, gtexMaxGraphHeight(), extras->doLogTransform);
-    if (graphPadding == 0 || sameString(colorScheme, GTEX_COLORS_GTEX))
-        hvGfxBox(hvg, x1, yZero, barWidth, height, fillColorIx);
-    else
-        hvGfxOutlinedBox(hvg, x1, yZero, barWidth, height, fillColorIx, lineColorIx);
-    x1 = x1 + barWidth + graphPadding;
-    }
 }
-#endif
 
 static int gtexGeneItemHeightOptionalMax(struct track *tg, void *item, boolean isMax)
 {
 if (tg->visibility == tvSquish || tg->visibility == tvDense)
     return 0;
 if (isMax)
     {
     int extra = 0;
     if (((struct gtexGeneExtras *)tg->extraUiData)->isComparison)
         extra = gtexMaxGraphHeight() + 2;
     return gtexMaxGraphHeight() + gtexGeneMargin() + gtexGeneModelHeight() + extra;
     }
 if (item == NULL)
     return 0;
 struct gtexGeneInfo *geneInfo = (struct gtexGeneInfo *)item;
@@ -979,31 +832,26 @@
 static int gtexGeneItemEnd(struct track *tg, void *item)
 /* Return end chromosome coordinate of item, including graph */
 {
 struct gtexGeneInfo *geneInfo = (struct gtexGeneInfo *)item;
 struct gtexGeneBed *geneBed = geneInfo->geneBed;
 double scale = scaleForWindow(insideWidth, winStart, winEnd);
 int graphWidth = gtexGraphWidth(tg, geneInfo);
 return max(geneBed->chromEnd, max(winStart, geneBed->chromStart) + graphWidth/scale);
 }
 
 void gtexGeneMethods(struct track *tg)
 {
 tg->drawItems = gtexGeneDrawItems;
 tg->drawItemAt = gtexGeneDrawAt;
 tg->loadItems = gtexGeneLoadItems;
-//tg->freeItems = gtexGeneFreeItems;
 tg->mapItem = gtexGeneMapItem;
 tg->itemName = gtexGeneItemName;
 tg->mapItemName = gtexGeneItemName;
 tg->itemHeight = gtexGeneItemHeight;
 tg->itemStart = gtexGeneItemStart;
 tg->itemEnd = gtexGeneItemEnd;
 tg->totalHeight = gtexGeneTotalHeight;
-#ifdef MULTI_REGION
-tg->nonPropDrawItemAt = gtexGeneNonPropDrawAt;
-tg->nonPropPixelWidth = gtexGeneNonPropPixelWidth;
-#endif
 }