0c551e8432f5c9bbf86ac83e49a5c640ae7dbc55
angie
  Fri Jun 2 11:40:19 2023 -0700
Add support for a couple Influenza A RefSeq assemblies -- only for segment 4 (HA gene, the "H" in serotypes like "H3N2") for now since we'll need another menu (or smart matching) in order to support all segments.

diff --git src/hg/hgPhyloPlace/hgPhyloPlace.c src/hg/hgPhyloPlace/hgPhyloPlace.c
index f68e460..e77277f 100644
--- src/hg/hgPhyloPlace/hgPhyloPlace.c
+++ src/hg/hgPhyloPlace/hgPhyloPlace.c
@@ -71,48 +71,72 @@
     char *words[2];
     char *mem;
     unsigned long size;
     chopByWhite(binInfo, words, ArraySize(words));
     mem = (char *)sqlUnsignedLong(words[0]);
     size = sqlUnsignedLong(words[1]);
     lf = lineFileDecompressMem(TRUE, mem, size);
     }
 return lf;
 }
 
 static char *labelForDb(char *db)
 /* The assembly hub name is just the accession; make a special label for hMPXV.  Otherwise just
  * return hGenome(db). */
 {
-char *label = NULL;
-if (sameString(trackHubSkipHubName(db), "GCF_014621545.1"))
-    label = cloneString("hMPXV");
-else if (sameString(trackHubSkipHubName(db), "GCF_002815475.1"))
-    label = cloneString("RSV-A");
-else if (sameString(trackHubSkipHubName(db), "GCF_000855545.1"))
-    label = cloneString("RSV-B");
-else
+char *label = phyloPlaceDbSetting(db, "name");
+if (isEmpty(label))
     label = hGenome(db);
 return label;
 }
 
+static int labelCmp(const void *va, const void *vb)
+/* Compare two slPairs on their string values -- but treat SARS-CoV-2 as more important. */
+{
+const struct slPair *a = *((struct slPair **)va);
+const struct slPair *b = *((struct slPair **)vb);
+if (sameString((char *)(a->val), "SARS-CoV-2"))
+    return -1;
+else if (sameString((char *)(b->val), "SARS-CoV-2"))
+    return 1;
+return strcmp((char *)(a->val), (char *)(b->val));
+}
+
+
+static struct slName *sortByLabel(struct slName *dbList)
+/* Return a newly allocated version of dbList, sorted by labelForDb value -- but favor SARS-CoV-2. */
+{
+struct slPair *dbLabelList = NULL;
+struct slName *sln;
+for (sln = dbList;  sln != NULL;  sln = sln->next)
+    slPairAdd(&dbLabelList, sln->name, cloneString(labelForDb(sln->name)));
+slSort(&dbLabelList, labelCmp);
+struct slName *newList = NULL;
+struct slPair *slp;
+for (slp = dbLabelList;  slp != NULL;  slp = slp->next)
+    slAddHead(&newList, slNameNew(slp->name));
+slReverse(&newList);
+slPairFreeValsAndList(&dbLabelList);
+return newList;
+}
+
 static void selectDb(char **pDb, char **pLabel)
 /* Search for assembly config.ra files in hgPhyloPlaceData.  If there is more than one
  * supported assembly, then make a menu / select input for supported  assemblies;
  * reload the page on change. */
 {
-struct slName *supportedDbs = phyloPlaceDbList(cart);
+struct slName *supportedDbs = sortByLabel(phyloPlaceDbList(cart));
 if (supportedDbs == NULL)
     errAbort("Sorry, this server is not configured to perform phylogenetic placement.");
 if (!slNameInList(supportedDbs, *pDb))
     {
     *pDb = cloneString(supportedDbs->name);
     }
 *pLabel = labelForDb(*pDb);
 int supportedDbCount = slCount(supportedDbs);
 if (supportedDbCount > 1)
     {
     char *labels[supportedDbCount];
     char *values[supportedDbCount];
     struct slName *sDb;
     int i;
     for (sDb = supportedDbs, i = 0;  i < supportedDbCount;  sDb = sDb->next, i++)