ddb85ced5e8b6127a233b5cda5fcb1fbe2260578
max
  Wed Mar 25 04:22:06 2026 -0700
Add detailsScript trackDb mechanism for JS visualizations on bigBed details pages

Changing based on feedback from Jonathan, Chris and Brian after group
discussion. Refactored existing Claude-generated code, moving functions
into libraries.

This is the first use of ES6 modules in the kent js code. In 2026, this
should be acceptable?

New trackDb syntax: detailsScript.<plotType>.<fieldName> <jsonConfig>
The C code (bigBedClick.c) collects these settings, exports field values as JSON
(bedDetails object), and dynamically imports hgc.<plotType>.js as an ES6 module.
Fields used by detailsScript are shown in the HTML table with empty values,
filled by JavaScript.

Includes hgc.histogram.js module for drawing SVG bar chart histograms from
logfmt-encoded data (space-separated key=value pairs). Applied to both the
trexplorer and webstr tracks in the strVar supertrack.

Also adds jsonWriteJsonElement() helper to jsonWrite.c for writing parsed
jsonElement trees into a jsonWrite stream.

max, refs #36652
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

diff --git src/hg/makeDb/scripts/webstr/webstr.as src/hg/makeDb/scripts/webstr/webstr.as
index 603dcd0b82f..42cc933629e 100644
--- src/hg/makeDb/scripts/webstr/webstr.as
+++ src/hg/makeDb/scripts/webstr/webstr.as
@@ -1,31 +1,26 @@
 table webstr
 "WebSTR short tandem repeat loci with allele frequency data from EnsembleTR panel"
     (
     string chrom;        "Chromosome"
     uint chromStart;     "Start position"
     uint chromEnd;       "End position"
-    string name;         "Repeat ID"
+    string name;         "Repeat motif x copy count"
     uint score;          "Score (0-1000)"
     char[1] strand;      "Strand"
     uint thickStart;     "Thick start (same as chromStart)"
     uint thickEnd;       "Thick end (same as chromEnd)"
     uint reserved;       "Item color RGB"
     string motif;        "Repeat unit motif"
     uint period;         "Length of repeat unit"
     uint numCopies;      "Number of repeat copies in reference"
-    lstring afrAlleles;  "AFR alleles (comma-separated repeat counts)"
-    lstring afrFreqs;    "AFR allele frequencies (comma-separated)"
+    lstring afrHist;     "AFR allele frequency histogram (space-separated allele=freq pairs)"
     uint afrN;           "AFR sample count"
-    lstring amrAlleles;  "AMR alleles (comma-separated repeat counts)"
-    lstring amrFreqs;    "AMR allele frequencies (comma-separated)"
+    lstring amrHist;     "AMR allele frequency histogram (space-separated allele=freq pairs)"
     uint amrN;           "AMR sample count"
-    lstring easAlleles;  "EAS alleles (comma-separated repeat counts)"
-    lstring easFreqs;    "EAS allele frequencies (comma-separated)"
+    lstring easHist;     "EAS allele frequency histogram (space-separated allele=freq pairs)"
     uint easN;           "EAS sample count"
-    lstring eurAlleles;  "EUR alleles (comma-separated repeat counts)"
-    lstring eurFreqs;    "EUR allele frequencies (comma-separated)"
+    lstring eurHist;     "EUR allele frequency histogram (space-separated allele=freq pairs)"
     uint eurN;           "EUR sample count"
-    lstring sasAlleles;  "SAS alleles (comma-separated repeat counts)"
-    lstring sasFreqs;    "SAS allele frequencies (comma-separated)"
+    lstring sasHist;     "SAS allele frequency histogram (space-separated allele=freq pairs)"
     uint sasN;           "SAS sample count"
     )