Commit 74d3c3a9 authored by Peter van 't Hof's avatar Peter van 't Hof

Fixed compile issues

parent b27102c7
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#end #end
#if (showPlot) #if (showPlot)
#{ BammetricsReport.insertSizePlot(outputDir, "insertsize", summary, !sampleLevel, sampleId = sampleId, libId = libId) }# #{ BammetricsReport.insertSizePlot(outputDir, "insertsize", summary, !sampleLevel, sampleId = sampleId, libraryId = libId) }#
<div class="panel-body"> <div class="panel-body">
<img src="insertsize.png" class="img-responsive" /> <img src="insertsize.png" class="img-responsive" />
......
...@@ -132,12 +132,11 @@ object BammetricsReport extends ReportBuilder { ...@@ -132,12 +132,11 @@ object BammetricsReport extends ReportBuilder {
"NotPrimaryAlignment" -> List("flagstats", "NotPrimaryAlignment") "NotPrimaryAlignment" -> List("flagstats", "NotPrimaryAlignment")
) )
val pipelineId: Int = summary.getPipelineId(runId, "bammetrics").map(_.get)
val moduleId: Option[Int] = summary.getmoduleId(runId, "bamstats", pipelineId)
val results: Map[(Int, Option[Int]), Map[String, Option[Any]]] = if (libraryLevel) { val results: Map[(Int, Option[Int]), Map[String, Option[Any]]] = if (libraryLevel) {
summary.getStatsForLibraries(runId = runId, pipelineName = "bammetrics", moduleName = Some("bamstats"), sampleId = sampleId, keyValues = statsPaths).map(x => (x._1._1, Some(x._1._2)) -> x._2) summary.getStatsForLibraries(runId, Right("bammetrics"), Some(Right("bamstats")),
} else summary.getStatsForSamples(runId, pipelineId, moduleId, sample = sampleId, keyValues = statsPaths).map(x => (x._1, None) -> x._2) sampleId = sampleId, keyValues = statsPaths).map(x => (x._1._1, Some(x._1._2)) -> x._2)
} else summary.getStatsForSamples(runId, Right("bammetrics"), Some(Right("bamstats")),
sample = sampleId.map(Left(_)), keyValues = statsPaths).map(x => (x._1, None) -> x._2)
for (((s,l),result) <- results) { for (((s,l),result) <- results) {
val sampleName: String = summary.getSampleName(s).map(_.get) val sampleName: String = summary.getSampleName(s).map(_.get)
...@@ -168,6 +167,49 @@ object BammetricsReport extends ReportBuilder { ...@@ -168,6 +167,49 @@ object BammetricsReport extends ReportBuilder {
plot.runLocal() plot.runLocal()
} }
def writePlotFromSummary(outputDir: File,
prefix: String,
summary: SummaryDb,
libraryLevel: Boolean = false,
sampleId: Option[Int] = None,
libraryId: Option[Int] = None,
statsPaths: Map[String, List[String]],
xKey: String,
yKey: String,
pipeline: Either[Int,String],
module: Option[Either[Int,String]],
xlabel: Option[String] = None,
ylabel: Option[String] = None,
title: Option[String] = None,
removeZero: Boolean = true): Unit = {
val tsvFile = new File(outputDir, prefix + ".tsv")
val pngFile = new File(outputDir, prefix + ".png")
val results: Map[(Int, Option[Int]), Map[String, Option[Array[Any]]]] = if (libraryLevel) {
summary.getStatsForLibraries(runId, pipeline, module, sampleId = sampleId, keyValues = statsPaths)
.map(x => (x._1._1, Some(x._1._2)) -> x._2.map(x => x._1 -> x._2.map(ConfigUtils.any2list(_).toArray)))
} else summary.getStatsForSamples(runId, pipeline, module, sample = sampleId.map(Left(_)), keyValues = statsPaths)
.map(x => (x._1, None) -> x._2.map(x => x._1 -> x._2.map(ConfigUtils.any2list(_).toArray)))
val tables: Array[Map[String, Array[Any]]] = results.map { case ((sample,library), map) =>
val sampleName = Await.result(summary.getSampleName(sample), Duration.Inf)
.getOrElse(throw new IllegalStateException("Sample must be there"))
val libraryName = library.flatMap(l => Await.result(summary.getLibraryName(l), Duration.Inf))
Map(
yKey -> map(yKey).getOrElse(Array()),
(sampleName + libraryName.map("-" + _)getOrElse("")) -> map(xKey).getOrElse(Array())
)
}.toArray
writeTableToTsv(tsvFile, mergeTables(tables, yKey), yKey)
LinePlot(tsvFile, pngFile,
xlabel = xlabel,
ylabel = ylabel,
title = title,
removeZero = removeZero).runLocal()
}
/** /**
* Generate a line plot for insertsize * Generate a line plot for insertsize
* *
...@@ -182,36 +224,15 @@ object BammetricsReport extends ReportBuilder { ...@@ -182,36 +224,15 @@ object BammetricsReport extends ReportBuilder {
summary: SummaryDb, summary: SummaryDb,
libraryLevel: Boolean = false, libraryLevel: Boolean = false,
sampleId: Option[Int] = None, sampleId: Option[Int] = None,
libId: Option[Int] = None): Unit = { libraryId: Option[Int] = None): Unit = {
val tsvFile = new File(outputDir, prefix + ".tsv")
val pngFile = new File(outputDir, prefix + ".png")
val statsPaths = Map( val statsPaths = Map(
"insert_size" -> List("histogram", "insert_size"), "insert_size" -> List("histogram", "insert_size"),
"All_Reads.fr_count" -> List("histogram", "All_Reads.fr_count") "count" -> List("histogram", "All_Reads.fr_count")
) )
val pipelineId: Int = summary.getPipelineId(runId, "bammetrics").map(_.get) writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId,statsPaths,
val moduleId: Option[Int] = summary.getmoduleId(runId, "CollectInsertSizeMetrics", pipelineId) "insert_size", "count", Right("bammetrics"), Some(Right("CollectInsertSizeMetrics")),
"Insert size", "Reads", "Insert size")
val results: Map[(Int, Option[Int]), Map[String, Option[Array[Any]]]] = if (libraryLevel) {
summary.getStatsForLibraries(runId, pipelineId, moduleId, sampleId = sampleId, keyValues = statsPaths)
.map(x => (x._1._1, Some(x._1._2)) -> x._2.map(x => x._1 -> x._2.map(ConfigUtils.any2list(_).toArray)))
} else summary.getStatsForSamples(runId, pipelineId, moduleId, sample = sampleId, keyValues = statsPaths)
.map(x => (x._1, None) -> x._2.map(x => x._1 -> x._2.map(ConfigUtils.any2list(_).toArray)))
val tables = getSampleLibraries(summary, sampleId, libId, libraryLevel)
.map {
case (sample, lib) =>
getTableFromSummary(summary, paths(lib.map(l => s"$sample-$l").getOrElse(sample)), Some(sample), lib)
}
writeTableToTsv(tsvFile, mergeTables(tables.toArray, "insert_size"), "insert_size")
LinePlot(tsvFile, pngFile,
xlabel = Some("Insert size"),
ylabel = Some("Reads"),
title = Some("Insert size"),
removeZero = true).runLocal()
} }
def mappingQualityPlot(outputDir: File, def mappingQualityPlot(outputDir: File,
...@@ -219,27 +240,15 @@ object BammetricsReport extends ReportBuilder { ...@@ -219,27 +240,15 @@ object BammetricsReport extends ReportBuilder {
summary: SummaryDb, summary: SummaryDb,
libraryLevel: Boolean = false, libraryLevel: Boolean = false,
sampleId: Option[Int] = None, sampleId: Option[Int] = None,
libId: Option[Int] = None): Unit = { libraryId: Option[Int] = None): Unit = {
val tsvFile = new File(outputDir, prefix + ".tsv") val statsPaths = Map(
val pngFile = new File(outputDir, prefix + ".png") "mapping_quality" -> List("mapping_quality", "histogram", "values"),
"count" -> List("mapping_quality", "histogram", "counts")
def paths(name: String) = Map(
"mapping_quality" -> List("bammetrics", "stats", "bamstats", "mapping_quality", "histogram", "values"),
name -> List("bammetrics", "stats", "bamstats", "mapping_quality", "histogram", "counts")
) )
val tables = getSampleLibraries(summary, sampleId, libId, libraryLevel) writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths,
.map { "mapping_quality", "count", Right("bammetrics"), Some(Right("bamstats")),
case (sample, lib) => "Mapping quality", "Reads", "Mapping quality")
getTableFromSummary(summary, paths(lib.map(l => s"$sample-$l").getOrElse(sample)), Some(sample), lib)
}
writeTableToTsv(tsvFile, mergeTables(tables.toArray, "mapping_quality"), "mapping_quality")
LinePlot(tsvFile, pngFile,
xlabel = Some("Mapping Quality"),
ylabel = Some("Reads"),
title = Some("Mapping Quality"),
removeZero = true).runLocal()
} }
def clippingPlot(outputDir: File, def clippingPlot(outputDir: File,
...@@ -247,27 +256,15 @@ object BammetricsReport extends ReportBuilder { ...@@ -247,27 +256,15 @@ object BammetricsReport extends ReportBuilder {
summary: SummaryDb, summary: SummaryDb,
libraryLevel: Boolean = false, libraryLevel: Boolean = false,
sampleId: Option[Int] = None, sampleId: Option[Int] = None,
libId: Option[Int] = None): Unit = { libraryId: Option[Int] = None): Unit = {
val tsvFile = new File(outputDir, prefix + ".tsv") val statsPaths = Map(
val pngFile = new File(outputDir, prefix + ".png") "clipping" -> List("clipping", "histogram", "values"),
"count" -> List("clipping", "histogram", "counts")
def paths(name: String) = Map(
"clipping" -> List("bammetrics", "stats", "bamstats", "clipping", "histogram", "values"),
name -> List("bammetrics", "stats", "bamstats", "clipping", "histogram", "counts")
) )
val tables = getSampleLibraries(summary, sampleId, libId, libraryLevel) writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths,
.map { "clipping", "count", Right("bammetrics"), Some(Right("bamstats")),
case (sample, lib) => "Clipping", "Reads", "Clipping")
getTableFromSummary(summary, paths(lib.map(l => s"$sample-$l").getOrElse(sample)), Some(sample), lib)
}
writeTableToTsv(tsvFile, mergeTables(tables.toArray, "clipping"), "clipping")
LinePlot(tsvFile, pngFile,
xlabel = Some("Clipping"),
ylabel = Some("Reads"),
title = Some("Clipping"),
removeZero = true).runLocal()
} }
/** /**
...@@ -284,27 +281,15 @@ object BammetricsReport extends ReportBuilder { ...@@ -284,27 +281,15 @@ object BammetricsReport extends ReportBuilder {
summary: SummaryDb, summary: SummaryDb,
libraryLevel: Boolean = false, libraryLevel: Boolean = false,
sampleId: Option[Int] = None, sampleId: Option[Int] = None,
libId: Option[Int] = None): Unit = { libraryId: Option[Int] = None): Unit = {
val tsvFile = new File(outputDir, prefix + ".tsv") val statsPaths = Map(
val pngFile = new File(outputDir, prefix + ".png") "coverage" -> List("wgs", "histogram", "coverage"),
"count" -> List("wgs", "histogram", "count")
def paths(name: String) = Map(
"coverage" -> List("bammetrics", "stats", "wgs", "histogram", "coverage"),
name -> List("bammetrics", "stats", "wgs", "histogram", "count")
) )
val tables = getSampleLibraries(summary, sampleId, libId, libraryLevel) writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths,
.map { "coverage", "count", Right("bammetrics"), Some(Right("wgs")),
case (sample, lib) => "Coverage", "Bases", "Whole genome coverage")
getTableFromSummary(summary, paths(lib.map(l => s"$sample-$l").getOrElse(sample)), Some(sample), lib)
}
writeTableToTsv(tsvFile, mergeTables(tables.toArray, "coverage"), "coverage")
LinePlot(tsvFile, pngFile,
xlabel = Some("Coverage"),
ylabel = Some("Bases"),
title = Some("Whole genome coverage"),
removeZero = true).runLocal()
} }
/** /**
...@@ -320,51 +305,16 @@ object BammetricsReport extends ReportBuilder { ...@@ -320,51 +305,16 @@ object BammetricsReport extends ReportBuilder {
prefix: String, prefix: String,
summary: SummaryDb, summary: SummaryDb,
libraryLevel: Boolean = false, libraryLevel: Boolean = false,
sampleId: Option[String] = None, sampleId: Option[Int] = None,
libId: Option[String] = None): Unit = { libraryId: Option[Int] = None): Unit = {
val tsvFile = new File(outputDir, prefix + ".tsv") val statsPaths = Map(
val pngFile = new File(outputDir, prefix + ".png") "position" -> List("rna", "histogram", "normalized_position"),
"count" -> List("rna", "histogram", "All_Reads.normalized_coverage")
def paths(name: String) = Map(
"normalized_position" -> List("bammetrics", "stats", "rna", "histogram", "normalized_position"),
name -> List("bammetrics", "stats", "rna", "histogram", "All_Reads.normalized_coverage")
) )
val tables = getSampleLibraries(summary, sampleId, libId, libraryLevel) writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths,
.map { "coverage", "count", Right("bammetrics"), Some(Right("rna")),
case (sample, lib) => "Relative position", "Coverage", "Rna coverage")
getTableFromSummary(summary, paths(lib.map(l => s"$sample-$l").getOrElse(sample)), Some(sample), lib)
}
writeTableToTsv(tsvFile, mergeTables(tables.toArray, "normalized_position"), "normalized_position")
LinePlot(tsvFile, pngFile,
xlabel = Some("Relative position"),
ylabel = Some("Coverage"),
title = Some("Rna coverage"),
removeZero = true).runLocal()
}
private def getSampleLibraries(summary: SummaryDb,
sampleId: Option[Int] = None,
LibId: Option[Int] = None,
libraryLevel: Boolean = false): List[(Int, Option[Int])] = {
if (LibId.isDefined) require(sampleId.isDefined)
if (libraryLevel || LibId.isDefined)
for ((sample, libs) <- summary.libraries.toList; lib <- libs) yield (sample, Some(lib))
else for ((sample, libs) <- summary.libraries.toList) yield (sample, None)
}
def getTableFromSummary(summary: SummaryDb,
paths: Map[String, List[String]],
sampleId: Option[Int] = None,
libId: Option[Int] = None): Map[String, Array[Any]] = {
val pathValues: Map[String, Array[Any]] = paths.map {
case (key, path) =>
val value = summary.getValueAsArray(sampleId, libId, path: _*)
key -> value.getOrElse(Array())
}
require(pathValues.map(_._2.size).toList.distinct.size == 1, s"Arrays in summary does not have the same number of values, $paths")
pathValues
} }
def mergeTables(tables: Array[Map[String, Array[Any]]], def mergeTables(tables: Array[Map[String, Array[Any]]],
......
...@@ -19,6 +19,9 @@ import nl.lumc.sasc.biopet.core.report._ ...@@ -19,6 +19,9 @@ import nl.lumc.sasc.biopet.core.report._
import nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport import nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport
import nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport import nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport
import scala.concurrent.Await
import scala.concurrent.duration.Duration
class MappingReport(val parent: Configurable) extends ReportBuilderExtension { class MappingReport(val parent: Configurable) extends ReportBuilderExtension {
def builder = MappingReport def builder = MappingReport
} }
...@@ -35,12 +38,17 @@ object MappingReport extends ReportBuilder { ...@@ -35,12 +38,17 @@ object MappingReport extends ReportBuilder {
override def extFiles = super.extFiles ++ List("js/gears.js", "js/krona-2.0.js", "img/krona/loading.gif", "img/krona/hidden.png", "img/krona/favicon.ico") override def extFiles = super.extFiles ++ List("js/gears.js", "js/krona-2.0.js", "img/krona/loading.gif", "img/krona/hidden.png", "img/krona/favicon.ico")
.map(x => ExtFile("/nl/lumc/sasc/biopet/pipelines/gears/report/ext/" + x, x)) .map(x => ExtFile("/nl/lumc/sasc/biopet/pipelines/gears/report/ext/" + x, x))
def krakenExecuted = summary.getValue(sampleId, libId, "gears", "stats", "krakenreport").isDefined summary.getStatsSize(runId, Right("gears"), Some(Right("krakenreport")),
sample = sampleId.map(Left(_)), library = libId.map(Left(_)))
def krakenExecuted: Boolean = Await.result(summary.getStatsSize(runId, Right("gears"), Some(Right("krakenreport")),
sample = sampleId.map(Left(_)), library = libId.map(Left(_))), Duration.Inf) >= 1
/** Root page for single BamMetrcis report */ /** Root page for single BamMetrcis report */
def indexPage = { def indexPage = {
val skipFlexiprep = summary.getValue(sampleId, libId, "mapping", "settings", "skip_flexiprep").getOrElse(false) == true val mappingSettings = summary.getSettingKeys(runId, Right("mapping"), None, sample = sampleId.map(Left(_)), library = libId.map(Left(_)),
val bamMetricsPage = if (summary.getValue(sampleId, libId, "mapping", "settings", "skip_metrics").getOrElse(false) != true) { keyValues = Map("skip_flexiprep" -> List("skip_flexiprep"), "skip_metrics" -> List("skip_metrics")))
val skipFlexiprep = mappingSettings.get("skip_flexiprep").flatten.getOrElse(false) == true
val bamMetricsPage = if (mappingSettings.get("skip_metrics").flatten.getOrElse(false) == true) {
Some(BammetricsReport.bamMetricsPage(summary, sampleId, libId)) Some(BammetricsReport.bamMetricsPage(summary, sampleId, libId))
} else None } else None
ReportPage((if (skipFlexiprep) Nil else List("QC" -> FlexiprepReport.flexiprepPage)) ::: ReportPage((if (skipFlexiprep) Nil else List("QC" -> FlexiprepReport.flexiprepPage)) :::
......
...@@ -14,11 +14,14 @@ ...@@ -14,11 +14,14 @@
*/ */
package nl.lumc.sasc.biopet.pipelines.mapping package nl.lumc.sasc.biopet.pipelines.mapping
import nl.lumc.sasc.biopet.core.report.{ ReportBuilderExtension, ReportSection, ReportPage, MultisampleReportBuilder } import nl.lumc.sasc.biopet.core.report.{MultisampleReportBuilder, ReportBuilderExtension, ReportPage, ReportSection}
import nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport import nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport
import nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport import nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport
import nl.lumc.sasc.biopet.utils.config.Configurable import nl.lumc.sasc.biopet.utils.config.Configurable
import scala.concurrent.Await
import scala.concurrent.duration.Duration
/** /**
* Created by pjvanthof on 11/01/16. * Created by pjvanthof on 11/01/16.
*/ */
...@@ -45,15 +48,20 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder { ...@@ -45,15 +48,20 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
/** Root page for the carp report */ /** Root page for the carp report */
def indexPage = { def indexPage = {
val krakenExecuted = summary.getSampleValues("gearskraken", "stats", "krakenreport").values.forall(_.isDefined) val krakenExecuted = Await.result(summary.getStatsSize(runId, Right("gearskraken"), Some(Right("krakenreport")),
val centrifugeExecuted = summary.getSampleValues("gearscentrifuge", "stats", "centrifuge_report").values.forall(_.isDefined) library = Some(None), mustHaveSample = true), Duration.Inf) >= 1
val wgsExecuted = summary.getSampleValues("bammetrics", "stats", "wgs").values.exists(_.isDefined) val centrifugeExecuted = Await.result(summary.getStatsSize(runId, Right("gearscentrifuge"), Some(Right("centrifuge_report")),
val rnaExecuted = summary.getSampleValues("bammetrics", "stats", "rna").values.exists(_.isDefined) library = Some(None), mustHaveSample = true), Duration.Inf) >= 1
val insertsizeExecuted = summary.getSampleValues("bammetrics", "stats", "CollectInsertSizeMetrics", "metrics").values.exists(_ != Some(None)) val wgsExecuted = Await.result(summary.getStatsSize(runId, Right("bammetrics"), Some(Right("wgs")),
val mappingExecuted = summary.getLibraryValues("mapping").exists(_._2.isDefined) library = Some(None), mustHaveSample = true), Duration.Inf) >= 1
val pairedFound = !mappingExecuted || summary.getLibraryValues("mapping", "settings", "paired").exists(_._2 == Some(true)) val rnaExecuted = Await.result(summary.getStatsSize(runId, Right("bammetrics"), Some(Right("rna")),
val flexiprepExecuted = summary.getLibraryValues("flexiprep") library = Some(None), mustHaveSample = true), Duration.Inf) >= 1
.exists { case ((sample, lib), value) => value.isDefined } val insertsizeExecuted = Await.result(summary.getStatsSize(runId, Right("bammetrics"), Some(Right("CollectInsertSizeMetrics")),
library = Some(None), mustHaveSample = true), Duration.Inf) >= 1
val mappingExecuted = Await.result(summary.getStatsSize(runId, Right("mapping"), Some(None), mustHaveLibrary = true), Duration.Inf) >= 1
val pairedFound = !mappingExecuted || summary.getSettingsForLibraries(runId, Right("mapping"), None, keyValues = Map("paired" -> List("paired")))
.exists(_._2.exists(_._2 == Some(true)))
val flexiprepExecuted = Await.result(summary.getStatsSize(runId, Right("flexiprep"), Some(None), mustHaveLibrary = true), Duration.Inf) >= 1
ReportPage( ReportPage(
List("Samples" -> generateSamplesPage(pageArgs)) ++ List("Samples" -> generateSamplesPage(pageArgs)) ++
...@@ -105,8 +113,7 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder { ...@@ -105,8 +113,7 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
/** Files page, can be used general or at sample level */ /** Files page, can be used general or at sample level */
def filesPage: ReportPage = { def filesPage: ReportPage = {
val flexiprepExecuted = summary.getLibraryValues("flexiprep") val flexiprepExecuted = Await.result(summary.getStatsSize(runId, Right("flexiprep"), Some(None), mustHaveLibrary = true), Duration.Inf) >= 1
.exists { case ((sample, lib), value) => value.isDefined }
ReportPage(List(), (if (flexiprepExecuted) List( ReportPage(List(), (if (flexiprepExecuted) List(
"Input fastq files" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepInputfiles.ssp"), "Input fastq files" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepInputfiles.ssp"),
...@@ -118,11 +125,13 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder { ...@@ -118,11 +125,13 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
} }
/** Single sample page */ /** Single sample page */
def samplePage(sampleId: String, args: Map[String, Any]): ReportPage = { def samplePage(sampleId: Int, args: Map[String, Any]): ReportPage = {
val krakenExecuted = summary.getValue(Some(sampleId), None, "gearskraken", "stats", "krakenreport").isDefined val krakenExecuted = Await.result(summary.getStatsSize(runId, Right("gearskraken"), Some(Right("krakenreport")),
val centrifugeExecuted = summary.getValue(Some(sampleId), None, "gearscentrifuge", "stats", "centrifuge_report").isDefined library = Some(None), sample = Some(Left(sampleId))), Duration.Inf) >= 1
val flexiprepExecuted = summary.getLibraryValues("flexiprep") val centrifugeExecuted = Await.result(summary.getStatsSize(runId, Right("gearscentrifuge"), Some(Right("centrifuge_report")),
.exists { case ((sample, lib), value) => sample == sampleId && value.isDefined } library = Some(None), sample = Some(Left(sampleId)), mustHaveSample = true), Duration.Inf) >= 1
val flexiprepExecuted = Await.result(summary.getStatsSize(runId, Right("flexiprep"), Some(None),
sample = Some(Left(sampleId)), mustHaveLibrary = true), Duration.Inf) >= 1
ReportPage(List( ReportPage(List(
"Libraries" -> generateLibraryPage(args), "Libraries" -> generateLibraryPage(args),
...@@ -149,10 +158,13 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder { ...@@ -149,10 +158,13 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
} }
/** Library page */ /** Library page */
def libraryPage(sampleId: String, libId: String, args: Map[String, Any]): ReportPage = { def libraryPage(sampleId: Int, libId: Int, args: Map[String, Any]): ReportPage = {
val krakenExecuted = summary.getValue(Some(sampleId), Some(libId), "gearskraken", "stats", "krakenreport").isDefined val krakenExecuted = Await.result(summary.getStatsSize(runId, Right("gearskraken"), Some(Right("krakenreport")),
val centrifugeExecuted = summary.getValue(Some(sampleId), Some(libId), "gearscentrifuge", "stats", "centrifuge_report").isDefined library = Some(Left(libId)), sample = Some(Left(sampleId))), Duration.Inf) >= 1
val flexiprepExecuted = summary.getValue(Some(sampleId), Some(libId), "flexiprep").isDefined val centrifugeExecuted = Await.result(summary.getStatsSize(runId, Right("gearscentrifuge"), Some(Right("centrifuge_report")),
library = Some(Left(libId)), sample = Some(Left(sampleId)), mustHaveSample = true), Duration.Inf) >= 1
val flexiprepExecuted = Await.result(summary.getStatsSize(runId, Right("flexiprep"), Some(None), library = Some(Left(libId)),
sample = Some(Left(sampleId)), mustHaveLibrary = true), Duration.Inf) >= 1
ReportPage( ReportPage(
("Alignment" -> BammetricsReport.bamMetricsPage(summary, Some(sampleId), Some(libId))) :: ("Alignment" -> BammetricsReport.bamMetricsPage(summary, Some(sampleId), Some(libId))) ::
......
...@@ -14,13 +14,17 @@ ...@@ -14,13 +14,17 @@
*/ */
package nl.lumc.sasc.biopet.pipelines.shiva package nl.lumc.sasc.biopet.pipelines.shiva
import java.io.{ File, PrintWriter } import java.io.{File, PrintWriter}
import nl.lumc.sasc.biopet.core.report._ import nl.lumc.sasc.biopet.core.report._
import nl.lumc.sasc.biopet.pipelines.mapping.MultisampleMappingReportTrait import nl.lumc.sasc.biopet.pipelines.mapping.MultisampleMappingReportTrait
import nl.lumc.sasc.biopet.utils.config.Configurable import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.utils.rscript.StackedBarPlot import nl.lumc.sasc.biopet.utils.rscript.StackedBarPlot
import nl.lumc.sasc.biopet.utils.summary.{ Summary, SummaryValue } import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import nl.lumc.sasc.biopet.utils.summary.{Summary, SummaryValue}
import scala.concurrent.Await
import scala.concurrent.duration.Duration
/** /**
* With this extension the report is executed within a pipeline * With this extension the report is executed within a pipeline
...@@ -37,7 +41,8 @@ object ShivaReport extends ShivaReportTrait ...@@ -37,7 +41,8 @@ object ShivaReport extends ShivaReportTrait
/** Trait for report generation for Shiva pipeline, this can be extended */ /** Trait for report generation for Shiva pipeline, this can be extended */
trait ShivaReportTrait extends MultisampleMappingReportTrait { trait ShivaReportTrait extends MultisampleMappingReportTrait {
def variantcallingExecuted = summary.getValue("shiva", "settings", "multisample_variantcalling") match { def variantcallingExecuted = summary.getSettingKeys(runId, Right("shiva"), None, keyValues = Map("multisample_variantcalling" -> List("multisample_variantcalling"))).get("multisample_variantcalling")
.flatten match {
case Some(true) => true case Some(true) => true
case _ => false case _ => false
} }
...@@ -60,8 +65,8 @@ trait ShivaReportTrait extends MultisampleMappingReportTrait { ...@@ -60,8 +65,8 @@ trait ShivaReportTrait extends MultisampleMappingReportTrait {
/** Generate a page with all target coverage stats */ /** Generate a page with all target coverage stats */
def regionsPage: Option[(String, ReportPage)] = { def regionsPage: Option[(String, ReportPage)] = {
val roi = summary.getValue("shiva", "settings", "regions_of_interest") val roi = summary.getSetting(runId, Right("shiva")).get("regions_of_interest")
val amplicon = summary.getValue("shiva", "settings", "amplicon_bed") val amplicon = summary.getSetting(runId, Right("shiva")).get("amplicon_bed")
var regionPages: Map[String, ReportPage] = Map() var regionPages: Map[String, ReportPage] = Map()
...@@ -108,7 +113,7 @@ trait ShivaReportTrait extends MultisampleMappingReportTrait { ...@@ -108,7 +113,7 @@ trait ShivaReportTrait extends MultisampleMappingReportTrait {
} }
/** Single sample page */ /** Single sample page */
override def samplePage(sampleId: String, args: Map[String, Any]): ReportPage = { override def samplePage(sampleId: Int, args: Map[String, Any]): ReportPage = {
val variantcallingSection = if (variantcallingExecuted) List("Variantcalling" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/shiva/sampleVariants.ssp")) else Nil val variantcallingSection = if (variantcallingExecuted) List("Variantcalling" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/shiva/sampleVariants.ssp")) else Nil
val oldPage = super.samplePage(sampleId, args) val oldPage = super.samplePage(sampleId, args)
oldPage.copy(sections = variantcallingSection ++ oldPage.sections) oldPage.copy(sections = variantcallingSection ++ oldPage.sections)
...@@ -123,51 +128,37 @@ trait ShivaReportTrait extends MultisampleMappingReportTrait { ...@@ -123,51 +128,37 @@ trait ShivaReportTrait extends MultisampleMappingReportTrait {
* @param outputDir OutputDir for the tsv and png file * @param outputDir OutputDir for the tsv and png file
* @param prefix Prefix of the tsv and png file