b94993d07e5d0ef24f17a40c9ca7f5b2ddb93701
braney
  Wed May 11 10:50:56 2022 -0700
allow hubs to specify a naming authority for the chromosome that's
displayed by the browser

diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c
index 7b451fc..c3eab37 100644
--- src/hg/hgTracks/hgTracks.c
+++ src/hg/hgTracks/hgTracks.c
@@ -711,40 +711,40 @@
         }
     else
         {
         trashDirFile(ideoTn, "hgtIdeo", "hgtIdeo", ".png");
         hvg = hvGfxOpenPng(ideoWidth, ideoHeight, ideoTn->forCgi, FALSE);
         }
     maybeNewFonts(hvg);
     hvg->rc = revCmplDisp;
     initColors(hvg);
     ideoTrack->ixColor = hvGfxFindRgb(hvg, &ideoTrack->color);
     ideoTrack->ixAltColor = hvGfxFindRgb(hvg, &ideoTrack->altColor);
     hvGfxSetClip(hvg, 0, gfxBorder, ideoWidth, ideoTrack->height);
     if (virtMode)
 	{
     	if (!sameString(virtModeShortDescr,""))
-    	    safef(title, sizeof(title), "%s (%s)", chromName, virtModeShortDescr);
+    	    safef(title, sizeof(title), "%s (%s)", displayChromName, virtModeShortDescr);
 	else
-    	    safef(title, sizeof(title), "%s (%s)", chromName, virtModeType);
+    	    safef(title, sizeof(title), "%s (%s)", displayChromName, virtModeType);
 	}
     else if (isEmpty(startBand))
-        safef(title, sizeof(title), "%s", chromName);
+        safef(title, sizeof(title), "%s", displayChromName);
     else if (sameString(startBand, endBand))
-        safef(title, sizeof(title), "%s (%s)", chromName, startBand);
+        safef(title, sizeof(title), "%s (%s)", displayChromName, startBand);
     else
-        safef(title, sizeof(title), "%s (%s-%s)", chromName, startBand, endBand);
+        safef(title, sizeof(title), "%s (%s-%s)", displayChromName, startBand, endBand);
     textWidth = mgFontStringWidth(font, title);
     hvGfxTextCentered(hvg, 2, gfxBorder, textWidth, ideoTrack->height, MG_BLACK, font, title);
     // cytoBandDrawAt() clips x based on insideX+insideWidth,
     // but in virtMode we may be in a window that is smaller than the ideo width
     // so temporarily set them to the actual ideo graphic offset and width
     int saveInsideX = insideX;
     int saveInsideWidth = insideWidth;
     insideX = textWidth+4;
     insideWidth = ideoWidth-insideX;
     ideoTrack->drawItems(ideoTrack, winStart, winEnd, hvg, insideX, gfxBorder,
                          insideWidth, font, ideoTrack->ixColor, ideoTrack->limitedVis);
     insideX = saveInsideX;
     insideWidth = saveInsideWidth;
     hvGfxUnclip(hvg);
     /* Save out picture and tell html file about it. */
@@ -3890,30 +3890,31 @@
     lastEnd = v->end;
     }
 }
 
 
 // multi-window variables global to hgTracks
 
 
 void setGlobalsFromWindow(struct window *window)
 /* set global window values */
 {
 currentWindow = window;
 organism  = window->organism;
 database  = window->database;
 chromName = window->chromName;
+displayChromName = chromAliasGetDisplayChrom(database, cart, window->chromName);
 winStart  = window->winStart;
 winEnd    = window->winEnd;
 insideX   = window->insideX;
 insideWidth = window->insideWidth;
 winBaseCount = winEnd - winStart;
 }
 
 
 void initExonStep()
 /* create exon-like pattern with exonSize and stepSize */
 {
 int winCount = cartUsualInt(cart, "demo2NumWindows", demo2NumWindows);
 int i;
 int exonSize = cartUsualInt(cart, "demo2WindowSize", demo2WindowSize);  //200; //9974; //200;
 int intronSize = cartUsualInt(cart, "demo2StepSize", demo2StepSize); //200; //15000; // really using it like stepSize as that allows overlapping windows.
@@ -5265,31 +5266,31 @@
             {
             hvGfxTextRight(hvgSide, leftLabelX, y, leftLabelWidth-1, showPosHeight,
                            MG_BLACK, font, WIN_POS_LABEL);
             y += showPosHeight;
             }
         if (baseShowScaleBar)
             {
             y += scaleBarPad;
             hvGfxTextRight(hvgSide, leftLabelX, y, leftLabelWidth-1, scaleBarHeight,
                            MG_BLACK, font, SCALE_BAR_LABEL);
             y += scaleBarHeight + scaleBarPad;
             }
         if (baseShowRuler)
             {
             char rulerLabel[SMALLBUF];
-            char *shortChromName = cloneString(chromName);
+            char *shortChromName = cloneString(displayChromName );
             safef(rulerLabel,ArraySize(rulerLabel),":%s",shortChromName);
             int labelWidth = mgFontStringWidth(font,rulerLabel);
             while ((labelWidth > 0) && (labelWidth > leftLabelWidth))
                 {
                 int len = strlen(shortChromName);
                 shortChromName[len-1] = 0;
                 safef(rulerLabel,ArraySize(rulerLabel),":%s",shortChromName);
                 labelWidth = mgFontStringWidth(font,rulerLabel);
                 }
             if (hvgSide->rc)
                 safef(rulerLabel,ArraySize(rulerLabel),":%s",shortChromName);
             else
                 safef(rulerLabel,ArraySize(rulerLabel),"%s:",shortChromName);
             hvGfxTextRight(hvgSide, leftLabelX, y, leftLabelWidth-1, rulerHeight,
                            MG_BLACK, font, rulerLabel);
@@ -9478,30 +9479,31 @@
 fullInsideWidth = tl.picWidth-gfxBorder-fullInsideX;
 }
 
 static boolean resolvePosition(char **pPosition)
 /* Position may be an already-resolved chr:start-end, or a search term.
  * If it is a search term:
  * 1 match ==> set globals chromName, winStart, winEnd, return TRUE.
  * 0 matches ==> switch back to lastPosition, hopefully get 1 match from that;
  * set globals chromName, winStart, winEnd, return TRUE.  If no lastPosition, try w/hDefaultPos().
  * multiple matches ==> Display a page with links to match positions, return FALSE. */
 {
 boolean resolved = TRUE;
 struct dyString *dyWarn = dyStringNew(0);
 boolean noShort = (cartOptionalString(cart, "noShort") != NULL);
 hgp = hgFindSearch(cart, pPosition, &chromName, &winStart, &winEnd, hgTracksName(), dyWarn);
+displayChromName = chromAliasGetDisplayChrom(database, cart, chromName);
 if (isNotEmpty(dyWarn->string))
     {
     if (noShort) // we're on the second pass of the search
         hgp->posCount = 0; // hgFindSearch gives us a bogus hgp if the warn string is set
     else
         warn("%s", dyWarn->string);
     }
 
 if (!noShort && hgp->singlePos)
     {
     createHgFindMatchHash();
     }
 else 
     {
     char *menuStr = menuBar(cart, database);
@@ -9542,30 +9544,31 @@
 if (!position)
     {
     errAbort("position NULL");
     }
 char *vPos = cloneString(position);
 stripChar(vPos, ',');
 char *colon = strchr(vPos, ':');
 if (!colon)
     errAbort("position has no colon");
 char *dash = strchr(vPos, '-');
 if (!dash)
     errAbort("position has no dash");
 *colon = 0;
 *dash = 0;
 chromName = cloneString(vPos);
+displayChromName = chromAliasGetDisplayChrom(database, cart, chromName);
 winStart = atol(colon+1) - 1;
 winEnd = atol(dash+1);
 }
 
 boolean findNearestVirtMatch(char *chrom, int start, int end, boolean findNearest, long *retVirtStart, long *retVirtEnd)
 /* find nearest match on virt chrom.
  * findNearest flag means of no direct hits found, take the closest miss. */
 {
 // search for one or more overlapping windows
 struct positionMatch *mList = virtChromSearchForPosition(chrom, start, end, findNearest);
 
 // sort positions by virtPos (will be sorted by chrom, start, end)
 matchSortOnVPos(&mList);
 
 // merge contiguous matches spanning multiple touching windows
@@ -9886,31 +9889,31 @@
 	    virtWinEnd = virtSeqBaseCount;
 	    virtMode = TRUE;
 	    // TODO what if the full-vchrom view has "too many windows"
 	    // check if virtRegionCount > 4000?
 	    }
 
 	remapHighlightPos();
 
 	}
 
     }
 
 if (virtMode)
     virtChromName = MULTI_REGION_CHROM;
 else
-    virtChromName = chromName;
+    virtChromName = displayChromName;
 
 virtWinBaseCount = virtWinEnd - virtWinStart;
 
 
 baseShowPos = cartUsualBoolean(cart, BASE_SHOWPOS, FALSE);
 baseShowAsm = cartUsualBoolean(cart, BASE_SHOWASM, FALSE);
 baseShowScaleBar = cartUsualBoolean(cart, BASE_SCALE_BAR, TRUE);
 baseShowRuler = cartUsualBoolean(cart, BASE_SHOWRULER, TRUE);
 safef(titleVar,sizeof(titleVar),"%s_%s", BASE_TITLE, database);
 baseTitle = cartUsualString(cart, titleVar, "");
 if (sameString(baseTitle, ""))
     baseTitle = NULL;
 
 if  (cgiVarExists("hgt.toggleRevCmplDisp"))
     toggleRevCmplDisp();