c143e15a268ea9f8338dbde7f9f832cbdbacb5fb
braney
  Fri Jun 13 17:30:18 2025 -0700
color bedMethyl appropriately and add mouseOver

diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c
index 9ca217eade2..ef02f7a7d5e 100644
--- src/hg/hgTracks/simpleTracks.c
+++ src/hg/hgTracks/simpleTracks.c
@@ -8097,30 +8097,66 @@
 vis = limitVisibility(tg);
 }
 
 void loadRefGene(struct track *tg)
 /* Load up RefSeq known genes. */
 {
 enum trackVisibility vis = tg->visibility;
 tg->items = lfFromGenePredInRange(tg, tg->table, chromName, winStart, winEnd);
 if (vis != tvDense)
     {
     lookupRefNames(tg);
     }
 vis = limitVisibility(tg);
 }
 
+/* A spectrum from blue to red signifying the percentage of methylation */
+Color bedMethylColorArray[] =
+{
+0xffff0000,  
+0xffff4444,  
+0xffaa4488,  
+0xff884488,
+0xff4444aa,
+0xff0000ff,
+};
+
+void bedMethylMapItem(struct track *tg, struct hvGfx *hvg, void *item,
+        char *itemName, char *mapItemName, int start, int end, int x, int y, int width, int height)
+/* Return name of item */
+{
+struct bedMethyl *bed = item;
+struct dyString *mouseOver = newDyString(4096);
+
+dyStringPrintf(mouseOver, "Cov %s, %s %% modified, N_mod %s, N_canon %s, N_other %s, N_delete %s, N_fail %s, N_diff %s, N_nocall %s",
+bed->nValidCov, bed->percMod, bed->nMod, bed->nCanon, bed->nOther, bed->nDelete, bed->nFail, bed->nDiff, bed->nNoCall);
+
+mapBoxHgcOrHgGene(hvg, start, end, x, y, width, height, tg->track,
+                  mapItemName, mouseOver->string, NULL, FALSE, NULL);
+}
+
+Color bedMethylColor(struct track *tg, void *item, struct hvGfx *hvg)
+/* Return color to draw methylated site in. */
+{
+struct bedMethyl *bed = (struct bedMethyl *)item;
+
+double percent = atof(bed->percMod) / 100.0;
+
+unsigned index = percent * (sizeof(bedMethylColorArray) / sizeof(Color) - 1) + 0.5;
+
+return bedMethylColorArray[index];
+}
 
 Color blastColor(struct track *tg, void *item, struct hvGfx *hvg)
 /* Return color to draw protein in. */
 {
 struct linkedFeatures *lf = item;
 int col = tg->ixColor;
 char *acc;
 char *colon, *pos;
 char *buffer;
 char cMode[SMALLBUF];
 int colorMode;
 char *blastRef;
 
 if (baseColorGetDrawOpt(tg) > baseColorDrawOff)
     return tg->ixColor;
@@ -12118,31 +12154,32 @@
 void loadBedMethyl(struct track *tg)
 /* Load up bedMethyl type tracks */
 {
 struct customTrack *ct = tg->customPt;
 char *table = tg->table;
 struct sqlConnection *conn;
 if (ct == NULL)
     conn = hAllocConn(database);
 else
     {
     conn = hAllocConn(CUSTOM_TRASH);
     table = ct->dbTableName;
     }
 struct dyString *query = sqlDyStringCreate("select * from %s where ", table);
 hAddBinToQuery(winStart, winEnd, query);
-sqlDyStringPrintf(query, "chrom = '%s' and chromStart < %d and chromEnd > %d",
+// for the moment we're only loading the 'm's and not the 'h's
+sqlDyStringPrintf(query, "chrom = '%s' and chromStart < %d and chromEnd > %d and name = 'm'",
 	       chromName, winEnd, winStart);
 tg->items = bedMethylLoadByQuery(conn, query->string);
 
 hFreeConn(&conn);
 }
 
 void loadPgSnp(struct track *tg)
 /* Load up pgSnp (personal genome SNP) type tracks */
 {
 struct customTrack *ct = tg->customPt;
 char *table = tg->table;
 struct sqlConnection *conn;
 if (ct == NULL)
     conn = hAllocConn(database);
 else
@@ -12200,30 +12237,32 @@
 {
 if (vis == tvDense)
     {
     if (isCenterLabelIncluded(tg))
 	yOff += mgFontLineHeight(font);
     hvGfxTextRight(hvg, leftLabelX, yOff, leftLabelWidth-1, tg->lineHeight,
 		   color, font, tg->shortLabel);
     }
 }
 
 void bedMethylMethods (struct track *tg)
 /* bedMethyl track methods */
 {
 bedMethods(tg);
 tg->loadItems = loadBedMethyl;
+tg->itemColor = bedMethylColor;
+tg->mapItem= bedMethylMapItem;
 tg->canPack = TRUE;
 }
 
 void pgSnpMethods (struct track *tg)
 /* Personal Genome SNPs: show two alleles with stacked color bars for base alleles and
  * (if available) allele counts in mouseover. */
 {
 bedMethods(tg);
 tg->loadItems = loadPgSnp;
 tg->freeItems = freePgSnp;
 tg->totalHeight = pgSnpHeight;
 tg->itemName = pgSnpName;
 tg->drawItemAt = pgSnpDrawAt;
 tg->mapItem = pgSnpMapItem;
 tg->nextItemButtonable = TRUE;