ac21738f7d300c547f394228e274f8f161c49a88 jcasper Mon Mar 17 08:32:53 2025 -0700 Minor change to permit re-use of derived heatmap structures, refs #35320 diff --git src/hg/hgTracks/heatmap.c src/hg/hgTracks/heatmap.c index d0ebb692829..90d1041a3cc 100644 --- src/hg/hgTracks/heatmap.c +++ src/hg/hgTracks/heatmap.c @@ -112,30 +112,33 @@ /* This takes a linkedFeatures structure from a bigBed and builds a heatmap out * of it. In the current setup, the heatmap values and labels are each stored * in a 1-D comma-separated matrix that we convert to a 2-D matrix using * row-major ordering. * The column count is the number of exons in the LF structure; the number of * rows is in an extra field. The full type definition is in hg/lib/heatmap.as. */ { struct bigBedInterval *bbi = lf->original; if (bbi == NULL) { warn("unable to make heatmap from lf - no original bbi"); return NULL; } +if (lf->extra != NULL) + return (struct heatmap*) lf->extra; + #define HEATMAP_COUNT 17 char *bedRow[HEATMAP_COUNT]; // hard-coded for now, should change this to accommodate extra .as fields char startBuf[16], endBuf[16]; bigBedIntervalToRow(bbi, chromName, startBuf, endBuf, bedRow, ArraySize(bedRow)); // Use this to figure out which field to pull. For now, we're just doing 12, 13, 14, 15 // (right after the exons) // 9: exonCount, 10: sizes, 11: starts, 12: rowcount, 13: rowlabels, 14: scores, 15: itemLabels // 16: link to maveDb struct heatmap *h = NULL; int rowCount = atoi(bedRow[12]); int colCount = atoi(bedRow[9]); @@ -222,30 +225,31 @@ if (isNotEmpty(tmpScore[i])) { h->itemLabels[i] = cloneString(tmpScore[i]); } // else, the itemLabels[i] pointer was already zeroed by AllocArray } // Keep track of the min, max, and midpoint of the scores we've read h->highCap = max; h->lowCap = min; h->midPoint = (max+min)/2.0; // The label for this heatmap h->label = cloneString(bedRow[3]); +lf->extra = h; return h; } int heatmapTotalHeight(struct heatmap *h) /* * Need to be able to say how high a heatmap is, including optional column labels * I think. We'll see if and where we want to invoke this. This is probably * dead code and can be removed. */ { // for now, just draw the raw heatmap // final row starts at int(rows*rowHeight). each row ends one pixel before the next, // but we'll need a sanity check for very zoomed out situations (a row might have a