fb697a0c3d6910f8acd9725fd420f6cd42be64e9
max
  Wed May 11 16:12:06 2016 -0700
new gbic script, refs #14399

diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c
index d2f38de..44597fb 100644
--- src/hg/lib/hdb.c
+++ src/hg/lib/hdb.c
@@ -758,30 +758,44 @@
 boolean hCanHaveSplitTables(char *db)
 /* Return TRUE if split tables are allowed in database. */
 {
 struct sqlConnection *conn = hAllocConn(db);
 int count = sqlTableSizeIfExists(conn, "chromInfo");
 hFreeConn(&conn);
 return (count >= 0 && count <= HDB_MAX_SEQS_FOR_SPLIT);
 }
 
 static void tableListHashAdd(struct hash *dbTblHash, char *profile, char *db)
 /* Add to a hash that maps a track/table name (unsplit) to an slName list
  * of actual table names (possibly split) -- we can compute this once and
  * cache it to save a lot of querying if we will check existence of
  * lots of tables. */
 {
+if (trackHubDatabase(db))
+    {
+    struct trackHub *hub = hubConnectGetHubForDb(db);
+    if (hub != NULL)
+        {
+        struct trackHubGenome *hubGenome = trackHubFindGenome(hub, db);
+        struct trackDb *tdbList = trackHubTracksForGenome(hub, hubGenome), *tdb;
+        for (tdb = tdbList;  tdb != NULL;  tdb = tdb->next)
+            {
+            hashAdd(dbTblHash, tdb->table, slNameNew(tdb->table));
+            }
+        }
+    return;
+    }
 struct sqlConnection *conn = hAllocConnProfile(profile, db);
 struct slName *allTables =  sqlListTables(conn);
 
 if (!sameString(CUSTOM_TRASH,db) && !sameString("hgFixed",db) && hCanHaveSplitTables(db))
     {
     /* Consolidate split tables into one list per track: */
     struct slName *tbl = NULL, *nextTbl = NULL;
     for (tbl = allTables;  tbl != NULL;  tbl = nextTbl)
 	{
 	struct hashEl *tHel = NULL;
 	char trackName[HDB_MAX_TABLE_STRING];
 	char chrom[HDB_MAX_CHROM_STRING];
 	nextTbl = tbl->next;
 	tbl->next = NULL;
 	hParseTableName(db, tbl->name, trackName, chrom);