4d1bafe4de39413f4ab1a9cd7183c64655b01e0a kate Mon Oct 24 14:59:31 2016 -0700 Temporarily hardcode hg19 for review purposes. refs #17369 diff --git src/hg/hgGtexTrackSettings/hgGtexTrackSettings.c src/hg/hgGtexTrackSettings/hgGtexTrackSettings.c index 6a96147..bc47caa 100644 --- src/hg/hgGtexTrackSettings/hgGtexTrackSettings.c +++ src/hg/hgGtexTrackSettings/hgGtexTrackSettings.c @@ -1,189 +1,200 @@ /* hgGtexTrackSettings: Configure GTEx track * * Copyright (C) 2016 The Regents of the University of California */ #include "common.h" #include "cart.h" #include "cartJson.h" #include "cheapcgi.h" #include "errCatch.h" #include "googleAnalytics.h" #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 */ char *db = NULL; 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 printTrackDescription() { puts(""); puts("
"); puts("
Track Description
"); puts("
" "" "" //"" "
"); puts("
"); struct sqlConnection *conn = sqlConnect(db); +if (conn == NULL) + errAbort("Can't connect to database %s\n", db); char query[256]; sqlSafef(query, sizeof(query), "select html from trackDb where tableName='gtexGene'"); char *html = sqlQuickString(conn, query); -sqlDisconnect(&conn); +if (html != NULL) + { puts("
"); puts("
"); puts(html); + } +sqlDisconnect(&conn); puts("
"); puts(""); } 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 *genome = NULL, *clade = NULL; -getDbGenomeClade(cart, &db, &genome, &clade, oldVars); +//getDbGenomeClade(cart, &db, &genome, &clade, oldVars); + +/* hardcode for now -- later, check for hg19 or hg38 */ + +db = "hg19"; +genome = "human"; +clade = "mammal"; // char *chromosome = cartUsualString(cart, "c", hDefaultChrom(database)); //char *track = cartString(cart, "g"); webStartJWestNoBanner(cart, db, "Genome Browser GTEx Track Settings"); puts(""); puts(""); // 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)); puts(""); printTrackDescription(); puts(""); // end panel, section and body layout container // Track description // JS libraries doJsIncludes(); // Main JS -puts(""); +puts(""); webIncludeFile("inc/jWestFooter.html"); webEndJWest(); } void doMiddle(struct cart *theCart) /* Display the main page or execute a command and update the page */ { cart = theCart; if (cgiOptionalString(CARTJSON_COMMAND)) doCartJson(); else doMainPage(); } int main(int argc, char *argv[]) /* Process CGI / command line. */ { /* Null terminated list of CGI Variables we don't want to save * permanently. */ char *excludeVars[] = {CARTJSON_COMMAND, NULL}; cgiSpoof(&argc, argv); oldVars = hashNew(10); cartEmptyShellNoContent(doMiddle, hUserCookie(), excludeVars, oldVars); return 0; }