8d662255bea829d680d17220a0b049f5f9c02f16
hiram
  Fri Aug 21 22:32:26 2026 -0700
finalize asmAlias selection issue - if a given GenArk assembly is requested and it exists then use it, otherwise look for an alias refs #38082

diff --git src/hg/lib/asmAlias.c src/hg/lib/asmAlias.c
index e990499be66..dbe13a1dbed 100644
--- src/hg/lib/asmAlias.c
+++ src/hg/lib/asmAlias.c
@@ -1,26 +1,27 @@
 /* asmAlias.c was originally generated by the autoSql program, which also 
  * generated asmAlias.h and asmAlias.sql.  This module links the database and
  * the RAM representation of objects. */
 
 #include "common.h"
 #include "linefile.h"
 #include "dystring.h"
 #include "jksql.h"
 #include "hdb.h"
 #include "asmAlias.h"
 #include "trackHub.h"
+#include "genark.h"
 
 
 
 char *asmAliasCommaSepFieldNames = "alias,browser";
 
 void asmAliasStaticLoad(char **row, struct asmAlias *ret)
 /* Load a row from asmAlias table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->alias = row[0];
 ret->browser = row[1];
 }
 
 struct asmAlias *asmAliasLoadByQuery(struct sqlConnection *conn, char *query)
@@ -175,15 +176,32 @@
     {
     hDisconnectCentral(&centralConn);
     return alias;
     }
 
 char buffer[4096];
 
 sqlSafef(buffer, sizeof buffer, "select * from asmAlias where alias='%s' limit 1", trackHubSkipHubName(alias));
 struct asmAlias *asmAlias = asmAliasLoadByQuery(centralConn, buffer);
 hDisconnectCentral(&centralConn);
 if (asmAlias)
     ret = asmAlias->browser;
 
 return ret;
 }
+
+char *asmAliasFindUnlessGenArk(char *alias)
+/* Like asmAliasFind(), but only translate through the asmAlias table if
+ * alias isn't already a real, existing GenArk hub -- an accession that
+ * resolves on its own should never be promoted to a merely "equivalent"
+ * alias. */
+{
+if ((alias != NULL) && startsWith("hub_", alias))
+    // already a decorated hub_<id>_<name> reference to a specific, already
+    // attached hub -- this is not a raw accession to look up in asmAlias,
+    // and the "hub_<id>_" decoration must not be stripped off.
+    return alias;
+
+if (isGenArk(alias))
+    return alias;
+return asmAliasFind(alias);
+}