Commit 19a8db89 authored by Peter van 't Hof's avatar Peter van 't Hof

Fixing compile errors

parent 84c05fce
......@@ -24,8 +24,7 @@ import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Await
import scala.concurrent.{ Await, Future }
import scala.concurrent.duration.Duration
class BammetricsReport(val parent: Configurable) extends ReportBuilderExtension {
......@@ -43,12 +42,12 @@ object BammetricsReport extends ReportBuilder {
val reportName = "Bam Metrics"
/** Root page for single BamMetrcis report */
def indexPage = {
val bamMetricsPage = this.bamMetricsPage(summary, sampleId, libId)
def indexPage: Future[ReportPage] = Future {
val bamMetricsPage = Await.result(this.bamMetricsPage(summary, sampleId, libId), Duration.Inf)
ReportPage(bamMetricsPage.subPages ::: List(
"Versions" -> ReportPage(List(), List("Executables" -> ReportSection("/nl/lumc/sasc/biopet/core/report/executables.ssp"
)), Map()),
"Files" -> ReportPage(List(), List(), Map())
"Versions" -> Future(ReportPage(List(), List("Executables" -> ReportSection("/nl/lumc/sasc/biopet/core/report/executables.ssp"
)), Map())),
"Files" -> Future(ReportPage(List(), List(), Map()))
), List(
"Report" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/bamMetricsFront.ssp")
) ::: bamMetricsPage.sections,
......@@ -60,7 +59,7 @@ object BammetricsReport extends ReportBuilder {
def bamMetricsPage(summary: SummaryDb,
sampleId: Option[Int],
libId: Option[Int],
metricsTag: String = "bammetrics") = {
metricsTag: String = "bammetrics"): Future[ReportPage] = Future {
//val pipelineId: Int = summary.getPipelineId(runId, metricsTag).map(_.get)
......@@ -85,10 +84,10 @@ object BammetricsReport extends ReportBuilder {
ReportPage(
if (targets.isEmpty) List()
else List("Targets" -> ReportPage(
else List("Targets" -> Future(ReportPage(
List(),
targets.map(t => t -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/covstatsPlot.ssp", Map("target" -> Some(t)))),
Map())),
Map()))),
List(
"Summary" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp"),
"Mapping Quality" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/mappingQuality.ssp", Map("showPlot" -> true)),
......
......@@ -24,11 +24,10 @@ import org.broadinstitute.gatk.utils.commandline.Input
import org.fusesource.scalate.TemplateEngine
import scala.collection.mutable
import scala.concurrent.{ Await, Future }
import scala.concurrent.{ Await, ExecutionContextExecutor, Future }
import scala.concurrent.duration.Duration
import scala.language.postfixOps
import scala.language.implicitConversions
import scala.concurrent.ExecutionContext.Implicits.global
/**
* This trait is meant to make an extension for a report object
......@@ -74,8 +73,9 @@ trait ReportBuilderExtension extends ToolCommandFunction {
trait ReportBuilder extends ToolCommand {
implicit lazy val global: ExecutionContextExecutor = scala.concurrent.ExecutionContext.global
implicit def toOption[T](x: T): Option[T] = Option(x)
// implicit def autoWait[T](x: Future[T]): T = Await.result(x, Duration.Inf)
implicit def autoWait[T](x: Future[T]): T = Await.result(x, Duration.Inf)
case class Args(summaryDbFile: File = null,
outputDir: File = null,
......
......@@ -19,7 +19,7 @@ import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.{ LibraryId, SampleId }
import scala.concurrent.Await
import scala.concurrent.{ Await, Future }
import scala.concurrent.duration.Duration
class GearsSingleReport(val parent: Configurable) extends ReportBuilderExtension {
......@@ -31,7 +31,7 @@ object GearsSingleReport 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 indexPage = {
def indexPage: Future[ReportPage] = Future {
val sampleName = sampleId.flatMap(x => Await.result(summary.getSampleName(x), Duration.Inf))
val libraryName = libId.flatMap(x => Await.result(summary.getLibraryName(x), Duration.Inf))
......@@ -40,8 +40,8 @@ object GearsSingleReport extends ReportBuilder {
ReportPage(
List(
"Versions" -> ReportPage(List(),
List(("Executables" -> ReportSection("/nl/lumc/sasc/biopet/core/report/executables.ssp"))), Map())
"Versions" -> Future(ReportPage(List(),
List(("Executables" -> ReportSection("/nl/lumc/sasc/biopet/core/report/executables.ssp"))), Map()))
),
List("Gears intro" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/gearsSingleFront.ssp")) ++
(if (krakenExecuted) List("Kraken analysis" ->
......
......@@ -21,7 +21,7 @@ import nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._
import scala.concurrent.Await
import scala.concurrent.{ Await, Future }
import scala.concurrent.duration.Duration
class MappingReport(val parent: Configurable) extends ReportBuilderExtension {
......@@ -44,7 +44,7 @@ object MappingReport extends ReportBuilder {
sample = sampleId.map(SampleId), library = libId.map(LibraryId)), Duration.Inf) >= 1
/** Root page for single BamMetrcis report */
def indexPage = {
def indexPage: Future[ReportPage] = Future {
val mappingSettings = summary.getSettingKeys(runId, "mapping", NoModule,
sample = sampleId.map(SampleId).getOrElse(NoSample), library = libId.map(LibraryId).getOrElse(NoLibrary),
keyValues = Map("skip_flexiprep" -> List("skip_flexiprep"), "skip_metrics" -> List("skip_metrics")))
......@@ -54,13 +54,13 @@ object MappingReport extends ReportBuilder {
} else None
ReportPage((if (skipFlexiprep) Nil else List("QC" -> FlexiprepReport.flexiprepPage)) :::
bamMetricsPage.map(_.subPages).getOrElse(Nil) ::: List(
"Versions" -> ReportPage(List(), List("Executables" -> ReportSection("/nl/lumc/sasc/biopet/core/report/executables.ssp"
)), Map()),
"Files" -> ReportPage(List(), Nil, Map())
"Versions" -> Future(ReportPage(List(), List("Executables" -> ReportSection("/nl/lumc/sasc/biopet/core/report/executables.ssp"
)), Map())),
"Files" -> Future(ReportPage(List(), Nil, Map()))
) :::
(if (krakenExecuted) List("Gears - Metagenomics" -> ReportPage(List(), List(
(if (krakenExecuted) List("Gears - Metagenomics" -> Future(ReportPage(List(), List(
"Sunburst analysis" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/gearsSunburst.ssp"
)), Map()))
)), Map())))
else Nil), List(
"Report" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/mapping/mappingFront.ssp")
) ::: bamMetricsPage.map(_.sections).getOrElse(Nil),
......
......@@ -49,7 +49,7 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
.map(x => ExtFile("/nl/lumc/sasc/biopet/pipelines/gears/report/ext/" + x, x))
/** Root page for the carp report */
def indexPage = {
def indexPage: Future[ReportPage] = Future {
val krakenExecuted = Await.result(summary.getStatsSize(runId, "gearskraken", "krakenreport",
library = NoLibrary, mustHaveSample = true), Duration.Inf) >= 1
......@@ -67,22 +67,23 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
ReportPage(
List("Samples" -> generateSamplesPage(pageArgs)) ++
(if (krakenExecuted) List("Dustbin analysis - Kraken" -> ReportPage(List(), List(
(if (krakenExecuted) List("Dustbin analysis - Kraken" -> Future(ReportPage(List(), List(
"Krona plot" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp"
)), Map()))
else Nil) ++ (if (centrifugeExecuted) List("Centriguge analysis" -> ReportPage(List("Non-unique" -> ReportPage(List(), List("All mappings" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp",
Map("summaryStatsTag" -> "centrifuge_report")
)), Map())), List(
)), Map())))
else Nil) ++ (if (centrifugeExecuted) List("Centriguge analysis" -> Future(ReportPage(List(
"Non-unique" -> Future(ReportPage(List(), List("All mappings" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp",
Map("summaryStatsTag" -> "centrifuge_report")
)), Map()))), List(
"Unique mappings" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp",
Map("summaryStatsTag" -> "centrifuge_unique_report")
)), Map("summaryModuleTag" -> "gearscentrifuge", "centrifugeTag" -> Some("centrifuge"))))
)), Map("summaryModuleTag" -> "gearscentrifuge", "centrifugeTag" -> Some("centrifuge")))))
else Nil) ++
List("Reference" -> ReportPage(List(), List(
List("Reference" -> Future(ReportPage(List(), List(
"Reference" -> ReportSection("/nl/lumc/sasc/biopet/core/report/reference.ssp", Map("pipeline" -> pipelineName))
), Map()),
"Files" -> Await.result(filesPage(), Duration.Inf),
"Versions" -> ReportPage(List(), List("Executables" -> ReportSection("/nl/lumc/sasc/biopet/core/report/executables.ssp"
)), Map())
), Map())),
"Files" -> filesPage(),
"Versions" -> Future(ReportPage(List(), List("Executables" -> ReportSection("/nl/lumc/sasc/biopet/core/report/executables.ssp"
)), Map()))
),
List(
"Report" -> frontSection) ++
......@@ -129,7 +130,7 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
moduleName.map(_ -> ReportSection("/nl/lumc/sasc/biopet/core/report/files.ssp", Map("files" -> files)))
}
val moduleSectionsSorted = moduleSections.find(_._1 == "Pipeline") ++ moduleSections.filter(_._1 != "Pipeline")
summary.getPipelineName(pipelineId = pipelineId).map(_.get -> ReportPage(Nil, Await.result(Future.sequence(moduleSectionsSorted), Duration.Inf).toList, Map()))
summary.getPipelineName(pipelineId = pipelineId).map(_.get -> Future(ReportPage(Nil, Await.result(Future.sequence(moduleSectionsSorted), Duration.Inf).toList, Map())))
})
val pipelineFiles = summary.getPipelineId(runId, pipelineName).flatMap(pipelinelineId => dbFiles.map(x => x(pipelinelineId.get).filter(_.moduleId.isEmpty)))
......@@ -140,7 +141,7 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
}
/** Single sample page */
def samplePage(sampleId: Int, args: Map[String, Any]): ReportPage = {
def samplePage(sampleId: Int, args: Map[String, Any]): Future[ReportPage] = Future {
val krakenExecuted = Await.result(summary.getStatsSize(runId, "gearskraken", "krakenreport",
library = NoLibrary, sample = sampleId), Duration.Inf) >= 1
val centrifugeExecuted = Await.result(summary.getStatsSize(runId, "gearscentrifuge", "centrifuge_report",
......@@ -151,17 +152,18 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
ReportPage(List(
"Libraries" -> generateLibraryPage(args),
"Alignment" -> BammetricsReport.bamMetricsPage(summary, Some(sampleId), None)) ++
(if (centrifugeExecuted) List("Centriguge analysis" -> ReportPage(List("Non-unique" -> ReportPage(List(), List("All mappings" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp",
Map("summaryStatsTag" -> "centrifuge_report", "centrifugeTag" -> Some("centrifuge"))
)), Map())), List(
(if (centrifugeExecuted) List("Centriguge analysis" -> Future(ReportPage(List(
"Non-unique" -> Future(ReportPage(List(), List("All mappings" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp",
Map("summaryStatsTag" -> "centrifuge_report", "centrifugeTag" -> Some("centrifuge"))
)), Map()))), List(
"Unique mappings" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp",
Map("summaryStatsTag" -> "centrifuge_unique_report")
)), Map("summaryModuleTag" -> "gearscentrifuge")))
else Nil) ::: (if (krakenExecuted) List("Dustbin analysis" -> ReportPage(List(), List(
)), Map("summaryModuleTag" -> "gearscentrifuge"))))
else Nil) ::: (if (krakenExecuted) List("Dustbin analysis" -> Future(ReportPage(List(), List(
"Krona Plot" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp"
)), Map()))
)), Map())))
else Nil) ++
List("Files" -> Await.result(filesPage(sampleId = sampleId), Duration.Inf)
List("Files" -> filesPage(sampleId = sampleId)
), List(
"Alignment" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp",
Map("showPlot" -> true)),
......@@ -173,7 +175,7 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
}
/** Library page */
def libraryPage(sampleId: Int, libId: Int, args: Map[String, Any]): ReportPage = {
def libraryPage(sampleId: Int, libId: Int, args: Map[String, Any]): Future[ReportPage] = Future {
val krakenExecuted = Await.result(summary.getStatsSize(runId, "gearskraken", "krakenreport",
library = libId, sample = sampleId), Duration.Inf) >= 1
val centrifugeExecuted = Await.result(summary.getStatsSize(runId, "gearscentrifuge", "centrifuge_report",
......@@ -184,16 +186,17 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
ReportPage(
("Alignment" -> BammetricsReport.bamMetricsPage(summary, Some(sampleId), Some(libId))) ::
(if (flexiprepExecuted) List("QC" -> FlexiprepReport.flexiprepPage) else Nil) :::
(if (centrifugeExecuted) List("Centriguge analysis" -> ReportPage(List("Non-unique" -> ReportPage(List(), List("All mappings" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp",
Map("summaryStatsTag" -> "centrifuge_report")
)), Map())), List(
(if (centrifugeExecuted) List("Centriguge analysis" -> Future(ReportPage(List(
"Non-unique" -> Future(ReportPage(List(), List("All mappings" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp",
Map("summaryStatsTag" -> "centrifuge_report")
)), Map()))), List(
"Unique mappings" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp",
Map("summaryStatsTag" -> "centrifuge_unique_report")
)), Map("summaryModuleTag" -> "gearscentrifuge", "centrifugeTag" -> Some("centrifuge"))))
else Nil) ::: (if (krakenExecuted) List("Dustbin analysis" -> ReportPage(List(), List(
)), Map("summaryModuleTag" -> "gearscentrifuge", "centrifugeTag" -> Some("centrifuge")))))
else Nil) ::: (if (krakenExecuted) List("Dustbin analysis" -> Future(ReportPage(List(), List(
"Krona Plot" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp"
)), Map()))
else Nil) ::: List("Files" -> Await.result(filesPage(sampleId = sampleId, libraryId = libId), Duration.Inf)),
)), Map())))
else Nil) ::: List("Files" -> filesPage(sampleId = sampleId, libraryId = libId)),
"Alignment" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp") ::
(if (flexiprepExecuted) List("QC reads" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepReadSummary.ssp"),
"QC bases" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepBaseSummary.ssp"))
......
......@@ -24,7 +24,7 @@ import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.{ NoModule, NoSample, SampleId }
import scala.concurrent.Await
import scala.concurrent.{ Await, Future }
import scala.concurrent.duration.Duration
/**
......@@ -57,15 +57,15 @@ trait ShivaReportTrait extends MultisampleMappingReportTrait {
else Nil)
/** Root page for the shiva report */
override def indexPage = {
override def indexPage: Future[ReportPage] = Future {
val regions = regionsPage
val oldPage = super.indexPage
val oldPage = Await.result(super.indexPage, Duration.Inf)
oldPage.copy(subPages = oldPage.subPages ++ regionsPage)
}
/** Generate a page with all target coverage stats */
def regionsPage: Option[(String, ReportPage)] = {
def regionsPage: Option[(String, Future[ReportPage])] = {
val shivaSettings = Await.result(summary.getSetting(runId, "shiva"), Duration.Inf).get
val roi = shivaSettings.get("regions_of_interest")
val amplicon = shivaSettings.get("amplicon_bed")
......@@ -91,24 +91,24 @@ trait ShivaReportTrait extends MultisampleMappingReportTrait {
case _ =>
}
if (regionPages.nonEmpty) Some("Regions" -> ReportPage(
regionPages.map(p => p._1 -> ReportPage(Nil,
if (regionPages.nonEmpty) Some("Regions" -> Future(ReportPage(
regionPages.map(p => p._1 -> Future(ReportPage(Nil,
List(
"Variants" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/shiva/sampleVariants.ssp", Map("showPlot" -> true)),
"Coverage" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/covstatsMultiTable.ssp")
),
Map("target" -> Some(p._1.stripSuffix(" (Amplicon)")))
)).toList.sortBy(_._1),
))).toList.sortBy(_._1),
List(),
Map())
Map()))
)
else None
}
/** Single sample page */
override def samplePage(sampleId: Int, args: Map[String, Any]): ReportPage = {
override def samplePage(sampleId: Int, args: Map[String, Any]): Future[ReportPage] = Future {
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: ReportPage = super.samplePage(sampleId, args)
oldPage.copy(sections = variantcallingSection ++ oldPage.sections)
}
......
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