34f380bfb0b4003a23fe2e00be6bdac6af326cda
jcasper
Mon Dec 15 15:20:13 2025 -0800
Adding hicArcLimit and hicArcLimitEnabled settings to let people prevent excessive
arc counts from overwhelming a Hi-C display with data, refs #36774
diff --git src/hg/lib/hicUi.c src/hg/lib/hicUi.c
index 1df683007a3..76f6b4433e0 100644
--- src/hg/lib/hicUi.c
+++ src/hg/lib/hicUi.c
@@ -3,30 +3,82 @@
/* Copyright (C) 2019 The Regents of the University of California
* See kent/LICENSE or http://genome.ucsc.edu/license/ for licensing information. */
#include "cheapcgi.h"
#include "cart.h"
#include "hui.h"
#include "web.h"
#include "trackDb.h"
#include "hicUi.h"
#include "cStraw.h"
#include "regexHelper.h"
#include "obscure.h"
#include "htmshell.h"
#include "htmlColor.h"
+boolean hicUiArcLimitEnabled(struct cart *cart, struct trackDb *tdb)
+/* Returns true if the checkbox for limiting the number of displayed arcs is checked */
+{
+//return cartUsualBooleanClosestToHome(cart, tdb, FALSE, HIC_ARC_LIMIT_CHECKBOX, FALSE);
+return cartOrTdbBoolean(cart, tdb, HIC_ARC_LIMIT_CHECKBOX, FALSE);
+}
+
+int hicUiGetArcLimit(struct cart *cart, struct trackDb *tdb)
+/* Returns the currently configured limit on the number of arcs drawn in arc mode.
+ * Defaults to 5000.
+ */
+{
+//int arcLimit = cartUsualIntClosestToHome(cart, tdb, FALSE, HIC_ARC_LIMIT, 5000);
+int arcLimit = cartOrTdbInt(cart, tdb, HIC_ARC_LIMIT, 5000);
+return arcLimit;
+}
+
+void hicUiAddArcLimitJS(struct cart *cart, char *track)
+/* Write out a bit of javascript to associate checking/unchecking the arc count
+ * limit checkbox with deactivating/activating (respectively) the text
+ * input. */
+{
+struct dyString *new = dyStringNew(0);
+dyStringPrintf(new, "$('input[name=\"%s.%s\"]')[0].onclick = function() {", track, HIC_ARC_LIMIT_CHECKBOX);
+dyStringPrintf(new, "if (this.checked) {$('input[name=\"%s.%s\"]')[0].disabled = false; $('span#hicArcLimitText').css('color', '');}", track, HIC_ARC_LIMIT);
+dyStringPrintf(new, "else {$('input[name=\"%s.%s\"]')[0].disabled = true; $('span#hicArcLimitText').css('color', 'gray');} };\n", track, HIC_ARC_LIMIT);
+dyStringPrintf(new, "if (!$('input[name=\"%s.%s\"]')[0].checked) {$('input[name=\"%s.%s\"]')[0].disabled = true; $('span#hicArcLimitText').css('color', 'gray');}\n",
+ track, HIC_ARC_LIMIT_CHECKBOX, track, HIC_ARC_LIMIT);
+jsInline(dyStringContents(new));
+dyStringFree(&new);
+}
+
+void hicUiArcLimitSection(struct cart *cart, struct trackDb *tdb)
+/* Draw the menu inputs associated with selecting whether the track should automatically
+ * scale its color gradient based on the scores present in the view window, or whether it
+ * should stick to a gradient based on a user-selected maximum score. */
+{
+printf("\n");
+char cartVar[1024];
+safef(cartVar, sizeof(cartVar), "%s.%s", tdb->track, HIC_ARC_LIMIT_CHECKBOX);
+boolean arcLimitChecked = hicUiArcLimitEnabled(cart, tdb);
+cgiMakeCheckBox(cartVar, arcLimitChecked);
+int currentLimit = hicUiGetArcLimit(cart, tdb);
+safef(cartVar, sizeof(cartVar), "%s.%s", tdb->track, HIC_ARC_LIMIT);
+printf(" Limit arcs to the ");
+cgiMakeIntVar(cartVar, currentLimit, 6);
+printf(" strongest interactions \n");
+
+hicUiAddArcLimitJS(cart, tdb->track);
+}
+
+
char *hicUiFetchNormalization(struct cart *cart, struct trackDb *tdb, struct hicMeta *meta)
/* Return the current normalization selection, or the default if none
* has been selected. Right now this is a hard-coded set specifically for
* .hic files, but in the future this list might be dynamically determined by
* the contents and format of the Hi-C file. */
{
char cartVar[1024];
safef(cartVar, sizeof(cartVar), "%s.%s", tdb->track, HIC_NORMALIZATION);
char *selected = cartNonemptyString(cart, cartVar);
if (selected == NULL)
selected = trackDbSetting(tdb, HIC_TDB_NORMALIZATION);
char **menu = meta->normOptions;
int i;
char *result = menu[0];
for (i=1; i
\n"); hicUiNormalizationMenu(cart, tdb, trackMeta); puts(" "); hicUiMaxOptionsMenu(cart, tdb, FALSE); puts("
"); hicUiDrawMenu(cart, tdb); puts(" "); hicUiResolutionMenu(cart, tdb, trackMeta); puts(" "); hicUiColorMenu(cart, tdb); puts("
\n"); hicUiMinMaxRangeMenu(cart, tdb); puts("
\n"); +hicUiArcLimitSection(cart, tdb); +puts("
\n"); hicUiFileDetails(trackMeta); cfgEndBox(boxed); } void hicCfgUiComposite(struct cart *cart, struct trackDb *tdb, char *track, char *title, boolean boxed) /* Draw the (empty) list of track configuration options for a composite of Hi-C tracks */ { boxed = cfgBeginBoxAndTitle(tdb, boxed, title); puts("
"); printf("Items are drawn in shades of the chosen color depending on score - scores above the " "chosen maximum are drawn at full intensity.
\n"); hicUiMaxOptionsMenu(cart, tdb, TRUE); puts("
");