7bf9ad5d27f838f39326f49e9670da152f51e1c6
max
  Wed Sep 30 15:02:37 2026 -0700
vcfTabix tracks: trackDb setting maxItems now also sets the maximum number of VCF records loaded for the window, overriding the hg.conf setting vcfMaxItems (default 10000), refs #37306

diff --git src/hg/hgTracks/vcfTrack.c src/hg/hgTracks/vcfTrack.c
index 4aa9645eeda..26a6818662b 100644
--- src/hg/hgTracks/vcfTrack.c
+++ src/hg/hgTracks/vcfTrack.c
@@ -3371,72 +3371,66 @@
 /* Load items from a VCF of one individuals phased genotypes */
 {
 knetUdcInstall();
 pgSnpMethods(track);
 track->drawItems = vcfPhasedDrawItems;
 // Disinherit next/prev flag and methods since we don't support next/prev:
 track->nextExonButtonable = FALSE;
 track->nextPrevExon = NULL;
 track->nextPrevItem = NULL;
 track->loadItems = vcfPhasedLoadItems;
 track->totalHeight = vcfPhasedTrackHeight;
 track->itemName = vcfHapClusterTrackName;
 track->mapsSelf = TRUE;
 }
 
-static unsigned vcfMaxItems()
-/* Get the maximum number of items to grab from a vcf file.  Defaults to ten thousand. */
+static unsigned vcfMaxItems(struct trackDb *tdb)
+/* Get the maximum number of items to grab from a vcf file: trackDb setting maxItems,
+ * else hg.conf setting vcfMaxItems, else ten thousand. */
 {
-static boolean set = FALSE;
-static unsigned maxItems = 0;
-
-if (!set)
-    {
-    char *maxItemsStr = cfgOptionDefault("vcfMaxItems", "10000");
-
-    maxItems = sqlUnsigned(maxItemsStr);
-    }
-
-return maxItems;
+char *maxItemsStr = trackDbSettingClosestToHome(tdb, "maxItems");
+if (maxItemsStr == NULL)
+    maxItemsStr = cfgOptionDefault("vcfMaxItems", "10000");
+return sqlUnsigned(maxItemsStr);
 }
 
 static void vcfTabixLoadItems(struct track *tg)
 /* Load items in window from VCF file using its tabix index file. */
 {
 char *fileOrUrl = trackDbSetting(tg->tdb, "bigDataUrl");
 char *tbiFileOrUrl = trackDbSetting(tg->tdb, "bigDataIndex"); // unrelated to mysql
 
 if (!fileOrUrl)
     {
     struct sqlConnection *conn = hAllocConnTrack(database, tg->tdb);
     fileOrUrl = bbiNameFromSettingOrTableChrom(tg->tdb, conn, tg->table, chromName);
     hFreeConn(&conn);
     }
 
 if (isEmpty(fileOrUrl))
     return;
 fileOrUrl = hReplaceGbdb(fileOrUrl);
 int vcfMaxErr = -1;
 struct vcfFile *vcff = NULL;
 boolean hapClustEnabled = cartOrTdbBoolean(cart, tg->tdb, VCF_HAP_ENABLED_VAR, TRUE);
 if (slCount(windows)>1)
     hapClustEnabled = FALSE;  // haplotype sorting display not currently available with multiple windows.
 /* protect against temporary network error */
 struct errCatch *errCatch = errCatchNew();
 if (errCatchStart(errCatch))
     {
-    vcff = vcfTabixFileAndIndexMayOpenExt(fileOrUrl, tbiFileOrUrl, chromName, winStart, winEnd, vcfMaxErr, vcfMaxItems(), 
+    vcff = vcfTabixFileAndIndexMayOpenExt(fileOrUrl, tbiFileOrUrl, chromName, winStart, winEnd, vcfMaxErr, vcfMaxItems(tg->tdb),
         "Too many items in region.Zoom in to view track.");
     if (vcff != NULL)
 	{
 	filterRecords(vcff, tg);
         int vis = tdbVisLimitedByAncestors(cart,tg->tdb,TRUE,TRUE);
         boolean doWiggle = checkIfWiggling(cart, tg);
 	if (!doWiggle && hapClustEnabled && vcff->genotypeCount > 1 &&
 	    (vis == tvPack || vis == tvSquish))
 	    vcfHapClusterOverloadMethods(tg, vcff);
 	else
 	    {
 	    tg->items = vcfFileToPgSnp(vcff, tg->tdb);
 	    // pgSnp bases coloring/display decision on count of items:
 	    tg->customInt = slCount(tg->items);
 	    }