b5d34fef6610916dc89c85f83c0e1f719f6969c3
kate
  Mon Aug 31 20:13:15 2020 -0700
Add support for mouseOver (pattern) trackDb setting (initially to bigLolly). refs #26160

diff --git src/hg/hgTracks/lollyTrack.c src/hg/hgTracks/lollyTrack.c
index 6b54b93..61fecad 100644
--- src/hg/hgTracks/lollyTrack.c
+++ src/hg/hgTracks/lollyTrack.c
@@ -221,30 +221,42 @@
 
 int lollySizeField = -1 ;
 setting = trackDbSetting(tg->tdb, "lollySizeField");
 if (setting != NULL)
     lollySizeField = atoi(setting);
     
 double minVal = DBL_MAX, maxVal = -DBL_MAX;
 //double sumData = 0.0, sumSquares = 0.0;
 unsigned count = 0;
 
 int trackHeight = tg->lollyCart->height;
 struct bigBedFilter *filters = bigBedBuildFilters(cart, bbi, tg->tdb);
 char *mouseOverField = cartOrTdbString(cart, tg->tdb, "mouseOverField", NULL);
 int mouseOverIdx = bbExtraFieldIndex(bbi, mouseOverField) ;
 
+char *mouseOverPattern = NULL;
+char **fieldNames = NULL;
+if (!mouseOverIdx)
+    {
+    mouseOverPattern = cartOrTdbString(cart, tg->tdb, "mouseOver", NULL);
+    AllocArray(fieldNames, bbi->fieldCount);
+    struct slName *field = NULL, *fields = bbFieldNames(bbi);
+    int i =  0;
+    for (field = fields; field != NULL; field = field->next)
+        fieldNames[i++] = field->name;
+    }
+                    
 for (bb = bbList; bb != NULL; bb = bb->next)
     {
     bigBedIntervalToRow(bb, chromName, startBuf, endBuf, bedRow, ArraySize(bedRow));
 
     // throw away items that don't pass the filters
     if (!bigBedFilterInterval(bedRow, filters))
         continue;
 
     // clip out lollies that aren't in our display range
     double val = atof(bedRow[lollyField - 1]);
     if (!((lollyCart->autoScale == wiggleScaleAuto) ||  ((val >= lollyCart->minY) && (val <= lollyCart->maxY) )))
         continue;
 
     // don't draw lollies off the screen
     if (atoi(bedRow[1]) < winStart)
@@ -256,30 +268,32 @@
     pop->start = atoi(bedRow[1]);
     pop->end = atoi(bedRow[2]);
     pop->name = cloneString(bedRow[3]);
     pop->radius = -1;
     if (lollySizeField > 0)
         {
         double radius = atoi(bedRow[lollySizeField - 1]) * trackHeight / 100.0;
         pop->radius = radius;
         }
     pop->color = 0;
 
     pop->mouseOver = pop->name;
     extern char* restField(struct bigBedInterval *bb, int fieldIdx) ;
     if (mouseOverIdx > 0)
         pop->mouseOver   = restField(bb, mouseOverIdx);
+    else if (mouseOverPattern)
+        pop->mouseOver = replaceFieldInPattern(mouseOverPattern, bbi->fieldCount, fieldNames, bedRow);
 
     if (bbi->fieldCount > 8)
         pop->color = itemRgbColumn(bedRow[8]);
     count++;
     if (val > maxVal)
         maxVal = val;
     if (val < minVal)
         minVal = val;
     }
 
 if (count == 0)
     lollyCart->upperLimit = lollyCart->lowerLimit = NAN; // no lollies in range
 else if (lollyCart->autoScale == wiggleScaleAuto)
     {
     lollyCart->upperLimit = maxVal;