98874f1656202cd5781466a5d9b25f47da1f104d
hiram
  Mon Feb 13 16:03:53 2023 -0800
a bit closer to correct NCBI links, not perfect, but better than it was no redmine

diff --git src/hg/lib/asmEquivalent.c src/hg/lib/asmEquivalent.c
index 3971aadd..7942c2c 100644
--- src/hg/lib/asmEquivalent.c
+++ src/hg/lib/asmEquivalent.c
@@ -243,62 +243,58 @@
 fprintf(f,"sourceCount");
 fputc('"',f);
 fputc(':',f);
 fprintf(f, "%lld", el->sourceCount);
 fputc(',',f);
 fputc('"',f);
 fprintf(f,"destinationCount");
 fputc('"',f);
 fputc(':',f);
 fprintf(f, "%lld", el->destinationCount);
 fputc('}',f);
 }
 
 /* -------------------------------- End autoSql Generated Code -------------------------------- */
 
-char *asmEquivalentUcscToNCBI(char *ucscName)
-/* check if there is a RefSeq/GenBank equivalent to this UCSC assembly name.
- *    If RefSeq exists, return that first, else if GenBank than return that.
+char *asmEquivalentUcscToNCBI(char *ucscName, char *authority)
+/* check if there is an "authority" equivalent to this UCSC assembly name.
+ *    where 'authority' in this case is either 'refseq' or 'genbank'
  * No checking of sequence match counts in this first implementation,
  *    therefore, could be a fuzzy match, and since it is returning only the
  *    first one, it might not be the best match.  Could add more specifics
  *    later to get better match.
  */
 {
 char *ret = NULL;
 if (ucscName == NULL)
     return ret;
 
+
 struct sqlConnection *conn = hAllocConn("hgFixed");
 if (!conn)
     return ret;
 
 if (!sqlTableExists(conn, "asmEquivalent"))
     {
     hFreeConn(&conn);
     return ret;
     }
 
 char buffer[4096];
 
-sqlSafef(buffer, sizeof buffer, "SELECT destination FROM asmEquivalent WHERE sourceAuthority='ucsc' AND destinationAuthority='refseq' AND source='%s' LIMIT 1", ucscName);
+sqlSafef(buffer, sizeof buffer, "SELECT destination FROM asmEquivalent WHERE sourceAuthority='ucsc' AND destinationAuthority='%s' AND source='%s' LIMIT 1", authority, ucscName);
 char *sqlAnswer = sqlQuickString(conn, buffer);
-if (isEmpty(sqlAnswer))
-    {
-    sqlSafef(buffer, sizeof buffer, "SELECT destination FROM asmEquivalent WHERE sourceAuthority='ucsc' AND destinationAuthority='genbank' AND source='%s' LIMIT 1", ucscName);
-    sqlAnswer = sqlQuickString(conn, buffer);
-    }
 hFreeConn(&conn);
 
 /* if there is a result, for example: GCA_000001405.28_GRCh38.p13
  *    want to return only: GCA_000001405.28
  */
 if (isNotEmpty(sqlAnswer))
     {
     char *words[3];
     int wordCount = 0;
     wordCount = chopString(sqlAnswer, "_", words, ArraySize(words));
     if (3 != wordCount)	/* something wrong with this answer */
        return ret;
     safef(buffer, sizeof(buffer), "%s_%s", words[0], words[1]);
     ret = cloneString(buffer);
     }