5a34c495d5fe1db2aab6d1785c0b0239dbed2520 angie Sat Aug 16 21:21:02 2025 -0700 New track type lorax: details page embeds Lorax multi-tree viewer. The trees are subtrees of an Ancestral Recombination Graph (ARG). This commit also adds a track with 1000 Genomes data, tgpLorax. The details page uses an iframe to embed the Lorax viewer from a separate server (most likely will run in a docker container on the GB server hosts; that will make this track more complicated for mirror operators than other tracks). diff --git src/hg/hgc/loraxClick.c src/hg/hgc/loraxClick.c new file mode 100644 index 00000000000..acdcd7b8b36 --- /dev/null +++ src/hg/hgc/loraxClick.c @@ -0,0 +1,48 @@ +/* Details page for Lorax multi-tree viewer track type */ + +/* Copyright (C) 2025 The Regents of the University of California + * See kent/LICENSE or http://genome.ucsc.edu/license/ for licensing information. */ + +#include "common.h" +#include "cart.h" +#include "cheapcgi.h" +#include "hgc.h" +#include "jsHelper.h" + +void doLorax(struct trackDb *tdb, char *item) +/* Display the Lorax multi-tree viewer. */ +{ +// Open page and get parameters from CGI +cartWebStart(cart, database, "%s: %s", genome, tdb->longLabel); +char *chrom = cartString(cart, "c"); +int start = cartInt(cart, "o"); +int end = cartInt(cart, "t"); + +// Set iframe style and make iframe with src=[lorax docker with chrom, start and end in URL] +char *iframeHeight = trackDbSetting(tdb, "loraxIframeHeight"); +printf( +"<style>\n" +"iframe {\n" +" width: %s;\n" +" height: %s;\n" +" border: none;\n" +"}\n" +"</style>\n", + "100%", iframeHeight); + +// Get backend URL from trackDb setting, add chrom, start and end params +char *backendUrl = trackDbSetting(tdb, "loraxBackendUrl"); +printf("<iframe id='loraxIframe' src='%s?chrom=%s&start=%d&end=%d'></iframe>\n", + backendUrl, chrom, start, end); + +// jsIncludeFile throws an error due to CSP when invoked via pop-up, but is necessary when +// "Enable pop-up when clicking items" is disabled in Genome Browser. +// When invoked via pop-up, hgTracks has already included lorax.js, so the error can be +// ignored because the file has already been loaded. +jsIncludeFile("lorax.js", NULL); + +// jsInline still works in pop-up mode even though jsIncludeFile doesn't. (ASH has no idea why.) +jsInlineF("loraxView('%s', %d, %d);", chrom, start, end); + +printTrackHtml(tdb); +}