61f9643c131fb8ff8d1fbf75d8562c98668d61c7
chmalee
  Mon Feb 26 13:14:46 2024 -0800
Make codon numbers in mouseovers show up at the cds color level and not just the cds number level, fix incorrect mouseovers on introns that was broken by previous change, refs #32815

diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c
index 7e91985..0399fbc 100644
--- src/hg/hgTracks/simpleTracks.c
+++ src/hg/hgTracks/simpleTracks.c
@@ -2959,31 +2959,31 @@
                         {
                         if (startPhase==0)
                             exonNote = " → in-frame exon";
                         safef(buf, sizeof(buf), ", start codon phase %d%s", startPhase, exonNote);
                         }
                     frameText = buf;
                     }
                 }
 
 	    if (w > 0) // draw exon or intron if width is greater than 0
 		{
                 // draw mapBoxes for the codons if we are zoomed in far enough
                 struct simpleFeature *codon;
                 struct dyString *codonDy = dyStringNew(0);
                 int codonS, codonE;
-                if (lf->codons && zoomedToCodonNumberLevel)
+                if (isExon && lf->codons && zoomedToCdsColorLevel)
                     {
                     for (codon = lf->codons; codon != NULL; codon = codon->next)
                         {
                         codonS = codon->start; codonE = codon->end;
                         if (codonS <= winEnd && codonE >= winStart)
                             {
                             int codonSClp = (codonS < winStart) ? winStart : codonS;
                             int codonEClp = (codonE > winEnd)   ? winEnd   : codonE;
 
                             int codonsx = round((codonSClp - winStart)*scale) + insideX;
                             int codonex = round((codonEClp - winStart)*scale) + insideX;
 
                             // skip regions entirely outside available picture
                             // (accounts for space taken by exon arrows buttons)
                             if (codonsx <= picEnd && codonex >= picStart)
@@ -2991,30 +2991,31 @@
                                 // clip it to avail pic
                                 codonsx = (codonsx < picStart) ? picStart : codonsx;
                                 codonex = (codonex > picEnd)   ? picEnd   : codonex;
 
                                 int w = codonex - codonsx;
                                 if (w > 0)
                                     {
                                     // temporarily remove the mouseOver from the lf, since linkedFeatureMapItem will always 
                                     // prefer a lf->mouseOver over the itemName
                                     char *oldMouseOver = lf->mouseOver;
                                     lf->mouseOver = NULL;
                                     dyStringClear(codonDy);
                                     if (!isEmpty(existingText))
                                         dyStringPrintf(codonDy, "%s, ", existingText);
                                     int codonHgvsIx = (codon->codonIndex - 1) * 3;
+                                    if (codonHgvsIx >= 0)
                                         dyStringPrintf(codonDy, "c.%d-%d, ", codonHgvsIx + 1, codonHgvsIx + 3);
                                     dyStringPrintf(codonDy, "strand %c, %s %d of %d%s",
                                                 strandChar, exonIntronText, exonIntronNumber, numExonIntrons, frameText);
                                     tg->mapItem(tg, hvg, item, codonDy->string, tg->mapItemName(tg, item),
                                             sItem, eItem, codonsx, y, w, heightPer);
                                     // and restore the mouseOver
                                     lf->mouseOver = oldMouseOver;
                                     }
                                 }
                             }
                         }
                     }
                 else
                     {
                     // temporarily remove the mouseOver from the lf, since linkedFeatureMapItem will always