5f3f4e801929d38e98550dc8df784043ff1d8f75
angie
  Tue Mar 30 11:55:05 2021 -0700
Show amino acid back-mutations, not only amino acid differences from reference.

diff --git src/hg/hgPhyloPlace/treeToAuspiceJson.c src/hg/hgPhyloPlace/treeToAuspiceJson.c
index a84e777..f91244c 100644
--- src/hg/hgPhyloPlace/treeToAuspiceJson.c
+++ src/hg/hgPhyloPlace/treeToAuspiceJson.c
@@ -52,31 +52,31 @@
       "    \"scale\": [ [ \"S\", \"#EC676D\" ], [ \"L\", \"#F79E43\" ], [ \"O\", \"#F9D136\" ],"
       "        [ \"V\", \"#FAEA95\" ], [ \"G\", \"#B6D77A\" ], [ \"GH\", \"#8FD4ED\" ],"
       "        [ \"GR\", \"#A692C3\" ] ],"
       "    \"title\": \"GISAID Clade\", \"type\": \"categorical\" },"
           , outF);
 fprintf(outF, "  { \"key\": \"userOrOld\", "
         "    \"scale\": [ [ \"uploaded sample\", \"#CC0000\"] , [ \"%s\", \"#000000\"] ],"
         "    \"title\": \"Sample type\", \"type\": \"categorical\" }"
         , source);
 fputs("  ] , "
 //#*** Filters didn't seem to work... maybe something about the new fetch feature, or do I need to spcify in some other way?
 //#***      "\"filters\": [ \"GISAID_clade\", \"region\", \"country\", \"division\", \"author\" ], "
       "\"filters\": [ ], "
       "\"display_defaults\": { "
       "  \"branch_label\": \"none\", "
-      "  \"color_by\": \"userOrOld\" "
+      "  \"color_by\": \"Nextstrain_clade\" "
       "}, "
       , outF);
 fprintf(outF,
         "\"description\": \"Dataset generated by [UShER web interface]"
         "(%shgPhyloPlace) using the "
         "[usher](https://github.com/yatisht/usher/) program.  "
 //#*** TODO: describe input from which tree was generated: user sample, version of tree, etc.
         , hLocalHostCgiBinUrl());
 fputs("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.\"} ,"
       , outF);
 }
 
 static void jsonWriteObjectValueUrl(struct jsonWrite *jw, char *name, char *value, char *url)
@@ -177,32 +177,41 @@
     char gAlt[2];
     safef(gAlt, sizeof(gAlt), "%c", snc->newBase);
     if (!sameString(gi->psl->strand, "+"))
         errAbort("changesProtein: only worlds for psl->strand='+', but gene '%s' has strand '%s'",
                  gi->psl->qName, gi->psl->strand);
     struct vpTx *vpTx = vpGenomicToTranscript(gSeqWin, &gBed3, gAlt, gi->psl, gi->txSeq);
     if (vpTx->start.region == vpExon)
         {
         int aaStart = vpTx->start.txOffset / 3;
         int codonStart = aaStart * 3;
         char newCodon[4];
         safencpy(newCodon, sizeof newCodon, gi->txSeq->dna + codonStart, 3);
         int codonOffset = vpTx->start.txOffset - codonStart;
         assert(codonOffset < sizeof newCodon);
         newCodon[codonOffset] = snc->newBase;
-        char oldAa = lookupCodon(gi->txSeq->dna + codonStart);
         char newAa = lookupCodon(newCodon);
+        char oldAa;
+        if (snc->parBase == snc->refBase)
+            oldAa = lookupCodon(gi->txSeq->dna + codonStart);
+        else
+            {
+            char oldCodon[4];
+            safencpy(oldCodon, sizeof oldCodon, gi->txSeq->dna + codonStart, 3);
+            oldCodon[codonOffset] = snc->parBase;
+            oldAa = lookupCodon(oldCodon);
+            }
         if (newAa != oldAa)
             {
             isCodingChange = TRUE;
             *retAaStart = aaStart;
             *retOldAa = oldAa;
             *retNewAa = newAa;
             }
         }
     vpTxFree(&vpTx);
     }
 return isCodingChange;
 }
 
 struct slPair *getAaMutations(struct singleNucChange *sncList, struct geneInfo *geneInfoList,
                               struct seqWindow *gSeqWin)