0018e1b7a8a017e983d2d1d49b663e0ef987c8ef kate Thu Jan 26 15:30:14 2017 -0800 First cut click handler for barChart type tracks. refs #18736 diff --git src/hg/hgc/barChartClick.c src/hg/hgc/barChartClick.c new file mode 100644 index 0000000..d35014a --- /dev/null +++ src/hg/hgc/barChartClick.c @@ -0,0 +1,74 @@ +/* Details pages for GTEx tracks */ + +/* Copyright (C) 2015 The Regents of the University of California + * See README in this or parent directory for licensing information. */ + +#include "common.h" +#include "hash.h" +#include "hdb.h" +#include "hvGfx.h" +#include "trashDir.h" +#include "hgc.h" +#include "hCommon.h" + +#include "barChartBed.h" +#include "barChartCategory.h" +#include "barChartUi.h" + +static struct barChartBed *getBarChart(char *item, char *chrom, int start, int end, char *table) +/* Retrieve barChart BED item from the main track table */ +{ +struct barChartBed *barChart = NULL; +struct sqlConnection *conn = hAllocConn(database); +char **row; +char query[512]; +struct sqlResult *sr; +if (sqlTableExists(conn, table)) + { + sqlSafef(query, sizeof query, + "SELECT * FROM %s WHERE name = '%s' " + "AND chrom = '%s' AND chromStart = %d AND chromEnd = %d", + table, item, chrom, start, end); + sr = sqlGetResult(conn, query); + row = sqlNextRow(sr); + if (row != NULL) + { + barChart = barChartBedLoad(row); + } + sqlFreeResult(&sr); + } +hFreeConn(&conn); +return barChart; +} + +void doBarChartDetails(struct trackDb *tdb, char *item) +/* Details of barChart item */ +{ +int start = cartInt(cart, "o"); +int end = cartInt(cart, "t"); +struct barChartBed *barChart = getBarChart(item, seqName, start, end, tdb->table); +if (barChart == NULL) + errAbort("Can't find item %s in barChart table %s\n", item, tdb->table); + +genericHeader(tdb, item); +int categId; +float highLevel = barChartHighestValue(barChart, &categId); +printf("Highest value: %0.2f in %s
\n", + highLevel, barChartGetCategoryLabel(categId, database, tdb->table)); +printf("Total all values: %0.2f
\n", barChartTotalValue(barChart)); +printf("Score: %d
\n", barChart->score); +printf("Genomic position: " + "%s %s:%d-%d
\n", + database, hgTracksPathAndSettings(), database, + barChart->chrom, barChart->chromStart+1, barChart->chromEnd, + barChart->chrom, barChart->chromStart+1, barChart->chromEnd); +puts("

"); + +#ifdef BOXPLOT +struct tempName pngTn; +if (barChartBoxplot(barChart->name, &pngTn)) + printf("
\n", pngTn.forHtml); +printf("
"); +#endif +printTrackHtml(tdb); +}