38fe0330488867c168c817169bbf1c49806c5cfb kate Fri Oct 7 15:32:40 2016 -0700 Move tissue table to code for flexibility/maintenance. refs #17369 diff --git src/hg/hgGtexTrackSettings/hgGtexTrackSettings.c src/hg/hgGtexTrackSettings/hgGtexTrackSettings.c index 10ae215..3b072a8 100644 --- src/hg/hgGtexTrackSettings/hgGtexTrackSettings.c +++ src/hg/hgGtexTrackSettings/hgGtexTrackSettings.c @@ -12,76 +12,129 @@ #include "hCommon.h" #include "hgConfig.h" #include "hdb.h" #include "htmshell.h" #include "hubConnect.h" #include "hui.h" #include "jsHelper.h" #include "jsonParse.h" #include "obscure.h" // for readInGulp #include "regexHelper.h" #include "suggest.h" #include "trackHub.h" #include "trix.h" #include "web.h" +#include "gtexInfo.h" +#include "gtexTissue.h" + /* Global Variables */ struct cart *cart = NULL; /* CGI and other variables */ struct hash *oldVars = NULL; /* Old contents of cart before it was updated by CGI */ static void doCartJson() /* Perform UI commands to update the cart and/or retrieve cart vars & metadata. */ { struct cartJson *cj = cartJsonNew(cart); //e.g. cartJsonRegisterHandler(cj, "setTaxId", setTaxId); cartJsonExecute(cj); } static void doJsIncludes() /* Include JS libraries. From hgGateway (think about libifying) */ { //puts(""); //puts(""); //puts(""); puts(""); webIncludeResourceFile("jquery-ui.css"); jsIncludeFile("jquery-ui.js", NULL); jsIncludeFile("jquery.watermarkinput.js", NULL); jsIncludeFile("utils.js",NULL); } +static void printTissueTable(char *version) +/* Output HTML with tissue labels and colors, in 2 columns, to fit next to body map */ +{ +struct gtexTissue *tis, *tissues = gtexGetTissues(version); +struct gtexTissue **tisTable = NULL; +int count = slCount(tissues); +AllocArray(tisTable, count); +int i=0, col=0; +int cols = 2; +int last = count/2 + 1; + +puts(""); +puts(""); +for (tis = tissues; tis != NULL; tis = tis->next) + { + if (tis->id < last) + i = tis->id * 2; + else + i = (tis->id - last) * 2 + 1; + tisTable[i] = tis; + } +for (i=0; i" + "", + tis->color, tis->name, tis->description); + col++; + if (col > cols-1) + { + puts("\n"); + col = 0; + } + } +puts("\n"); +puts("
%s
"); +} + static void doMainPage() /* Send HTML with javascript to bootstrap the user interface. */ { // Start web page with new banner char *db = NULL, *genome = NULL, *clade = NULL; getDbGenomeClade(cart, &db, &genome, &clade, oldVars); // char *chromosome = cartUsualString(cart, "c", hDefaultChrom(database)); //char *track = cartString(cart, "g"); webStartJWestNoBanner(cart, db, "Genome Browser GTEx Track Settings"); puts(""); puts(""); -// The visible page elements are all in ./hgGtexTrackSettings.html, which is transformed into a quoted .h +// The initial visible page elements are hgGtexTrackSettings.html, +// which is transformed into a quoted .h // file containing a string constant that we #include and print here (see makefile). puts( #include "hgGtexTrackSettings.html.h" ); +//struct tdb *tdbList = NULL; +//struct trackDb *tdb = tdbForTrack(db, track, &tdbList); +//printTissueTable(gtexGetVersion(tdb->table)); + +char *table = "gtexGene"; + +printTissueTable(gtexVersion(table)); + +// end panel, section and body layout container +puts(""); webIncludeFile("inc/jWestFooter.html"); webEndJWest(); } void doMiddle(struct cart *theCart) /* Display the main page or execute a command and update the page */ {