Commit b0ec2c16 authored by Peter van 't Hof's avatar Peter van 't Hof

Added files to report

parent f7dce595
#import(nl.lumc.sasc.biopet.utils.summary.db.Schema.File)
#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 pipelineNames: List[Option[String]] %>
<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.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]%>
<table class="table">
<thead><tr>
<th data-sorted="true" data-sorted-direction="ascending">Key</th>
<th>path</th><th>md5</th>
</tr></thead>
<tbody>
#for (file <- files)
<tr><td>${file.key}</td><td>${file.path}</td><td>${file.md5}</td></tr>
#end
</tbody>
</table>
...@@ -177,6 +177,11 @@ class SummaryDb(val db: Database) extends Closeable { ...@@ -177,6 +177,11 @@ class SummaryDb(val db: Database) extends Closeable {
getPipelines(runId = Some(runId), name = Some(pipelineName)).map(_.headOption.map(_.id)) getPipelines(runId = Some(runId), name = Some(pipelineName)).map(_.headOption.map(_.id))
} }
/** Return name of a pipeline */
def getPipelineName(pipelineId: Int): Future[Option[String]] = {
getPipelines(pipelineId = Some(pipelineId)).map(_.headOption.map(_.name))
}
/** Creates a new module, even if it already exist. This may give a database exeption */ /** Creates a new module, even if it already exist. This may give a database exeption */
def forceCreateModule(name: String, runId: Int, pipelineId: Int): Future[Int] = { def forceCreateModule(name: String, runId: Int, pipelineId: Int): Future[Int] = {
val id = Await.result(db.run(modules.size.result), Duration.Inf) val id = Await.result(db.run(modules.size.result), Duration.Inf)
...@@ -211,6 +216,11 @@ class SummaryDb(val db: Database) extends Closeable { ...@@ -211,6 +216,11 @@ class SummaryDb(val db: Database) extends Closeable {
getModules(runId = Some(runId), name = Some(moduleName), pipelineId = Some(pipelineId)).map(_.headOption.map(_.id)) getModules(runId = Some(runId), name = Some(moduleName), pipelineId = Some(pipelineId)).map(_.headOption.map(_.id))
} }
/** Returns name of a module */
def getModuleName(pipelineId: Int, moduleId: Int): Future[Option[String]] = {
getModules(pipelineId = Some(pipelineId), moduleId = Some(moduleId)).map(_.headOption.map(_.name))
}
/** Create a new stat in the database, This method is need checking before */ /** Create a new stat in the database, This method is need checking before */
def createStat(runId: Int, pipelineId: Int, moduleId: Option[Int] = None, def createStat(runId: Int, pipelineId: Int, moduleId: Option[Int] = None,
sampleId: Option[Int] = None, libId: Option[Int] = None, content: String): Future[Int] = { sampleId: Option[Int] = None, libId: Option[Int] = None, content: String): Future[Int] = {
......
...@@ -101,7 +101,9 @@ class SummaryDbTest extends TestNGSuite with Matchers { ...@@ -101,7 +101,9 @@ class SummaryDbTest extends TestNGSuite with Matchers {
val runId = Await.result(db.createRun("name", "dir", "version", "hash", date), Duration.Inf) val runId = Await.result(db.createRun("name", "dir", "version", "hash", date), Duration.Inf)
Await.result(db.getPipelines(), Duration.Inf) shouldBe empty Await.result(db.getPipelines(), Duration.Inf) shouldBe empty
Await.result(db.getPipelineName(0), Duration.Inf) shouldBe None
val pipelineId = Await.result(db.createPipeline("test", runId), Duration.Inf) val pipelineId = Await.result(db.createPipeline("test", runId), Duration.Inf)
Await.result(db.getPipelineName(pipelineId), Duration.Inf) shouldBe Some("test")
Await.result(db.getPipelines(), Duration.Inf) shouldBe Seq(Schema.Pipeline(pipelineId, "test", runId)) Await.result(db.getPipelines(), Duration.Inf) shouldBe Seq(Schema.Pipeline(pipelineId, "test", runId))
Await.result(db.getPipelineId(runId, "test"), Duration.Inf) shouldBe Some(pipelineId) Await.result(db.getPipelineId(runId, "test"), Duration.Inf) shouldBe Some(pipelineId)
Await.result(db.createPipeline("test", runId), Duration.Inf) shouldBe pipelineId Await.result(db.createPipeline("test", runId), Duration.Inf) shouldBe pipelineId
...@@ -122,8 +124,10 @@ class SummaryDbTest extends TestNGSuite with Matchers { ...@@ -122,8 +124,10 @@ class SummaryDbTest extends TestNGSuite with Matchers {
val runId = Await.result(db.createRun("name", "dir", "version", "hash", date), Duration.Inf) val runId = Await.result(db.createRun("name", "dir", "version", "hash", date), Duration.Inf)
val pipelineId = Await.result(db.createPipeline("test", runId), Duration.Inf) val pipelineId = Await.result(db.createPipeline("test", runId), Duration.Inf)
Await.result(db.getModules(), Duration.Inf) shouldBe empty Await.result(db.getModules(), Duration.Inf) shouldBe empty
Await.result(db.getModuleName(pipelineId, 0), Duration.Inf) shouldBe None
val moduleId = Await.result(db.createModule("test", runId, pipelineId), Duration.Inf) val moduleId = Await.result(db.createModule("test", runId, pipelineId), Duration.Inf)
Await.result(db.getmoduleId(runId, "test", pipelineId), Duration.Inf) shouldBe Some(moduleId) Await.result(db.getmoduleId(runId, "test", pipelineId), Duration.Inf) shouldBe Some(moduleId)
Await.result(db.getModuleName(pipelineId, moduleId), Duration.Inf) shouldBe Some("test")
Await.result(db.getModules(), Duration.Inf) shouldBe Seq(Schema.Module(pipelineId, "test", runId, pipelineId)) Await.result(db.getModules(), Duration.Inf) shouldBe Seq(Schema.Module(pipelineId, "test", runId, pipelineId))
Await.result(db.createModule("test", runId, pipelineId), Duration.Inf) shouldBe pipelineId Await.result(db.createModule("test", runId, pipelineId), Duration.Inf) shouldBe pipelineId
Await.result(db.getModules(), Duration.Inf) shouldBe Seq(Schema.Module(pipelineId, "test", runId, pipelineId)) Await.result(db.getModules(), Duration.Inf) shouldBe Seq(Schema.Module(pipelineId, "test", runId, pipelineId))
......
...@@ -14,14 +14,14 @@ ...@@ -14,14 +14,14 @@
*/ */
package nl.lumc.sasc.biopet.pipelines.mapping package nl.lumc.sasc.biopet.pipelines.mapping
import nl.lumc.sasc.biopet.core.report.{MultisampleReportBuilder, ReportBuilderExtension, ReportPage, ReportSection} 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 nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._ import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._ import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._
import scala.concurrent.{Await, Future} import scala.concurrent.{ Await, Future }
import scala.concurrent.duration.Duration import scala.concurrent.duration.Duration
import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.ExecutionContext.Implicits.global
...@@ -119,15 +119,22 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder { ...@@ -119,15 +119,22 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
val dbFiles = summary.getFiles(runId, sample = Some(sampleId.map(SampleId).getOrElse(NoSample)), val dbFiles = summary.getFiles(runId, sample = Some(sampleId.map(SampleId).getOrElse(NoSample)),
library = Some(libraryId.map(LibraryId).getOrElse(NoLibrary))) library = Some(libraryId.map(LibraryId).getOrElse(NoLibrary)))
.map(_.groupBy(_.pipelineId)) .map(_.groupBy(_.pipelineId))
.map(_.map { case (pipelineId, files) => val modulePages = dbFiles.map(_.map {
val moduleSections = files.groupBy(_.moduleId).map { case (moduleId, files) => case (pipelineId, files) =>
summary.getModules(moduleId = moduleId, pipelineId = pipelineId) val moduleSections = files.groupBy(_.moduleId).map {
.map(_.headOption.map(_.name).getOrElse("Pipeline") -> ReportSection("/nl/lumc/sasc/biopet/core/report/files.ssp")) case (moduleId, files) =>
} val moduleName: Future[String] = moduleId match {
summary.getPipelines(pipelineId = pipelineId).map(_.head.name -> ReportPage(Nil, Await.result(Future.sequence(moduleSections), Duration.Inf).toList, Map())) case Some(id) => summary.getModuleName(pipelineId, id).map(_.getOrElse("Pipeline"))
case _ => Future("Pipeline")
}
moduleName.map(_ -> ReportSection("/nl/lumc/sasc/biopet/core/report/files.ssp", Map("files" -> files)))
}
summary.getPipelineName(pipelineId = pipelineId).map(_.get -> ReportPage(Nil, Await.result(Future.sequence(moduleSections), Duration.Inf).toList, Map()))
}) })
dbFiles.flatMap(Future.sequence(_)).map(x => ReportPage(x.toList, Nil, Map())) val pipelineNames = dbFiles.flatMap(x => Future.sequence(x.map(y => summary.getPipelineName(y._1))))
modulePages.flatMap(Future.sequence(_)).map(x => ReportPage(x.toList, "Pipelines" -> ReportSection("/nl/lumc/sasc/biopet/core/report/fileModules.ssp", Map("pipelineNames" -> Await.result(pipelineNames, Duration.Inf).toList)) ::Nil, Map()))
} }
/** Single sample page */ /** Single sample page */
...@@ -184,7 +191,7 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder { ...@@ -184,7 +191,7 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
else Nil) ::: (if (krakenExecuted) List("Dustbin analysis" -> ReportPage(List(), List( else Nil) ::: (if (krakenExecuted) List("Dustbin analysis" -> ReportPage(List(), List(
"Krona Plot" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp" "Krona Plot" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp"
)), Map())) )), Map()))
else Nil), else Nil) ::: List("Files" -> Await.result(filesPage(sampleId = sampleId, libraryId = libId), Duration.Inf)),
"Alignment" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp") :: "Alignment" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp") ::
(if (flexiprepExecuted) List("QC reads" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepReadSummary.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")) "QC bases" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepBaseSummary.ssp"))
......
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