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/treeToAuspiceJson.c src/hg/hgPhyloPlace/treeToAuspiceJson.c
index b43eb40..8de17ee 100644
--- src/hg/hgPhyloPlace/treeToAuspiceJson.c
+++ src/hg/hgPhyloPlace/treeToAuspiceJson.c
@@ -113,55 +113,62 @@
 if (slNameInList(colorFields, "pango_lineage_usher"))
     colorDefault = "pango_lineage_usher";
 else if (slNameInList(colorFields, "Nextstrain_lineage"))
     colorDefault = "Nextstrain_lineage";
 else if (slNameInList(colorFields, "Nextstrain_clade"))
     colorDefault = "Nextstrain_clade";
 else if (slNameInList(colorFields, "goya_usher"))
     colorDefault = "goya_usher";
 else if (colorFields != NULL)
     colorDefault = colorFields->name;
 else
     colorDefault = "userOrOld";
 return colorDefault;
 }
 
-static void auspiceMetaColorings(struct jsonWrite *jw, char *source, struct slName *colorFields)
+static void auspiceMetaColorings(struct jsonWrite *jw, char *source, struct slName *colorFields,
+                                 char *db)
 /* Write coloring specs for colorFields from metadata, locally added userOrOld, and
  * Auspice-automatic gt. */
 {
 jsonWriteListStart(jw, "colorings");
 auspiceMetaColoringCategoricalStart(jw, "userOrOld", "Sample type");
 jsonWriteListStart(jw, "scale");
 jsonWritePair(jw, "uploaded sample", "#CC0000");
 jsonWritePair(jw, source, "#000000");
 jsonWriteListEnd(jw);
 auspiceMetaColoringCategoricalEnd(jw);
 auspiceMetaColoringCategorical(jw, "gt", "Genotype");
 struct slName *col;
 for (col = colorFields;  col != NULL;  col = col->next)
     {
     if (sameString(col->name, "Nextstrain_clade"))
+        {
+        if (sameString(db, "wuhCor1"))
             auspiceMetaColoringSarsCov2Nextclade(jw, col->name, "Nextstrain Clade");
+        else
+            auspiceMetaColoringCategorical(jw, col->name, "Clade assigned by nextclade");
+        }
     else if (sameString(col->name, "Nextstrain_clade_usher"))
         auspiceMetaColoringSarsCov2Nextclade(jw, col->name, "Nextstrain Clade assigned by UShER");
     else if (sameString(col->name, "pango_lineage"))
         auspiceMetaColoringCategorical(jw, col->name, "Pango lineage");
     else if (sameString(col->name, "pango_lineage_usher"))
         auspiceMetaColoringCategorical(jw, col->name, "Pango lineage assigned by UShER");
     else if (sameString(col->name, "Nextstrain_lineage"))
         auspiceMetaColoringCategorical(jw, col->name, "Nextstrain lineage");
+    //#*** RSV hacks -- colorings really should come from JSON file in config directory
     else if (sameString(col->name, "goya_nextclade"))
         auspiceMetaColoringCategorical(jw, col->name, "Goya 2020 clade assigned by nextclade");
     else if (sameString(col->name, "goya_usher"))
         auspiceMetaColoringCategorical(jw, col->name, "Goya 2020 clade assigned by UShER");
     else if (sameString(col->name, "ramaekers_nextclade"))
         auspiceMetaColoringCategorical(jw, col->name, "Ramaekers 2020 clade assigned by nextclade");
     else if (sameString(col->name, "ramaekers_usher"))
         auspiceMetaColoringCategorical(jw, col->name, "Ramaekers 2020 clade assigned by UShER");
     else if (sameString(col->name, "ramaekers_tableS1"))
         auspiceMetaColoringCategorical(jw, col->name, "Ramaekers 2020 Table S1 designation");
     else if (sameString(col->name, "country"))
         auspiceMetaColoringCategorical(jw, col->name, "Country");
     else
         auspiceMetaColoringCategorical(jw, col->name, col->name);
     }
@@ -194,52 +201,57 @@
                  "If you have metadata you wish to display, you can now drag on a CSV file and "
                  "it will be added into this view, [see here]("NEXTSTRAIN_DRAG_DROP_DOC") "
                  "for more info."
                  , hLocalHostCgiBinUrl());
 // Panels: just the tree and  entropy (no map)
 jsonWriteListStart(jw, "panels");
 jsonWriteString(jw, NULL, "tree");
 jsonWriteString(jw, NULL, "entropy");
 jsonWriteListEnd(jw);
 // Default label & color
 jsonWriteObjectStart(jw, "display_defaults");
 jsonWriteString(jw, "branch_label", "aa mutations");
 jsonWriteString(jw, "color_by", getDefaultColor(colorFields));
 jsonWriteObjectEnd(jw);
 // Colorings: userOrOld, gt and whatever we got from metadata
-auspiceMetaColorings(jw, source, colorFields);
+auspiceMetaColorings(jw, source, colorFields, db);
 // Filters didn't work when I tried them a long time ago... revisit someday.
 jsonWriteListStart(jw, "filters");
 jsonWriteString(jw, NULL, "userOrOld");
 jsonWriteString(jw, NULL, "country");
-//#*** FIXME: TODO: either pass in along with sampleMetadata, or better yet, compute while building
-//#*** tree object in memory, then write the header object, then write the tree.
+//#*** FIXME: TODO: either pass in along with sampleMetadata, or take from JSON file specified
+//#*** in config, or better yet, compute while building tree object in memory, then write the
+//#*** header object, then write the tree.
 if (sameString(db, "wuhCor1"))
     {
     jsonWriteString(jw, NULL, "pango_lineage_usher");
     jsonWriteString(jw, NULL, "pango_lineage");
     jsonWriteString(jw, NULL, "Nextstrain_clade_usher");
     jsonWriteString(jw, NULL, "Nextstrain_clade");
     }
 else if (stringIn("GCF_000855545", db) || stringIn("GCF_002815475", db))
     {
     jsonWriteString(jw, NULL, "goya_usher");
     jsonWriteString(jw, NULL, "goya_nextclade");
     jsonWriteString(jw, NULL, "ramaekers_tableS1");
     jsonWriteString(jw, NULL, "ramaekers_usher");
     jsonWriteString(jw, NULL, "ramaekers_nextclade");
     }
+else if (stringIn("GCF_000865085", db) || stringIn("GCF_001343785", db))
+    {
+    jsonWriteString(jw, NULL, "Nextstrain_clade");
+    }
 else
     {
     jsonWriteString(jw, NULL, "Nextstrain_lineage");
     }
 jsonWriteListEnd(jw);
 // Annotations for coloring/filtering by base
 writeAuspiceMetaGenomeAnnotations(jw, geneInfoList, genomeSize);
 jsonWriteObjectEnd(jw);
 }
 
 static void jsonWriteObjectValueUrl(struct jsonWrite *jw, char *name, char *value, char *url)
 /* Write an object with member "value" set to value, and if url is non-empty, "url" set to url. */
 {
 jsonWriteObjectStart(jw, name);
 jsonWriteString(jw, "value", value);
@@ -782,51 +794,57 @@
 return geneInfoList;
 }
 
 void treeToAuspiceJson(struct subtreeInfo *sti, char *db, struct geneInfo *geneInfoList,
                        struct seqWindow *gSeqWin, struct hash *sampleMetadata,
                        struct hash *sampleUrls, struct hash *samplePlacements,
                        char *jsonFile, char *source)
 /* Write JSON for tree in Nextstrain's Augur/Auspice V2 JSON format
  * (https://github.com/nextstrain/augur/blob/master/augur/data/schema-export-v2.json). */
 {
 struct phyloTree *tree = sti->subtree;
 FILE *outF = mustOpen(jsonFile, "w");
 struct jsonWrite *jw = jsonWriteNew();
 jsonWriteObjectStart(jw, NULL);
 jsonWriteString(jw, "version", "v2");
-//#*** FIXME: TODO: either pass in along with sampleMetadata, or better yet, compute while building
-//#*** tree object in memory, then write the header object, then write the tree.
+//#*** FIXME: TODO: either pass in along with sampleMetadata, or take from JSON file specified
+//#*** in config, or better yet, compute while building tree object in memory, then write the
+//#*** header object, then write the tree.
 boolean isRsv = (stringIn("GCF_000855545", db) || stringIn("GCF_002815475", db));
 struct slName *colorFields = NULL;
 if (sameString(db, "wuhCor1"))
     {
     slNameAddHead(&colorFields, "country");
     slNameAddHead(&colorFields, "Nextstrain_clade_usher");
     slNameAddHead(&colorFields, "pango_lineage_usher");
     slNameAddHead(&colorFields, "Nextstrain_clade");
     slNameAddHead(&colorFields, "pango_lineage");
     }
 else if (isRsv)
     {
     slNameAddHead(&colorFields, "country");
     slNameAddHead(&colorFields, "ramaekers_nextclade");
     slNameAddHead(&colorFields, "ramaekers_usher");
     slNameAddHead(&colorFields, "ramaekers_tableS1");
     slNameAddHead(&colorFields, "goya_nextclade");
     slNameAddHead(&colorFields, "goya_usher");
     }
+else if (stringIn("GCF_000865085", db) || stringIn("GCF_001343785", db))
+    {
+    slNameAddHead(&colorFields, "country");
+    slNameAddHead(&colorFields, "Nextstrain_clade");
+    }
 else
     {
     slNameAddHead(&colorFields, "country");
     slNameAddHead(&colorFields, "Nextstrain_lineage");
     }
 //#*** END FIXME
 writeAuspiceMeta(jw, sti->subtreeUserSampleIds, source, db, colorFields, geneInfoList,
                  gSeqWin->end);
 jsonWriteObjectStart(jw, "tree");
 int nodeNum = 10000; // Auspice.us starting node number for newick -> json
 int depth = 0;
 
 // Add an extra root node because otherwise Auspice won't draw branch from big tree root to subtree
 struct phyloTree *root = phyloTreeNewNode("wrapper");
 phyloAddEdge(root, tree);