e5705b39b450c584576d183175f6b2656420bd88 braney Tue Jun 29 17:06:31 2021 -0700 change barChartClick to use the pipeline library instead of system() diff --git src/hg/hgc/barChartClick.c src/hg/hgc/barChartClick.c index 90112c3..f12fb48 100644 --- src/hg/hgc/barChartClick.c +++ src/hg/hgc/barChartClick.c @@ -12,30 +12,31 @@ #include "hui.h" #include "asParse.h" #include "hgc.h" #include "trackHub.h" #include "memgfx.h" #include "hgColors.h" #include "fieldedTable.h" #include "barChartBed.h" #include "barChartCategory.h" #include "barChartData.h" #include "barChartSample.h" #include "barChartUi.h" #include "hgConfig.h" #include "facetedBar.h" +#include "pipeline.h" #define EXTRA_FIELDS_SIZE 256 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) */ }; static struct hash *getTrackCategories(struct trackDb *tdb) /* Get list of categories from trackDb. This may be a subset of those in matrix. @@ -355,33 +356,39 @@ } static void printBoxplot(char *df, char *item, char *name2, char *units, char *colorFile) /* Plot data frame to image file and include in HTML */ { struct tempName pngTn; struct dyString *cmd = dyStringNew(0); trashDirFile(&pngTn, "hgc", "barChart", ".png"); // to help with QAing the change, we add the "oldFonts" CGI parameter so QA can compare // old and new fonts to make sure that things are still readible on mirrors and servers // without the new fonts installed. This only needed during the QA phase bool useOldFonts = cgiBoolean("oldFonts"); /* Exec R in quiet mode, without reading/saving environment or workspace */ +char *pipeCmd[] = {"Rscript","--vanilla","--slave","hgcData/barChartBoxplot.R", + item, units, colorFile, df, pngTn.forHtml, + isEmpty(name2) ? "n/a" : name2, useOldFonts ? "1" : "0"}; +struct pipeline *pl = pipelineOpen1(pipeCmd, pipelineWrite | pipelineNoAbort, "/dev/null", NULL); +int ret = pipelineWait(pl); + +/* put command in string in case of error. */ dyStringPrintf(cmd, "Rscript --vanilla --slave hgcData/barChartBoxplot.R %s '%s' %s %s %s %s %d", item, units, colorFile, df, pngTn.forHtml, isEmpty(name2) ? "n/a" : name2, useOldFonts); -int ret = system(cmd->string); if (ret == 0) printf("
\n", pngTn.forHtml); else warn("Error creating boxplot from sample data with command: %s", cmd->string); } static double estimateStringWidth(char *s) /* Get estimate of string width based on a memory font that is about the * same size as svg will be using. After much research I don't think we * can get the size from the server, would have to be in Javascript to get * more precise */ { MgFont *font = mgHelvetica14Font(); return mgFontStringWidth(font, s); }