60aca91bcce6d4fa555e6c7c91d8ff8aa9e7bd2b jcasper Fri Jun 11 15:17:21 2021 -0700 Updating hic support for files with large headers (over 100kb) and improving multi-region performance, refs #18842, #27593 diff --git src/hg/hgTracks/hicTrack.c src/hg/hgTracks/hicTrack.c index df58233..420b63d 100644 --- src/hg/hgTracks/hicTrack.c +++ src/hg/hgTracks/hicTrack.c @@ -1,28 +1,28 @@ /* hic -- draw Hi-C maps */ /* Copyright (C) 2018 The Regents of the University of California * See README in this or parent directory for licensing information. */ #include "common.h" #include "obscure.h" #include "hgTracks.h" #include "bedCart.h" #include "bigWarn.h" #include "interact.h" // for interact structures #include "hicUi.h" -#include "Cstraw.h" +#include "cStraw.h" #include "hic.h" #include "htmlColor.h" static int hicTotalHeight(struct track *tg, enum trackVisibility vis) /* Calculate height of the track across all windows. For arc and triangle, this * depends on the actual interactions being drawn. For square, it just depends * on the height of the highest square (yes, this currently means smaller * squares are stretched vertically in multi-region - it's not ideal). */ { int maxHeight = 0; struct track *trackScan = tg; while (trackScan != NULL) // Canvas max height for this and previous windows ... { @@ -142,31 +142,41 @@ if (filtNumRecords > 0) tg->graphUpperLimit = 2.0*doubleMedian(filtNumRecords, countsCopy); else tg->graphUpperLimit = 0.0; if (countsCopy != NULL) freeMem(countsCopy); tg->items = hicItems; } void hicLoadItems(struct track *tg) /* Load Hi-C items in (mostly) interact format */ { char *filename = trackDbSettingOrDefault(tg->tdb, "bigDataUrl", NULL); if (filename == NULL) return; +if (tg->customPt == NULL) + { tg->customPt = grabHeader(tg); + struct track *hicInNextWindow = tg->nextWindow; + while (hicInNextWindow != NULL) + { + // pre-cache the hic header info; no reason to re-fetch + hicInNextWindow->customPt = tg->customPt; + hicInNextWindow = hicInNextWindow->nextWindow; + } + } if (tg->customPt == NULL) return; loadAndFilterItems(tg); } Color *colorSetForHic(struct hvGfx *hvg, struct track *tg, int bucketCount) /* Create the gradient color array for drawing a Hi-C heatmap */ { struct rgbColor rgbLow; char *lowColorText = hicUiFetchBgColor(cart, tg->tdb); // This is an HTML color like #ffed02 unsigned lowRgbVal = 0; if (!htmlColorForCode(lowColorText, &lowRgbVal)) { warn("Bad RGB background color value %s for track %s", lowColorText, tg->track);