private void saveResults( final MetricsFile<?, Integer> metrics, final SAMFileHeader readsHeader, final String inputFileName) { MetricsUtils.saveMetrics(metrics, out, getAuthHolder()); if (metrics.getAllHistograms().isEmpty()) { logger.warn("No valid bases found in input file."); } else if (chartOutput != null) { // Now run R to generate a chart // If we're working with a single library, assign that library's name // as a suffix to the plot title final List<SAMReadGroupRecord> readGroups = readsHeader.getReadGroups(); /* * A subtitle for the plot, usually corresponding to a library. */ String plotSubtitle = ""; if (readGroups.size() == 1) { plotSubtitle = StringUtil.asEmptyIfNull(readGroups.get(0).getLibrary()); } final RScriptExecutor executor = new RScriptExecutor(); executor.addScript(new Resource(MeanQualityByCycle.R_SCRIPT, MeanQualityByCycle.class)); executor.addArgs(out, chartOutput.getAbsolutePath(), inputFileName, plotSubtitle); executor.exec(); } }