Commit 5d4b5b75 authored by Peter van 't Hof's avatar Peter van 't Hof

Merge remote-tracking branch 'remotes/origin/fix-BIOPET-587' into epic-summary_reformat

parents 75a2cc1b f32fe43a
#import(nl.lumc.sasc.biopet.utils.IoUtils)
#import(nl.lumc.sasc.biopet.utils.summary.Summary)
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(org.apache.commons.io.FileUtils)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._)
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(scala.concurrent.Await)
#import(scala.concurrent.duration.Duration)
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
#import(java.io.File)
<%@ var summary: Summary %>
<%@ var sampleId: Option[String] = None %>
<%@ var libId: Option[String] = None %>
<%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] = None %>
<%@ var sampleLevel: Boolean = true %>
<%@ var rootPath: String %>
<%@ var libId: Option[Int] = None %>
<%@ var outputDir: File %>
<%@ var rootPath: String %>
<%@ var metricsTag: String = "bammetrics" %>
<%@ var target: Option[String] %>
<%@ var runId: Int %>
<%@ var fields: List[String] = List("mean", "median", "max", "horizontal", "frac_min_10x", "frac_min_20x", "frac_min_30x", "frac_min_40x", "frac_min_50x") %>
#{
val samples = sampleId match {
case Some(sample) => List(sample.toString)
case _ => summary.samples.toList
}
val samples = Await.result(summary.getSamples(runId = Some(runId)), Duration.Inf)
}#
<table class="table">
<thead><tr>
<th>sample</th>
<th>mean</th>
<th>median</th>
<th>max</th>
<th>horizontal</th>
<th>frac min 10x</th>
<th>frac min 20x</th>
<th>frac min 30x</th>
<th>frac min 40x</th>
<th>frac min 50x</th>
#for (field <- fields)
<th>${field}</th>
#end
</tr></thead>
<tbody>
#for (sample <- samples.toList.sorted)
#for (sample <- samples.sortBy(_.name))
#{
val libs = (libId, sampleLevel) match {
case (_, true) => List("")
case (Some(libId), _) => List(libId.toString)
case _ => summary.libraries(sample).toList
val libs: List[Option[Int]] = (libId, sampleLevel) match {
case (_, true) => List(None)
case (Some(_), _) => List(libId)
case _ => Await.result(summary.getLibraries(sampleId = Some(sample.id), runId = Some(runId)), Duration.Inf).map(x => Some(x.id)).toList
}
}#
<tr><td rowspan="${libs.size}"><a href="${rootPath}Samples/${sample}/index.html">${sample}</a></td>
<tr><td rowspan="${libs.size}"><a href="${rootPath}Samples/${sample.name}/index.html">${sample.name}</a></td>
#for (libId <- libs)
#if (libs.head != libId) <tr> #end
#if (!sampleLevel) <td><a href="${rootPath}Samples/${sample}/Libraries/${libId}/index.html">${libId}</a></td> #end
#{
val prefixPath = List("samples", sample) ::: (if (libId.isEmpty) Nil else List("libraries", libId)) ::: List(metricsTag, "stats", target.get + "_cov_stats", "coverage", "_all")
val total = summary.getValue((prefixPath ::: List("biopet_flagstat", "All")):_*).getOrElse(0L).asInstanceOf[Long]
val mapped = summary.getValue((prefixPath ::: List("biopet_flagstat", "Mapped")):_*).getOrElse(0L).asInstanceOf[Long]
val duplicates = summary.getValue((prefixPath ::: List("biopet_flagstat", "Duplicates")):_*).getOrElse(0L).asInstanceOf[Long]
val moduleName = target.get + "_cov_stats"
val statsPaths = fields.map(x => x -> List("coverage", "_all", x)).toMap
val values = summary.getStatKeys(runId, PipelineName(metricsTag), ModuleName(moduleName), SampleId(sample.id), libId.map(LibraryId).getOrElse(NoLibrary), statsPaths)
}#
<td>${summary.getValue((prefixPath ::: "mean" :: Nil):_*)}</td>
<td>${summary.getValue((prefixPath ::: "median" :: Nil):_*)}</td>
<td>${summary.getValue((prefixPath ::: "max" :: Nil):_*)}</td>
<td>${summary.getValue((prefixPath ::: "horizontal" :: Nil):_*)}</td>
<td>${summary.getValue((prefixPath ::: "frac_min_10x" :: Nil):_*)}</td>
<td>${summary.getValue((prefixPath ::: "frac_min_20x" :: Nil):_*)}</td>
<td>${summary.getValue((prefixPath ::: "frac_min_30x" :: Nil):_*)}</td>
<td>${summary.getValue((prefixPath ::: "frac_min_40x" :: Nil):_*)}</td>
<td>${summary.getValue((prefixPath ::: "frac_min_50x" :: Nil):_*)}</td>
#for (field <- fields)
<th>${values(field)}</th>
#end
</tr>
#end
#end
......
#import(nl.lumc.sasc.biopet.utils.IoUtils)
#import(nl.lumc.sasc.biopet.utils.summary.Summary)
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(org.apache.commons.io.FileUtils)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._)
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(scala.concurrent.Await)
#import(scala.concurrent.duration.Duration)
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
#import(java.io.File)
<%@ var summary: Summary %>
<%@ var sampleId: Option[String] %>
<%@ var libId: Option[String] = None %>
<%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] %>
<%@ var libId: Option[Int] = None %>
<%@ var outputDir: File %>
<%@ var metricsTag: String = "bammetrics" %>
<%@ var target: Option[String] %>
<%@ var runId: Int %>
<%@ var fields: List[String] = List("mean", "median", "max", "horizontal", "frac_min_10x", "frac_min_20x", "frac_min_30x", "frac_min_40x", "frac_min_50x") %>
#{
val originalPlot = new File(summary.getValue(sampleId, libId, metricsTag, "files", target.get + "_cov_stats", "plot", "path")
.getOrElse(throw new IllegalArgumentException("No plot found in summary")).toString)
val moduleName = target.get + "_cov_stats"
val statsPaths = fields.map(x => x -> List("coverage", "_all", x)).toMap
val plotFile = Await.result(summary.getFile(runId, PipelineName(metricsTag), ModuleName(moduleName), sampleId.map(SampleId).get, libId.map(LibraryId).getOrElse(NoLibrary), "plot"), Duration.Inf)
val originalPlot = new File(plotFile.get.path)
val plot = new File(outputDir, target.get + "_cov_stats.png")
val values = summary.getValue(sampleId, libId, metricsTag, "stats", target.get + "_cov_stats", "coverage", "_all")
.getOrElse(throw new IllegalArgumentException("No plot found in summary")).asInstanceOf[Map[String, Any]]
val values = summary.getStatKeys(runId, PipelineName(metricsTag), ModuleName(moduleName), sampleId.map(SampleId).get, libId.map(LibraryId).getOrElse(NoLibrary), statsPaths)
if (originalPlot.exists()) IoUtils.copyFile(originalPlot, plot)
}#
<img src="${plot.getName}">
<table class="table">
<thead><tr>
<th>mean</th>
<th>median</th>
<th>max</th>
<th>horizontal</th>
<th>frac min 10x</th>
<th>frac min 20x</th>
<th>frac min 30x</th>
<th>frac min 40x</th>
<th>frac min 50x</th>
#for (field <- fields)
<th>${field}</th>
#end
</tr></thead>
<tbody>
<tr>
<td>${values.get("mean")}</td>
<td>${values.get("median")}</td>
<td>${values.get("max")}</td>
<td>${values.get("horizontal")}</td>
<td>${values.get("frac_min_10x")}</td>
<td>${values.get("frac_min_20x")}</td>
<td>${values.get("frac_min_30x")}</td>
<td>${values.get("frac_min_40x")}</td>
<td>${values.get("frac_min_50x")}</td>
#for (field <- fields)
<th>${values(field)}</th>
#end
</tr>
</tbody>
</table>
#import(nl.lumc.sasc.biopet.utils.summary.Summary)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._)
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(scala.concurrent.Await)
#import(scala.concurrent.duration.Duration)
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
#import(java.io.File)
#import(org.apache.commons.io.FileUtils)
<%@ var summary: Summary %>
<%@ var sampleId: Option[String] = None %>
<%@ var libId: Option[String] = None %>
<%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %>
<%@ var rootPath: String %>
<%@ var metricsTag: String = "bammetrics" %>
<%@ var sampleLevel: Boolean = false %>
......@@ -14,13 +17,9 @@
<%@ var showPlot: Boolean = false %>
<%@ var showTable: Boolean = true %>
<%@ var showIntro: Boolean = true%>
<%@ var runId: Int %>
#{
val samples = sampleId match {
case Some(sample) => {
List(sample.toString)
}
case _ => summary.samples.toList
}
val samples = Await.result(summary.getSamples(runId = Some(runId)), Duration.Inf)
}#
#if (showIntro)
......@@ -36,7 +35,7 @@
#end
#if (showPlot)
#{ BammetricsReport.rnaHistogramPlot(outputDir, "rna", summary, !sampleLevel, sampleId = sampleId, libId = libId) }#
#{ BammetricsReport.rnaHistogramPlot(outputDir, "rna", summary, !sampleLevel, sampleId = sampleId, libraryId = libId) }#
<div class="panel-body">
<img src="rna.png" class="img-responsive" />
......@@ -47,7 +46,7 @@
#else
<button type="button" class="btn btn-info" data-toggle="collapse" data-target="#rnaTable">Show table</button>
#end
<a href="rna.tsv"><button type="button" class="btn btn-info"><i class="glyphicon glyphicon-cloud-download"></i> TSV file</button></a>
<a href="rna.tsv"><button type="button" class="btn btn-info"><i class="glyphicon glyphicon-cloud-download"></i>TSV file</button></a>
</div>
#end
......@@ -62,27 +61,25 @@
#end
</tr></thead>
<tbody>
#for (sample <- samples.toList.sorted)
#for (sample <- samples.sortBy(_.name))
#{
val libs = (libId, sampleLevel) match {
case (_, true) => List("")
case (Some(libId), _) => List(libId.toString)
case _ => summary.libraries(sample).toList
val libs: List[Option[Int]] = (libId, sampleLevel) match {
case (_, true) => List(None)
case (Some(_), _) => List(libId)
case _ => Await.result(summary.getLibraries(sampleId = Some(sample.id), runId = Some(runId)), Duration.Inf).map(x => Some(x.id)).toList
}
}#
<tr><td rowspan="${libs.size}"><a href="${rootPath}Samples/${sample}/index.html">${sample}</a></td>
#for (libId <- libs)
#{ val libName = libId.map(l => Await.result(summary.getLibraryName(l), Duration.Inf)) }#
#if (libs.head != libId) <tr> #end
#if (!sampleLevel) <td><a href="${rootPath}Samples/${sample}/Libraries/${libId}/index.html">${libId}</a></td> #end
#if (!sampleLevel) <td><a href="${rootPath}Samples/${sample.name}/Libraries/${libName}/index.html">${libName}</a></td> #end
#{
val prefixPath = List("samples", sample) ::: (if (libId.isEmpty) Nil else List("libraries", libId)) ::: List("bammetrics", "stats")
val fieldValues = for (field <- fields) yield {
summary.getValue((prefixPath ::: List("rna", "metrics", field.toUpperCase)):_*).getOrElse(prefixPath ::: metricsTag :: Nil)
}
val statsPaths = fields.map(x => x -> List("metrics", x.toUpperCase)).toMap
val results = summary.getStatKeys(runId, "bammetrics", "wgs", sample = sample.id, library = libId.map(LibraryId).getOrElse(NoLibrary), keyValues = statsPaths)
}#
#for (value <- fieldValues)
<td>${value}</td>
#for (field <- fields)
<td>${results(field)}</td>
#end
</tr>
#end
......
......@@ -74,7 +74,7 @@
#if (libs.head != libId) <tr> #end
#if (!sampleLevel) <td><a href="${rootPath}Samples/${sample.name}/Libraries/${libName}/index.html">${libName}</a></td> #end
#{
val statsPaths = fields.map(x => x -> List("metrics", x)).toMap
val statsPaths = fields.map(x => x -> List("metrics", x.toUpperCase)).toMap
val results = summary.getStatKeys(runId, "bammetrics", "wgs", sample = sample.id, library = libId.map(LibraryId).getOrElse(NoLibrary), keyValues = statsPaths)
}#
#for (field <- fields)
......
......@@ -162,9 +162,7 @@ object BammetricsReport extends ReportBuilder {
plot.input = tsvFile
plot.output = pngFile
plot.ylabel = Some("Reads")
if (libraryLevel) {
plot.width = Some(200 + (libraries.filter(s => sampleId.getOrElse(s.id) == s.id).size) * 10)
} else plot.width = Some(200 + (samples.count(s => sampleId.getOrElse(s) == s) * 10))
plot.width = Some(200 + (results.size * 10))
plot.title = Some("Aligned reads")
plot.runLocal()
}
......@@ -176,8 +174,8 @@ object BammetricsReport extends ReportBuilder {
sampleId: Option[Int] = None,
libraryId: Option[Int] = None,
statsPaths: Map[String, List[String]],
xKey: String,
yKey: String,
xKey: String,
pipeline: PipelineQuery,
module: ModuleQuery,
xlabel: Option[String] = None,
......@@ -210,6 +208,7 @@ object BammetricsReport extends ReportBuilder {
xlabel = xlabel,
ylabel = ylabel,
title = title,
hideLegend = results.size > 40,
removeZero = removeZero).runLocal()
}
......@@ -286,8 +285,8 @@ object BammetricsReport extends ReportBuilder {
sampleId: Option[Int] = None,
libraryId: Option[Int] = None): Unit = {
val statsPaths = Map(
"coverage" -> List("wgs", "histogram", "coverage"),
"count" -> List("wgs", "histogram", "count")
"coverage" -> List("histogram", "coverage"),
"count" -> List("histogram", "count")
)
writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths,
......
#import(nl.lumc.sasc.biopet.utils.summary.db.Schema.File)
#import(nl.lumc.sasc.biopet.utils.summary.db.Schema.Pipeline)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._)
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(scala.concurrent.Await)
#import(scala.concurrent.duration.Duration)
<%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %>
<%@ var runId: Int %>
<%@ var pipelineIds: List[Int] %>
<%@ var allPipelines: Seq[Pipeline] %>
#{ val pipelineNames = pipelineIds.map(x => allPipelines.find(_.id == x).map(_.name)) }#
<table class="table">
<thead><tr>
<th>Pipeline</th>
</tr></thead>
<tbody>
#for (pipelineName <- pipelineNames)
<tr><td><a href="./${pipelineName}/index.html" >${pipelineName}</a></td></tr>
#end
</tbody>
</table>
#import(nl.lumc.sasc.biopet.utils.summary.db.Schema.File)
#import(nl.lumc.sasc.biopet.utils.summary.db.Schema.Pipeline)
#import(nl.lumc.sasc.biopet.utils.summary.db.Schema.Module)
#import(nl.lumc.sasc.biopet.utils.summary.db.Schema.Sample)
#import(nl.lumc.sasc.biopet.utils.summary.db.Schema.Library)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._)
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(scala.concurrent.Await)
#import(scala.concurrent.duration.Duration)
<%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %>
<%@ var runId: Int %>
<%@ var files: Seq[File]%>
<%@ var allPipelines: Seq[Pipeline]%>
<%@ var allModules: Seq[Module]%>
<%@ var allSamples: Seq[Sample]%>
<%@ var allLibraries: Seq[Library]%>
<table class="table sortable-theme-bootstrap" data-sortable>
<thead><tr>
<th>Pipeline</th>
<th>Module</th>
<th>Sample</th>
<th>Library</th>
<th data-sorted="true" data-sorted-direction="ascending">Key</th>
<th>path</th>
<th>md5</th>
</tr></thead>
<tbody>
#for (file <- files)
<tr><td>${allPipelines.find(_.id == file.pipelineId).map(_.name)}</td>
<td>${file.moduleId.map(id => allModules.find(x => x.pipelineId == file.pipelineId && file.moduleId == id).map(_.name)).flatten.getOrElse(("-"))}</td>
<td>${file.sampleId.map(id => allSamples.find(_.id == id).map(_.name)).flatten.getOrElse(("-"))}</td>
<td>${file.libraryId.map(id => allLibraries.find(_.id == id).map(_.name)).flatten.getOrElse(("-"))}</td>
<td>${file.key}</td>
<td>${file.path}</td>
<td>${file.md5}</td></tr>
#end
</tbody>
</table>
library(reshape2)
library(ggplot2)
library(argparse)
parser <- ArgumentParser(description='Process some integers')
parser$add_argument('--input', dest='input', type='character', help='Input tsv file', required=TRUE)
parser$add_argument('--output', dest='output', type='character', help='Output png file', required=TRUE)
parser$add_argument('--width', dest='width', type='integer', default = 500)
parser$add_argument('--height', dest='height', type='integer', default = 500)
parser$add_argument('--xlabel', dest='xlabel', type='character')
parser$add_argument('--ylabel', dest='ylabel', type='character', required=TRUE)
parser$add_argument('--llabel', dest='llabel', type='character')
parser$add_argument('--title', dest='title', type='character')
parser$add_argument('--removeZero', dest='removeZero', type='character', default="false")
arguments <- parser$parse_args()
png(filename = arguments$output, width = arguments$width, height = arguments$height)
DF <- read.table(arguments$input, header=TRUE)
if (is.null(arguments$xlabel)) xlab <- colnames(DF)[1] else xlab <- arguments$xlabel
colnames(DF)[1] <- "Rank"
DF1 <- melt(DF, id.var="Rank")
if (arguments$removeZero == "true") DF1 <- DF1[DF1$value > 0, ]
if (arguments$removeZero == "true") print("Removed 0 values")
ggplot(DF1, aes(x = Rank, y = value, group = variable, color = variable)) +
xlab(xlab) +
ylab(arguments$ylabel) +
guides(fill=guide_legend(title=arguments$llabel)) +
theme(axis.text.x = element_text(angle = 90, hjust = 1, size = 8)) +
ggtitle(arguments$title) +
theme_bw() +
geom_point()
dev.off()
library(reshape2)
library(ggplot2)
library(argparse)
parser <- ArgumentParser(description='Process some integers')
parser$add_argument('--input', dest='input', type='character', help='Input tsv file', required=TRUE)
parser$add_argument('--output', dest='output', type='character', help='Output png file', required=TRUE)
parser$add_argument('--width', dest='width', type='integer', default = 500)
parser$add_argument('--height', dest='height', type='integer', default = 500)
parser$add_argument('--xlabel', dest='xlabel', type='character')
parser$add_argument('--ylabel', dest='ylabel', type='character', required=TRUE)
parser$add_argument('--llabel', dest='llabel', type='character')
parser$add_argument('--title', dest='title', type='character')
parser$add_argument('--removeZero', dest='removeZero', type='character', default="false")
arguments <- parser$parse_args()
png(filename = arguments$output, width = arguments$width, height = arguments$height)
DF <- read.table(arguments$input, header=TRUE)
if (is.null(arguments$xlabel)) xlab <- colnames(DF)[1] else xlab <- arguments$xlabel
colnames(DF)[1] <- "Rank"
DF1 <- melt(DF, id.var="Rank")
if (arguments$removeZero == "true") DF1 <- DF1[DF1$value > 0, ]
if (arguments$removeZero == "true") print("Removed 0 values")
ggplot(DF1, aes(x = Rank, y = value, group = variable, color = variable)) +
xlab(xlab) +
ylab(arguments$ylabel) +
guides(fill=guide_legend(title=arguments$llabel)) +
theme(axis.text.x = element_text(angle = 90, hjust = 1, size = 8)) +
ggtitle(arguments$title) +
theme_bw() +
geom_line()
dev.off()
library(reshape2)
library(ggplot2)
library(argparse)
parser <- ArgumentParser(description='Process some integers')
parser$add_argument('--input', dest='input', type='character', help='Input tsv file', required=TRUE)
parser$add_argument('--output', dest='output', type='character', help='Output png file', required=TRUE)
parser$add_argument('--width', dest='width', type='integer', default = 500)
parser$add_argument('--height', dest='height', type='integer', default = 500)
parser$add_argument('--xlabel', dest='xlabel', type='character')
parser$add_argument('--ylabel', dest='ylabel', type='character', required=TRUE)
parser$add_argument('--llabel', dest='llabel', type='character')
parser$add_argument('--title', dest='title', type='character')
arguments <- parser$parse_args()
png(filename = arguments$output, width = arguments$width, height = arguments$height)
DF <- read.table(arguments$input, header=TRUE)
if (is.null(arguments$xlabel)) xlab <- colnames(DF)[1] else xlab <- arguments$xlabel
colnames(DF)[1] <- "Rank"
DF1 <- melt(DF, id.var="Rank")
ggplot(DF1, aes(x = Rank, y = value, fill = variable)) +
xlab(xlab) +
ylab(arguments$ylabel) +
guides(fill=guide_legend(title=arguments$llabel)) +
theme(axis.text.x = element_text(angle = 90, hjust = 1, size = 8)) +
geom_bar(stat = "identity", width=1) +
ggtitle(arguments$title)
dev.off()
......@@ -29,7 +29,8 @@ trait BiopetJavaCommandLineFunction extends JavaCommandLineFunction with BiopetC
/** Constructs java opts, this adds scala threads */
override def javaOpts = super.javaOpts +
optional("-Dscala.concurrent.context.numThreads=", threads, spaceSeparated = false)
optional("-Dscala.concurrent.context.numThreads=", threads, spaceSeparated = false) +
optional("-Dscala.concurrent.context.maxThreads=", threads, spaceSeparated = false)
override def beforeGraph(): Unit = {
setResources()
......
......@@ -17,7 +17,7 @@ package nl.lumc.sasc.biopet.core.report
import java.io._
import nl.lumc.sasc.biopet.core.ToolCommandFunction
import nl.lumc.sasc.biopet.utils.summary.db.Schema.{ Library, Sample }
import nl.lumc.sasc.biopet.utils.summary.db.Schema.{ Library, Module, Pipeline, Sample }
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import nl.lumc.sasc.biopet.utils.{ IoUtils, Logging, ToolCommand }
import org.broadinstitute.gatk.utils.commandline.Input
......@@ -118,6 +118,10 @@ trait ReportBuilder extends ToolCommand {
final def runId = setRunId
private var _setPipelines = Seq[Pipeline]()
final def pipelines = _setPipelines
private var _setModules = Seq[Module]()
final def modules = _setModules
private var _setSamples = Seq[Sample]()
final def samples = _setSamples
private var _setLibraries = Seq[Library]()
......@@ -160,7 +164,7 @@ trait ReportBuilder extends ToolCommand {
require(cmdArgs.outputDir.exists(), "Output dir does not exist")
require(cmdArgs.outputDir.isDirectory, "Output dir is not a directory")
setSummary = SummaryDb.openSqliteSummary(cmdArgs.summaryDbFile)
setSummary = SummaryDb.openReadOnlySqliteSummary(cmdArgs.summaryDbFile)
setRunId = cmdArgs.runId
cmdArgs.pageArgs.get("sampleId") match {
......@@ -177,6 +181,8 @@ trait ReportBuilder extends ToolCommand {
case _ =>
}
_setPipelines = Await.result(summary.getPipelines(runId = Some(runId)), Duration.Inf)
_setModules = Await.result(summary.getModules(runId = Some(runId)), Duration.Inf)
_setSamples = Await.result(summary.getSamples(runId = Some(runId), sampleId = sampleId), Duration.Inf)
_setLibraries = Await.result(summary.getLibraries(runId = Some(runId), sampleId = sampleId, libId = libId), Duration.Inf)
......@@ -236,7 +242,11 @@ trait ReportBuilder extends ToolCommand {
Map("page" -> page,
"path" -> path,
"outputDir" -> pageOutputDir,
"rootPath" -> rootPath
"rootPath" -> rootPath,
"allPipelines" -> pipelines,
"allModules" -> modules,
"allSamples" -> samples,
"allLibraries" -> libraries
)
// Generating subpages
......
......@@ -86,7 +86,7 @@ trait SummaryQScript extends BiopetQScript { qscript: QScript =>
private var addedJobs = false
final lazy val summaryRunId: Int = {
if (runIdFile.exists()) {
if (runIdFile.exists() && summaryDbFile.exists()) {
val reader = Source.fromFile(runIdFile)
val id = reader.getLines().next().toInt
reader.close()
......@@ -163,13 +163,29 @@ trait SummaryQScript extends BiopetQScript { qscript: QScript =>
}
}
qscript match {
case q: MultiSampleQScript =>
// Global level
for ((key, file) <- qscript.summaryFiles) addChecksum(file)
for ((sampleName, sample) <- q.samples) {
// Sample level
for ((key, file) <- sample.summaryFiles) addChecksum(file)
for ((libName, lib) <- sample.libraries) {
// Library level
for ((key, file) <- lib.summaryFiles) addChecksum(file)
}
}
case q => for ((key, file) <- q.summaryFiles) addChecksum(file)
}
for (inputFile <- inputFiles)