b2b58edce8b1d75567737b05e21ba9103073c69d
chmalee
  Mon May 4 12:11:37 2026 -0700
Fix myVariants tracks to load via a hardcoded query rather than hRangeQuery because the tableName is already qualified with the database. Remove dead code after refactor. Fix table browser output for myVariants tracks for various options, refs #33808

diff --git src/hg/hgTables/bedList.c src/hg/hgTables/bedList.c
index 568350a4229..a4950f2e20a 100644
--- src/hg/hgTables/bedList.c
+++ src/hg/hgTables/bedList.c
@@ -11,30 +11,31 @@
 #include "jksql.h"
 #include "cheapcgi.h"
 #include "trackDb.h"
 #include "customTrack.h"
 #include "hdb.h"
 #include "hui.h"
 #include "hCommon.h"
 #include "web.h"
 #include "featureBits.h"
 #include "portable.h"
 #include "hgTables.h"
 #include "wiggle.h"
 #include "correlate.h"
 #include "bedCart.h"
 #include "trashDir.h"
+#include "myVariants.h"
 #include "wikiTrack.h"
 
 
 boolean htiIsPsl(struct hTableInfo *hti)
 /* Return TRUE if table looks to be in psl format. */
 {
 return sameString("tStarts", hti->startsField);
 }
 
 void bedSqlFieldsExceptForChrom(struct hTableInfo *hti,
 	int *retFieldCount, char **retFields)
 /* Given tableInfo figure out what fields are needed to
  * add to a database query to have information to create
  * a bed. The chromosome is not one of these fields - we
  * assume that is already known since we're processing one
@@ -210,33 +211,35 @@
         int *retFieldCount)     /* Number of fields. */
 /* Return a bed list of all items in the given range in table.
  * Cleanup result via lmCleanup(&lm) rather than bedFreeList.  */
 {
 char *fields = NULL;
 struct sqlResult *sr;
 struct hTableInfo *hti;
 struct bed *bedList=NULL, *bed;
 char **row;
 int fieldCount;
 boolean isPsl, isGenePred, isBedWithBlocks;
 boolean pslKnowIfProtein = FALSE, pslIsProtein = FALSE;
 struct sqlConnection *conn = NULL;
 char *dbTable = NULL;
 
-if (isCustomTrack(table))
+if (isCustomTrack(table) || startsWith("myVariants_", table))
     {
     struct customTrack *ct = ctLookupName(table);
+    if (startsWith("myVariants_", table) && ct->dbTableName == NULL)
+        ct->dbTableName = myVariantsResolveDbTableForCustomTrack(ct->tdb->table, cart);
     dbTable = ct->dbTableName;
     conn = hAllocConn(CUSTOM_TRASH);
     hti = hFindTableInfo(CUSTOM_TRASH, region->chrom, dbTable);
     }
 else
     {
     dbTable = table;
     struct trackDb *tdb;
     if(sameWord(db, database))
         tdb = tdbForTrack(db, table, &fullTrackList);
     else
         tdb = hTrackDbForTrack(db, table);
     conn = (tdb ? hAllocConnTrack(db, tdb) : hAllocConn(db));
     hti = hFindTableInfo(db, region->chrom, table);
     }
@@ -292,31 +295,31 @@
 struct region *oldNext = region->next;
 struct bed *bedList = NULL;
 region->next = NULL;
 
 if (isBigBed(database, table, curTrack, ctLookupName))
     bedList = bigBedGetFilteredBedsOnRegions(conn, database, table, region, lm, retFieldCount);
 else if (isLongTabixTable(table))
     bedList = longTabixGetFilteredBedsOnRegions(conn, database, table, region, lm, retFieldCount);
 else if (isBamTable(table))
     bedList = bamGetFilteredBedsOnRegions(conn, database, table, region, lm, retFieldCount);
 else if (isVcfTable(table, &isTabix))
     bedList = vcfGetFilteredBedsOnRegions(conn, database, table, region, lm, retFieldCount,
 					  isTabix);
 else if (isHicTable(table))
     bedList = hicGetFilteredBedsOnRegions(conn, database, table, region, lm, retFieldCount);
-else if (isCustomTrack(table))
+else if (isCustomTrack(table) || startsWith("myVariants_", table))
     bedList = customTrackGetFilteredBeds(database, table, region, lm, retFieldCount);
 else if (sameWord(table, WIKI_TRACK_TABLE))
     bedList = wikiTrackGetFilteredBeds(table, region, lm, retFieldCount);
 else
     bedList = dbGetFilteredBedsOnRegions(conn, database, database, table, table, region, lm,
                                          retFieldCount);
 region->next = oldNext;
 return bedList;
 }
 
 /* Droplist menu for custom track visibility: */
 char *ctVisMenu[] =
 {
     "hide",
     "dense",