0daf709174cdb2a358839e26b1db7821da21e2cd
chmalee
  Mon Nov 20 12:13:16 2023 -0800
Make snp hgc pages use mitochrondrial codon table, refs #32576

diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c
index c6f4c73..5cf76d2 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -18567,30 +18567,33 @@
 int snpCodonPos = geneIsRc ? (2 - ((exonEnd - snpEnd) + exonFrame) % 3) :
 			     (((snpStart - exonStart) + exonFrame) % 3);
 refCodon[0] = getSnpTxBase(gene, exonIx, snpStart, -snpCodonPos);
 refCodon[1] = getSnpTxBase(gene, exonIx, snpStart, 1 - snpCodonPos);
 refCodon[2] = getSnpTxBase(gene, exonIx, snpStart, 2 - snpCodonPos);
 refCodon[3] = '\0';
 if (geneIsRc)
     {
     reverseComplement(refCodon, strlen(refCodon));
     snpCodonPos = 2 - snpCodonPos;
     }
 if (pSnpCodonPos != NULL)
     *pSnpCodonPos = snpCodonPos;
 if (pRefAA != NULL)
     {
+    if (isMito(seqName))
+        *pRefAA = lookupMitoCodon(refCodon);
+    else
         *pRefAA = lookupCodon(refCodon);
     if (*pRefAA == '\0') *pRefAA = '*';
     }
 }
 
 static char *highlightCodonBase(char *codon, int offset)
 /* If codon is a triplet and offset is 0 to 2, highlight the base at the offset.
  * Otherwise just return the given codon sequence unmodified.
  * Don't free the return value! */
 {
 static struct dyString *dy = NULL;
 if (dy == NULL)
     dy = dyStringNew(0);
 dyStringClear(dy);
 if (strlen(codon) != 3)
@@ -18644,31 +18647,35 @@
 		   geneTrack, geneName, snpMisoLinkFromFunc("frameshift"));
 	else if (diff > 0)
 	    printf(firstTwoColumnsPctS "%s (insertion of %d codon%s)\n",
 		   geneTrack, geneName, snpMisoLinkFromFunc("inframe_insertion"),
 		   (int)(diff/3), (diff > 3) ?  "s" : "");
 	else
 	    printf(firstTwoColumnsPctS "%s (deletion of %d codon%s)\n",
 		   geneTrack, geneName, snpMisoLinkFromFunc("inframe_deletion"),
 		   (int)(-diff/3), (diff < -3) ?  "s" : "");
 	}
     else if (alSize == 1 && refIsSingleBase)
         {
         char snpCodon[4];
         safecpy(snpCodon, sizeof(snpCodon), refCodon);
         snpCodon[snpCodonPos] = alBase;
-	char snpAA = lookupCodon(snpCodon);
+        char snpAA = '\0';
+        if (isMito(seqName))
+            snpAA = lookupMitoCodon(snpCodon);
+        else
+            snpAA = lookupCodon(snpCodon);
         if (snpAA == '\0') snpAA = '*';
         char refCodonHtml[16], snpCodonHtml[16];
         safecpy(refCodonHtml, sizeof(refCodonHtml), highlightCodonBase(refCodon, snpCodonPos));
         safecpy(snpCodonHtml, sizeof(snpCodonHtml), highlightCodonBase(snpCodon, snpCodonPos));
         if (refAA != snpAA)
             {
             if (refAA == '*')
                 printf(firstTwoColumnsPctS "%s %c (%s) --> %c (%s)\n",
                        geneTrack, geneName, snpMisoLinkFromFunc("stop-loss"),
                        refAA, refCodonHtml, snpAA, snpCodonHtml);
             else if (snpAA == '*')
                 printf(firstTwoColumnsPctS "%s %c (%s) --> %c (%s)\n",
                        geneTrack, geneName, snpMisoLinkFromFunc("nonsense"),
                        refAA, refCodonHtml, snpAA, snpCodonHtml);
             else