bc4639b87acf68232656130b2972293975e11933
braney
  Thu Sep 10 12:43:45 2026 -0700
genark: tolerate a missing or stale genarkOrg table, refs #38327

genarkGetOrgHash() aborted when the central database had no genarkOrg
table.  A mirror's hgcentral has never had one: buildHgCentralSql.csh did
not list the table, so hgcentral.sql on hgdownload carries neither its rows
nor its schema.  Add an sqlTableExists check, and add genarkOrg to the list
of tables that hgcentral.sql replaces entirely.

genarkMakeDbDb() defaulted genome to "Other" for an accession with no
genarkOrg row, but left organism NULL.  hgConvert prints organism, so the
Convert page read "Genome: (null)".  Default both.  The copy of genarkOrg
on the RR is 20,754 rows behind hgwdev, so this is visible on
genome.ucsc.edu today for 23 of the 855 GenArk assemblies that appear in
liftOverChain.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

diff --git src/hg/lib/genark.c src/hg/lib/genark.c
index 8816e33773b..93f3b0d8fb7 100644
--- src/hg/lib/genark.c
+++ src/hg/lib/genark.c
@@ -390,31 +390,31 @@
 {
 struct dbDb *dbDb;
 struct hash *orgHash = genarkGetOrgHash();
 
 AllocVar(dbDb);
 
 dbDb->name = cloneString(row[0]);
 dbDb->nibPath = cloneString("genark"); 
 dbDb->description = cloneString(row[4]); // commonName
 dbDb->scientificName = cloneString(row[3]); 
 dbDb->taxId = atoi(row[5]); 
 dbDb->organism = dbDb->genome = hashFindVal(orgHash, row[0]);
 dbDb->orderKey = 99999;
 dbDb->defaultPos = "default";
 if (dbDb->genome == NULL)
-    dbDb->genome = "Other";
+    dbDb->organism = dbDb->genome = "Other";
 
 return dbDb;
 }
 
 struct dbDb *genarkLiftOverDbs(char *listOfAccs)
 /* return list of dbDb structures for the genark genomes that match listOfAccs */
 {
 if (!cfgOption("genarkLiftOver"))
     return NULL;
 struct dbDb *list = NULL;
 char query[64 * 1024];
 
 safef(query, sizeof query, "NOSQLINJ select * from %s where gcAccession in (%s)", genarkTableName(), listOfAccs);
 struct sqlConnection *conn = hConnectCentral();
 struct sqlResult *sr;
@@ -444,24 +444,31 @@
 struct hash *genarkGetOrgHash()
 /* read table that maps gcAccession to UCSC org. */
 {
 static struct hash *orgHash = NULL;
 
 if (orgHash != NULL)
     return orgHash;
 char query[64 * 1024];
 
 sqlSafef(query, sizeof query, "select * from %s", "genarkOrg");
 struct sqlConnection *conn = hConnectCentral();
 struct sqlResult *sr;
 char **row;
 orgHash = newHash(0);
 
+/* a mirror's hgcentral may not have this table */
+if (!sqlTableExists(conn, "genarkOrg"))
+    {
+    hDisconnectCentral(&conn);
+    return orgHash;
+    }
+
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     hashAdd(orgHash, cloneString(row[0]), cloneString(row[1]));
     }
 sqlFreeResult(&sr);
 hDisconnectCentral(&conn);
 return orgHash;
 }