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

Fixing BIOPET-577

parent b0ec2c16
#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._)
......@@ -9,7 +10,9 @@
<%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %>
<%@ var runId: Int %>
<%@ var pipelineNames: List[Option[String]] %>
<%@ 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>
......
#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._)
......@@ -10,14 +14,29 @@
<%@ var libId: Option[Int] = None %>
<%@ var runId: Int %>
<%@ var files: Seq[File]%>
<table class="table">
<%@ 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>
<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>
<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>
......@@ -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]()
......@@ -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
......
......@@ -105,7 +105,7 @@ object Schema {
}
val settings = TableQuery[Settings]
case class File(runId: Int, pipelineId: Int, moduleId: Option[Int], sampleId: Option[Int], library: Option[Int], key: String, path: String, md5: String, link: Boolean, size: Long)
case class File(runId: Int, pipelineId: Int, moduleId: Option[Int], sampleId: Option[Int], libraryId: Option[Int], key: String, path: String, md5: String, link: Boolean, size: Long)
class Files(tag: Tag) extends Table[File](tag, "Files") {
def runId = column[Int]("runId")
def pipelineId = column[Int]("pipelineId")
......
......@@ -116,25 +116,28 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
/** Files page, can be used general or at sample level */
def filesPage(sampleId: Option[Int] = None, libraryId: Option[Int] = None): Future[ReportPage] = {
val dbFiles = summary.getFiles(runId, sample = Some(sampleId.map(SampleId).getOrElse(NoSample)),
library = Some(libraryId.map(LibraryId).getOrElse(NoLibrary)))
val dbFiles = summary.getFiles(runId, sample = sampleId.map(SampleId),
library = libraryId.map(LibraryId))
.map(_.groupBy(_.pipelineId))
val modulePages = dbFiles.map(_.map {
case (pipelineId, files) =>
val moduleSections = files.groupBy(_.moduleId).map {
case (moduleId, files) =>
val moduleName: Future[String] = moduleId match {
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()))
})
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()))
case (pipelineId, files) =>
val moduleSections = files.groupBy(_.moduleId).map {
case (moduleId, files) =>
val moduleName: Future[String] = moduleId match {
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)))
}
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()))
})
val pipelineFiles = summary.getPipelineId(runId, pipelineName).flatMap(pipelinelineId => dbFiles.map(x => x(pipelinelineId.get).filter(_.moduleId.isEmpty)))
modulePages.flatMap(Future.sequence(_)).map(x => ReportPage(x.toList,
s"$pipelineName files" -> ReportSection("/nl/lumc/sasc/biopet/core/report/files.ssp", Map("files" -> Await.result(pipelineFiles, Duration.Inf))) ::
"Sub pipelines/modules" -> ReportSection("/nl/lumc/sasc/biopet/core/report/fileModules.ssp", Map("pipelineIds" -> Await.result(dbFiles.map(_.keys.toList), Duration.Inf))) :: Nil, Map()))
}
/** Single sample page */
......
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