e1abdbe4945561b19dad7d4139982f511e4b2b5d
kent
  Wed Jun 29 19:12:39 2022 -0700
Expanding coloring based on query sequence to include chain tracks.

diff --git src/hg/hgTracks/chainTrack.c src/hg/hgTracks/chainTrack.c
index 9b0b02a..24bd072 100644
--- src/hg/hgTracks/chainTrack.c
+++ src/hg/hgTracks/chainTrack.c
@@ -120,42 +120,45 @@
     lf = hashFindVal(hash, row[0]);
     if (lf != NULL)
 	{
 	lmAllocVar(lm, sf);
 	sf->start = sqlUnsigned(row[1]);
 	sf->end = sqlUnsigned(row[2]);
 	sf->qStart = sqlUnsigned(row[3]);
 	sf->qEnd = sf->qStart + (sf->end - sf->start);
 	slAddHead(&lf->components, sf);
 	}
     }
 sqlFreeResult(&sr);
 dyStringFree(&query);
 }
 
-static void chainDraw(struct track *tg, int seqStart, int seqEnd,
+void chainDraw(struct track *tg, int seqStart, int seqEnd,
         struct hvGfx *hvg, int xOff, int yOff, int width,
         MgFont *font, Color color, enum trackVisibility vis)
 /* Draw chained features. This loads up the simple features from
  * the chainLink table, calls linkedFeaturesDraw, and then
  * frees the simple features again. */
 {
 struct linkedFeatures *lf;
 struct simpleFeature *sf;
 struct lm *lm;
 struct hash *hash;	/* Hash of chain ids. */
+#ifdef OLD
 double scale = ((double)(winEnd - winStart))/width;
+#endif /* OLD */
+
 char fullName[64];
 int start, end, extra;
 struct simpleFeature *lastSf = NULL;
 int maxOverLeft = 0, maxOverRight = 0;
 int overLeft, overRight;
 
 if (tg->items == NULL)		/*Exit Early if nothing to do */
     return;
 
 void *closure;
 struct sqlClosure sqlClosure;
 struct bbClosure bbClosure;
 linkRetrieveFunc queryFunc;
 if (tg->isBigBed)
     {
@@ -178,52 +181,56 @@
     queryFunc = doQuery;
     sqlClosure.conn = hAllocConn(database);
     }
 
 lm = lmInit(1024*4);
 hash = newHash(0);
 
 /* Make up a hash of all linked features keyed by
  * id, which is held in the extras field.  To
  * avoid burning memory on full chromosome views
  * we'll just make a single simple feature and
  * exclude from hash chains less than three pixels wide,
  * since these would always appear solid. */
 for (lf = tg->items; lf != NULL; lf = lf->next)
     {
+#ifdef OLD
     double pixelWidth = (lf->end - lf->start) / scale;
     if (pixelWidth >= 2.5)
+#endif /* OLD */
 	{
 	hashAdd(hash, lf->extra, lf);
 	overRight = lf->end - seqEnd;
 	if (overRight > maxOverRight)
 	    maxOverRight = overRight;
 	overLeft = seqStart - lf->start ;
 	if (overLeft > maxOverLeft)
 	    maxOverLeft = overLeft;
 	}
+#ifdef OLD
     else
 	{
 	lmAllocVar(lm, sf);
 	sf->start = lf->start;
 	sf->end = lf->end;
 	sf->grayIx = lf->grayIx;
 	lf->components = sf;
 	}
+#endif /* OLD */
     }
 
-/* if some chains are bigger than 3 pixels */
+/* if some chains are actually loaded */
 if (hash->size)
     {
     boolean isSplit = TRUE;
     /* Make up range query. */
     safef(fullName, sizeof fullName, "%s_%s", chromName, tg->table);
     if (isHubTrack(tg->table) || !hTableExists(database, fullName))
 	{
 	strcpy(fullName, tg->table);
 	isSplit = FALSE;
 	}
 
     /* in dense mode we don't draw the lines
      * so we don't need items off the screen
      */
     if (vis == tvDense)