7e5840e03baf4a7b7c198016c393d0b86f7b72b6
braney
  Tue Nov 16 15:25:19 2021 -0800
allow hgc pages on chains to provide a link to the "other" browser if
the other assembly is an unattached genark assembly hub

diff --git src/hg/lib/hubConnect.c src/hg/lib/hubConnect.c
index dd3cc70..8b1dbee 100644
--- src/hg/lib/hubConnect.c
+++ src/hg/lib/hubConnect.c
@@ -12,74 +12,61 @@
 #include "hash.h"
 #include "dystring.h"
 #include "sqlNum.h"
 #include "jksql.h"
 #include "hdb.h"
 #include "net.h"
 #include "trackHub.h"
 #include "hubConnect.h"
 #include "hui.h"
 #include "errCatch.h"
 #include "obscure.h"
 #include "hgConfig.h"
 #include "grp.h"
 #include "udc.h"
 #include "hubPublic.h"
+#include "genark.h"
 
 boolean isHubTrack(char *trackName)
 /* Return TRUE if it's a hub track. */
 {
 return startsWith(hubTrackPrefix, trackName);
 }
 
 static char *hubStatusTableName = NULL;
 static char *_hubPublicTableName = NULL;
 
 static char *getHubStatusTableName()
 /* return the hubStatus table name from the environment, 
  * or hg.conf, or use the default.  Cache the result */
 {
 if (hubStatusTableName == NULL)
     hubStatusTableName = cfgOptionEnvDefault("HGDB_HUB_STATUS_TABLE",
 	    hubStatusTableConfVariable, defaultHubStatusTableName);
 
 return hubStatusTableName;
 }
 
 char *hubPublicTableName()
 /* Get the name of the table that lists public hubs.  Don't free the result. */
 {
 if (_hubPublicTableName == NULL)
     _hubPublicTableName = cfgOptionEnvDefault("HGDB_HUB_PUBLIC_TABLE", hubPublicTableConfVariable,
                                              defaultHubPublicTableName);
 return _hubPublicTableName;
 }
 
-static char *_genArkTableName = NULL;
-
-static char *genArkTableName()
-/* return the genark table name from the environment, 
- * or hg.conf, or use the default.  Cache the result */
-{
-if (_genArkTableName == NULL)
-    _genArkTableName = cfgOptionEnvDefault("HGDB_GENARK_STATUS_TABLE",
-	    genArkTableConfVariable, defaultGenArkTableName);
-
-return _genArkTableName;
-}
-
-
 boolean hubConnectTableExists()
 /* Return TRUE if the hubStatus table exists. */
 {
 struct sqlConnection *conn = hConnectCentral();
 boolean exists = sqlTableExists(conn, getHubStatusTableName());
 hDisconnectCentral(&conn);
 return exists;
 }
 
 void hubConnectStatusFree(struct hubConnectStatus **pHub)
 /* Free hubConnectStatus */
 {
 struct hubConnectStatus *hub = *pHub;
 if (hub != NULL)
     {
@@ -905,59 +892,59 @@
 if (genome == NULL)
     return FALSE;
 
 struct trackHub *trackHub = genome->trackHub;
 
 if ((trackHub != NULL) && (trackHub->hubStatus != NULL))
     return trackHub->hubStatus->id;
 return 0;
 }
 
 static boolean lookForLonelyHubs(struct cart *cart, struct hubConnectStatus  *hubList, char **newDatabase, char *genarkPrefix)
 // We go through the hubs and see if any of them reference an assembly
 // that is NOT currently loaded, but we know a URL to load it.
 {
 struct sqlConnection *conn = hConnectCentral();
-if (!sqlTableExists(conn, genArkTableName()))
+if (!sqlTableExists(conn, genarkTableName()))
     return FALSE;
 
 boolean added = FALSE;
 
 struct hubConnectStatus  *hub;
 for(hub = hubList; hub; hub = hub->next)
     {
     struct trackHub *tHub = hub->trackHub;
     if (tHub == NULL)
         continue;
 
     struct trackHubGenome *genomeList = tHub->genomeList, *genome;
 
     for(genome = genomeList; genome; genome = genome->next)
         {
         char *name = genome->name;
 
         if (!hDbIsActive(name) )
             {
             char buffer[4096];
             unsigned newId = 0;
 
             // look with undecorated name for an attached assembly hub
             if (!(newId = lookForUndecoratedDb(name)))
                 {
                 // see if genark has this assembly
                 char query[4096];
-                sqlSafef(query, sizeof query, "select hubUrl from %s where gcAccession='%s'", genArkTableName(), name);
+                sqlSafef(query, sizeof query, "select hubUrl from %s where gcAccession='%s'", genarkTableName(), name);
                 if (sqlQuickQuery(conn, query, buffer, sizeof buffer))
                     {
                     char url[4096];
                     safef(url, sizeof url, "%s/%s", genarkPrefix, buffer);
 
                     struct hubConnectStatus *status = getAndSetHubStatus( cart, url, TRUE);
 
                     if (status)
                         {
                         newId = status->id;
                         added = TRUE;
                         }
                     }
                 }