41d01fd0f045a58696edb753981feef6865f62e5 kate Mon Apr 24 15:11:24 2017 -0700 1. Fix schema file syntax problem, strangely in comment. Caused crash in QA testing. 2. Allow bigBarChart w/o offset/len into matrix. refs #18736 diff --git src/hg/hgc/barChartClick.c src/hg/hgc/barChartClick.c index 113727f..e965168 100644 --- src/hg/hgc/barChartClick.c +++ src/hg/hgc/barChartClick.c @@ -1,27 +1,29 @@ /* Details pages for barChart 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 "hui.h" +#include "asParse.h" +#include "hgc.h" #include "barChartBed.h" #include "barChartCategory.h" #include "barChartData.h" #include "barChartSample.h" #include "barChartUi.h" struct barChartItemData /* Measured value for a sample and the sample category at a locus. * Used for barChart track details (boxplot) */ { struct barChartItemData *next; /* Next in singly linked list. */ char *sample; /* Sample identifier */ char *category; /* Sample category (from barChartSample table or barChartSampleUrl file) */ double value; /* Measured value (e.g. expression level) */ @@ -32,86 +34,96 @@ * (though maybe better to prune matrix for performance) */ { char *categs = trackDbSetting(tdb, BAR_CHART_CATEGORY_LABELS); char *words[BAR_CHART_MAX_CATEGORIES]; int wordCt; wordCt = chopLine(cloneString(categs), words); int i; struct hash *categoryHash = hashNew(0); for (i=0; inext) { char startBuf[16], endBuf[16]; char *row[32]; bigBedIntervalToRow(bb, chrom, startBuf, endBuf, row, ArraySize(row)); - struct barChartBed *barChart = barChartBedLoadOptionalOffsets(row, TRUE); + struct barChartBed *barChart = barChartBedLoadOptionalOffsets(row, hasOffsets); if (sameString(barChart->name, item)) return barChart; } return NULL; } -static struct barChartBed *getBarChartFromTable(char *item, char *chrom, int start, int end, - char *table) +static struct barChartBed *getBarChartFromTable(struct trackDb *tdb, char *table, + char *item, char *chrom, int start, int end) /* Retrieve barChart BED item from 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 = barChartBedLoadOptionalOffsets(row, FALSE); } sqlFreeResult(&sr); } hFreeConn(&conn); return barChart; } -static struct barChartBed *getBarChart(char *item, char *chrom, int start, int end, - struct trackDb *tdb) +static struct barChartBed *getBarChart(struct trackDb *tdb, char *item, char *chrom, int start, int end) /* Retrieve barChart BED item from track */ { struct barChartBed *barChart = NULL; char *file = trackDbSetting(tdb, "bigDataUrl"); if (file != NULL) - barChart = getBarChartFromFile(item, chrom, start, end, file); + barChart = getBarChartFromFile(tdb, file, item, chrom, start, end); else - barChart = getBarChartFromTable(item, chrom, start, end, tdb->table); + barChart = getBarChartFromTable(tdb, tdb->table, item, chrom, start, end); return barChart; } static struct barChartItemData *getSampleValsFromFile(struct trackDb *tdb, struct hash *categoryHash, struct barChartBed *bed) /* Get all data values in a file for this item (locus) */ { // Get sample categories from sample file // Format: id, category, extras char *url = trackDbSetting(tdb, "barChartSampleUrl"); struct lineFile *lf = udcWrapShortLineFile(url, NULL, 0); struct hash *sampleHash = hashNew(0); char *words[2]; int sampleCt = 0; @@ -299,31 +311,31 @@ /* Exec R in quiet mode, without reading/saving environment or workspace */ char cmd[256]; safef(cmd, sizeof(cmd), "Rscript --vanilla --slave hgcData/barChartBoxplot.R %s %s %s %s %s", item, units, colorFile, df, pngTn.forHtml); int ret = system(cmd); if (ret == 0) printf("
\n", pngTn.forHtml); } void doBarChartDetails(struct trackDb *tdb, char *item) /* Details of barChart item */ { int start = cartInt(cart, "o"); int end = cartInt(cart, "t"); -struct barChartBed *chartItem = getBarChart(item, seqName, start, end, tdb); +struct barChartBed *chartItem = getBarChart(tdb, item, seqName, start, end); if (chartItem == NULL) errAbort("Can't find item %s in barChart table/file %s\n", item, tdb->table); genericHeader(tdb, item); int categId; float highLevel = barChartMaxValue(chartItem, &categId); char *units = trackDbSettingClosestToHomeOrDefault(tdb, BAR_CHART_UNIT, ""); printf("Maximum value: %0.2f %s in %s
\n", highLevel, units, barChartUiGetCategoryLabelById(categId, database, tdb)); printf("Total all values: %0.2f
\n", barChartTotalValue(chartItem)); printf("Score: %d
\n", chartItem->score); printf("Genomic position: " "%s %s:%d-%d
\n", database, hgTracksPathAndSettings(), database, chartItem->chrom, chartItem->chromStart+1, chartItem->chromEnd,