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

Fixed compile issues

parent b27102c7
......@@ -43,7 +43,7 @@
#end
#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">
<img src="insertsize.png" class="img-responsive" />
......
......@@ -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.flexiprep.FlexiprepReport
import scala.concurrent.Await
import scala.concurrent.duration.Duration
class MappingReport(val parent: Configurable) extends ReportBuilderExtension {
def builder = MappingReport
}
......@@ -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")
.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 */
def indexPage = {
val skipFlexiprep = summary.getValue(sampleId, libId, "mapping", "settings", "skip_flexiprep").getOrElse(false) == true
val bamMetricsPage = if (summary.getValue(sampleId, libId, "mapping", "settings", "skip_metrics").getOrElse(false) != true) {
val mappingSettings = summary.getSettingKeys(runId, Right("mapping"), None, sample = sampleId.map(Left(_)), library = libId.map(Left(_)),
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))
} else None
ReportPage((if (skipFlexiprep) Nil else List("QC" -> FlexiprepReport.flexiprepPage)) :::
......
......@@ -14,11 +14,14 @@
*/
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.flexiprep.FlexiprepReport
import nl.lumc.sasc.biopet.utils.config.Configurable
import scala.concurrent.Await
import scala.concurrent.duration.Duration
/**
* Created by pjvanthof on 11/01/16.
*/
......@@ -45,15 +48,20 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
/** Root page for the carp report */
def indexPage = {
val krakenExecuted = summary.getSampleValues("gearskraken", "stats", "krakenreport").values.forall(_.isDefined)
val centrifugeExecuted = summary.getSampleValues("gearscentrifuge", "stats", "centrifuge_report").values.forall(_.isDefined)
val wgsExecuted = summary.getSampleValues("bammetrics", "stats", "wgs").values.exists(_.isDefined)
val rnaExecuted = summary.getSampleValues("bammetrics", "stats", "rna").values.exists(_.isDefined)
val insertsizeExecuted = summary.getSampleValues("bammetrics", "stats", "CollectInsertSizeMetrics", "metrics").values.exists(_ != Some(None))
val mappingExecuted = summary.getLibraryValues("mapping").exists(_._2.isDefined)
val pairedFound = !mappingExecuted || summary.getLibraryValues("mapping", "settings", "paired").exists(_._2 == Some(true))
val flexiprepExecuted = summary.getLibraryValues("flexiprep")
.exists { case ((sample, lib), value) => value.isDefined }
val krakenExecuted = Await.result(summary.getStatsSize(runId, Right("gearskraken"), Some(Right("krakenreport")),
library = Some(None), mustHaveSample = true), Duration.Inf) >= 1
val centrifugeExecuted = Await.result(summary.getStatsSize(runId, Right("gearscentrifuge"), Some(Right("centrifuge_report")),
library = Some(None), mustHaveSample = true), Duration.Inf) >= 1
val wgsExecuted = Await.result(summary.getStatsSize(runId, Right("bammetrics"), Some(Right("wgs")),
library = Some(None), mustHaveSample = true), Duration.Inf) >= 1
val rnaExecuted = Await.result(summary.getStatsSize(runId, Right("bammetrics"), Some(Right("rna")),
library = Some(None), mustHaveSample = true), Duration.Inf) >= 1
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(
List("Samples" -> generateSamplesPage(pageArgs)) ++
......@@ -105,8 +113,7 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
/** Files page, can be used general or at sample level */
def filesPage: ReportPage = {
val flexiprepExecuted = summary.getLibraryValues("flexiprep")
.exists { case ((sample, lib), value) => value.isDefined }
val flexiprepExecuted = Await.result(summary.getStatsSize(runId, Right("flexiprep"), Some(None), mustHaveLibrary = true), Duration.Inf) >= 1
ReportPage(List(), (if (flexiprepExecuted) List(
"Input fastq files" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepInputfiles.ssp"),
......@@ -118,11 +125,13 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
}
/** Single sample page */
def samplePage(sampleId: String, args: Map[String, Any]): ReportPage = {
val krakenExecuted = summary.getValue(Some(sampleId), None, "gearskraken", "stats", "krakenreport").isDefined
val centrifugeExecuted = summary.getValue(Some(sampleId), None, "gearscentrifuge", "stats", "centrifuge_report").isDefined
val flexiprepExecuted = summary.getLibraryValues("flexiprep")
.exists { case ((sample, lib), value) => sample == sampleId && value.isDefined }
def samplePage(sampleId: Int, args: Map[String, Any]): ReportPage = {
val krakenExecuted = Await.result(summary.getStatsSize(runId, Right("gearskraken"), Some(Right("krakenreport")),
library = Some(None), sample = Some(Left(sampleId))), Duration.Inf) >= 1
val centrifugeExecuted = Await.result(summary.getStatsSize(runId, Right("gearscentrifuge"), Some(Right("centrifuge_report")),
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(
"Libraries" -> generateLibraryPage(args),
......@@ -149,10 +158,13 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
}
/** Library page */
def libraryPage(sampleId: String, libId: String, args: Map[String, Any]): ReportPage = {
val krakenExecuted = summary.getValue(Some(sampleId), Some(libId), "gearskraken", "stats", "krakenreport").isDefined
val centrifugeExecuted = summary.getValue(Some(sampleId), Some(libId), "gearscentrifuge", "stats", "centrifuge_report").isDefined
val flexiprepExecuted = summary.getValue(Some(sampleId), Some(libId), "flexiprep").isDefined
def libraryPage(sampleId: Int, libId: Int, args: Map[String, Any]): ReportPage = {
val krakenExecuted = Await.result(summary.getStatsSize(runId, Right("gearskraken"), Some(Right("krakenreport")),
library = Some(Left(libId)), sample = Some(Left(sampleId))), Duration.Inf) >= 1
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(
("Alignment" -> BammetricsReport.bamMetricsPage(summary, Some(sampleId), Some(libId))) ::
......
......@@ -14,13 +14,17 @@
*/
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.pipelines.mapping.MultisampleMappingReportTrait
import nl.lumc.sasc.biopet.utils.config.Configurable
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
......@@ -37,7 +41,8 @@ object ShivaReport extends ShivaReportTrait
/** Trait for report generation for Shiva pipeline, this can be extended */
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 _ => false
}
......@@ -60,8 +65,8 @@ trait ShivaReportTrait extends MultisampleMappingReportTrait {
/** Generate a page with all target coverage stats */
def regionsPage: Option[(String, ReportPage)] = {
val roi = summary.getValue("shiva", "settings", "regions_of_interest")
val amplicon = summary.getValue("shiva", "settings", "amplicon_bed")
val roi = summary.getSetting(runId, Right("shiva")).get("regions_of_interest")
val amplicon = summary.getSetting(runId, Right("shiva")).get("amplicon_bed")
var regionPages: Map[String, ReportPage] = Map()
......@@ -108,7 +113,7 @@ trait ShivaReportTrait extends MultisampleMappingReportTrait {
}
/** 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 oldPage = super.samplePage(sampleId, args)
oldPage.copy(sections = variantcallingSection ++ oldPage.sections)
......@@ -123,51 +128,37 @@ trait ShivaReportTrait extends MultisampleMappingReportTrait {
* @param outputDir OutputDir for the tsv and png file
* @param prefix Prefix of the tsv and png file
* @param summary Summary class
* @param libraryLevel Default false, when set true plot will be based on library stats instead of sample stats
* @param sampleId Default it selects all sampples, when sample is giving it limits to selected sample
*/
def variantSummaryPlot(outputDir: File,
prefix: String,
summary: Summary,
libraryLevel: Boolean = false,
sampleId: Option[String] = None,
summary: SummaryDb,
sampleId: Option[Int] = None,
caller: String = "final",
target: Option[String] = None): Unit = {
val tsvFile = new File(outputDir, prefix + ".tsv")
val pngFile = new File(outputDir, prefix + ".png")
val tsvWriter = new PrintWriter(tsvFile)
if (libraryLevel) tsvWriter.print("Library") else tsvWriter.print("Sample")
tsvWriter.println("\tHomVar\tHet\tHomRef\tNoCall")
def getLine(summary: Summary, sample: String, summarySample: Option[String], lib: Option[String] = None): String = {
val path = target match {
case Some(t) => List("shivavariantcalling", "stats", s"multisample-vcfstats-$caller-$t", "genotype", sample)
case _ => List("shivavariantcalling", "stats", s"multisample-vcfstats-$caller", "total", "genotype", "general", sample)
}
val homVar = new SummaryValue(path :+ "HomVar", summary, summarySample, lib).value.getOrElse(0).toString.toLong
val homRef = new SummaryValue(path :+ "HomRef", summary, summarySample, lib).value.getOrElse(0).toString.toLong
val noCall = new SummaryValue(path :+ "NoCall", summary, summarySample, lib).value.getOrElse(0).toString.toLong
val het = new SummaryValue(path :+ "Het", summary, summarySample, lib).value.getOrElse(0).toString.toLong
val sb = new StringBuffer()
if (lib.isDefined) sb.append(sample + "-" + lib.get + "\t") else sb.append(sample + "\t")
sb.append(homVar + "\t")
sb.append(het + "\t")
sb.append(homRef + "\t")
sb.append(noCall)
sb.toString
tsvWriter.print("Sample")
val field = List("HomVar", "Het", "HomRef", "NoCall")
tsvWriter.println(s"\t${field.mkString("\t")}")
val samples = Await.result(summary.getSamples(runId = runId, sampleId = sampleId), Duration.Inf)
val statsPaths = {
(for (sample <- Await.result(summary.getSamples(runId = runId), Duration.Inf)) yield {
field.map(f => s"${sample.name};HomVar" -> List("total", "genotype", "general", sample.name, f)).toMap
}).fold(Map())(_ ++ _)
}
val moduleName = target match {
case Some(t) => s"multisample-vcfstats-$caller-$t"
case _ => s"multisample-vcfstats-$caller"
}
if (libraryLevel) {
for (
sample <- summary.samples if sampleId.isEmpty || sample == sampleId.get;
lib <- summary.libraries(sample)
) {
tsvWriter.println(getLine(summary, sample, sampleId, Some(lib)))
}
} else {
for (sample <- summary.samples if sampleId.isEmpty || sample == sampleId.get) {
tsvWriter.println(getLine(summary, sample, sampleId))
}
val results = summary.getStatKeys(runId, Right("shivavariantcalling"), Some(Right(moduleName)), sampleId.map(Left(_)), keyValues = statsPaths)
for (sample <- samples if sampleId.isEmpty || sample.id == sampleId.get) {
tsvWriter.println(sample.name + "\t" + field.map(f => results(s"${sample.name};$f").getOrElse("")).mkString("\t"))
}
tsvWriter.close()
......@@ -176,9 +167,7 @@ trait ShivaReportTrait extends MultisampleMappingReportTrait {
plot.input = tsvFile
plot.output = pngFile
plot.ylabel = Some("VCF records")
if (libraryLevel) {
plot.width = Some(200 + (summary.libraries.filter(s => sampleId.getOrElse(s._1) == s._1).foldLeft(0)(_ + _._2.size) * 10))
} else plot.width = Some(200 + (summary.samples.count(s => sampleId.getOrElse(s) == s) * 10))
plot.width = Some(200 + (samples.count(s => sampleId.getOrElse(s) == s) * 10))
plot.runLocal()
}
}
......@@ -33,17 +33,5 @@ object TinyCapReport extends MultisampleMappingReportTrait {
/** Front section for the report */
override def frontSection: ReportSection = ReportSection("/nl/lumc/sasc/biopet/pipelines/tinycap/tinycapFront.ssp")
override def additionalSections = List(
"Fragments per gene" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gentrap/measure_plotreport.ssp",
Map("pipelineName" -> pipelineName,
"plotName" -> "fragmentspergene",
"plotPath" -> summary.getValue("fragmentspergene", "files", "pipeline", "fragments_per_gene_heatmap", "path")
)),
"Fragments per microRNA" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gentrap/measure_plotreport.ssp",
Map("pipelineName" -> pipelineName,
"plotName" -> "fragmentspersmallrna",
"plotPath" -> summary.getValue("fragmentspersmallrna", "files", "pipeline", "fragments_per_smallrna_heatmap", "path")))
)
override def pipelineName = "tinycap"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment