161f75600a7d002b587651e28c25bd5034322bfa
angie
  Thu Jul 16 14:14:34 2020 -0700
AJAX update of VCF track with color-by-function was losing the colors because the whole track list isn't loaded; load geneTrack tdb separately in that case.  refs #25870

diff --git src/hg/hgTracks/vcfTrack.c src/hg/hgTracks/vcfTrack.c
index 40c96cd..425adcf 100644
--- src/hg/hgTracks/vcfTrack.c
+++ src/hg/hgTracks/vcfTrack.c
@@ -1021,30 +1021,47 @@
                 struct genePred *gp = lf->original;
                 struct txInfo *txi = txInfoFromGenePred(gp, gSeqWin);
                 slAddHead(&txiList, txi);
                 }
             }
         else if (sameString(gTdb->type, "bigGenePred"))
             txiList = txInfoLoadBigGenePred(gSeqWin, gTdb);
         else
             txiList = txInfoLoadGenePred(gSeqWin, gTdb);
         }
     else
         errAbort("VCF txInfoLoad: expecting type 'genePred' or 'bigGenePred' for track '%s' "
                  "in geneTrack setting, but got type '%s'",
                  geneTrack, gTdb->type);
     }
+else if (trackImgOnly)
+    {
+    // For AJAX requests to redraw a single track, we have not loaded the whole trackDb,
+    // so see if we can find tdb for geneTrack, and load its items.
+    struct trackDb *gTdb = hTrackDbForTrack(database, geneTrack);
+    if (gTdb)
+        {
+        if (startsWith("ncbiRefSeq", geneTrack))
+            txiList = txInfoLoadNcbiRefSeq(gSeqWin, gTdb);
+        else if (sameString(geneTrack, "refGene"))
+            txiList = txInfoLoadRefGene(gSeqWin, gTdb);
+        else if (sameString(gTdb->type, "bigGenePred"))
+            txiList = txInfoLoadBigGenePred(gSeqWin, gTdb);
+        else
+            txiList = txInfoLoadGenePred(gSeqWin, gTdb);
+        }
+    }
 return txiList;
 }
 
 static enum soTerm functionForRecord(struct vcfRecord *rec, struct seqWindow *gSeqWin,
                                      struct txInfo *txiList)
 /* Return the most severe functional consequence of rec for any transcript in txiList. */
 {
 struct lm *lm = lmInit(0);
 // Can't use rec->chrom because that might be just "1" instead of "chr1":
 struct bed3 variantBed3 = { NULL, chromName, rec->chromStart, rec->chromEnd };
 enum soTerm maxImpactTerm = soUnknown;
 struct txInfo *txi;
 for (txi = txiList;  txi != NULL;  txi = txi->next)
     {
     int alIx;