Commit 83188c3f authored by Ruben Vorderman's avatar Ruben Vorderman
Browse files

Simplified structure

parent 8263ea12
......@@ -421,7 +421,7 @@ object ReportBuilder {
}
)
)
*/
*/
/** Single template render engine, this will have a cache for all compile templates */
protected val engine = new TemplateEngine()
engine.allowReload = false
......
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
#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.Implicts._)
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(scala.concurrent.Await)
#import(scala.concurrent.duration.Duration)
#import(java.io.File)
#import(nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport)
<%@ var summary: SummaryDb %>
<%@ var runId: Int %>
<%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %>
......@@ -28,11 +22,12 @@
<%@ var librariesCount: Int %>
<%@ var clipCount: Int %>
<%@ var trimCount: Int %>
<%@ var flexiprepReportPlotRead1: Option[Unit] %>
<%@ var flexiprepReportPlotRead2: Option[Unit] %>
<%@ var sortableThemeBootstrap: scala.collection.mutable.Map[Int,scala.collection.mutable.Map[Int,Map[String,Map[String,Long]]]] %>
<%@ var seqstatStats: Map[(Int, Int), Map[String, Option[Any]]] %>
<%@ var seqstatQCStats: Map[(Int, Int), Map[String, Option[Any]]] %>
<%@ var clippingStats: Map[(Int, Int), Map[String, Option[Any]]] %>
<%@ var trimmingStats: Map[(Int, Int), Map[String, Option[Any]]] %>
#if (showIntro)
#if showIntro
<br/>
<div class="row">
<div class="col-md-1"></div>
......@@ -72,10 +67,6 @@
#end
#if (showPlot)
#{
flexiprepReportPlotRead1.getOrElse(None)
if (paired) flexiprepReportPlotRead2.getOrElse(None)
}#
<div class="panel-body">
<div class="row">
<div class="col-sm-6 col-md-6">
......@@ -121,7 +112,7 @@
#{
val sampleRowspan = {
libraries.filter(_.sampleId == sample.id).size +
settings.filter(_._1._1 == sample.id).count(_._2("paired").getOrElse(false) == true)
settings.filter(_._1._1 == sample.id).count(_._2("paired").getOrElse(false) == true)
}
}#
<tr><td rowspan="${sampleRowspan}">
......@@ -134,27 +125,27 @@
#for (lib <- libraries.filter(_.sampleId == sample.id))
#{ val paired = settings.filter(_._1._1 == sample.id).filter(_._1._2 == lib.id).head._2("paired") == Some(true) }#
<td #if (paired == true) rowspan="2" #end>
#if (multisample)
<a href="${rootPath}Samples/${sample.name}/Libraries/${lib.name}/index.html">${lib.name}</a>
#else
${lib.name}
#end
#if (multisample)
<a href="${rootPath}Samples/${sample.name}/Libraries/${lib.name}/index.html">${lib.name}</a>
#else
${lib.name}
#end
</td>
#{ val reads = if (paired == true) List("R1", "R2") else List("R1") }#
#{ val reads = if (paired) List("R1", "R2") else List("R1") }#
#for (read <- reads)
#if (read == "R2") </tr><tr> #end
#{
val beforeTotal = sortableThemeBootstrap(sample.id)(lib.id)(read)("beforeTotal")
val afterTotal = sortableThemeBootstrap(sample.id)(lib.id)(read)("afterTotal")
val clippingDiscardedTooShort = sortableThemeBootstrap(sample.id)(lib.id)(read)("clippingDiscardedTooShort")
val clippingDiscardedTooLong: Long = sortableThemeBootstrap(sample.id)(lib.id)(read)("clippingDiscardedTooLong")
val trimmingDiscarded: Long = sortableThemeBootstrap(sample.id)(lib.id)(read)("trimmingDiscarded")
val beforeTotal = seqstatStats(sample.id,lib.id)("num_total").getOrElse(0).toString.toLong
val afterTotal = seqstatQCStats(sample.id,lib.id)("num_total").getOrElse(0).toString.toLong
val clippingDiscardedToShort = clippingStats(sample.id,lib.id)("num_reads_discarded_too_short").getOrElse(0).toString.toLong
val clippingDiscardedToLong = clippingStats(sample.id,lib.id)("num_reads_discarded_too_long").getOrElse(0).toString.toLong
val trimmingDiscarded = trimmingStats(sample.id,lib.id)("num_reads_discarded").getOrElse(0).toString.toLong
}#
<td>${read}</td>
<td>${beforeTotal}</td>
<td>${clippingDiscardedTooShort + clippingDiscardedTooLong}</td>
<td>${clippingDiscardedToShort + clippingDiscardedToLong}</td>
<td>${trimmingDiscarded}</td>
#if (paired == true) <td>${beforeTotal - clippingDiscardedTooShort - clippingDiscardedTooLong - trimmingDiscarded - afterTotal}</td> #end
#if (paired == true) <td>${beforeTotal - clippingDiscardedToShort - clippingDiscardedToLong - trimmingDiscarded - afterTotal}</td> #end
<td>${afterTotal}</td>
#end
</tr>
......
......@@ -30,6 +30,7 @@ import nl.lumc.sasc.biopet.utils.summary.db.Schema.Library
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._
import scala.collection.mutable
import scala.concurrent.{Await, Future}
import scala.concurrent.duration.Duration
......@@ -225,25 +226,25 @@ object FlexiprepReport extends ReportBuilder {
object FlexiprepReadSummary {
def values(summary: SummaryDb,
outputDir: File,
runId: Int,
allSamples: Seq[Sample],
allLibraries: Seq[Library],
multisample: Boolean = true,
sampleId: Option[Int] = None,
libId: Option[Int] = None): Map[String, Any] = {
val samples = sampleId.map(id => allSamples.filter(_.id == id)).getOrElse(allSamples)
val libraries = libId.map(id => allLibraries.filter(_.id == id)).getOrElse(allLibraries)
libId: Option[Int] = None,
showPlot: Boolean = false,
showTable: Boolean = true,
showIntro: Boolean = true,
multisample: Boolean = true): Map[String, Any] = {
val settings = summary.getSettingsForLibraries(runId,
"flexiprep",
keyValues =
Map("skip_trim" -> List("skip_trim"),
"skip_clip" -> List("skip_clip"),
"paired" -> List("paired")))
val trimCount = settings.count(_._2.getOrElse("skip_trim", None) == Some(false))
val clipCount = settings.count(_._2.getOrElse("skip_clip", None) == Some(false))
val librariesCount = libraries.size
val paired: Boolean =
settings.count(_._2.getOrElse("skip_trim", None).contains(true))
val paired =
if (sampleId.isDefined && libId.isDefined)
summary
.getSettingKeys(runId,
......@@ -252,79 +253,39 @@ object FlexiprepReadSummary {
SampleId(sampleId.get),
LibraryId(libId.get),
keyValues = Map("paired" -> List("paired")))
.getOrElse("paired", None) == Some(true)
else settings.count(_._2.getOrElse("paired", None) == Some(true)) >= 1
/* TODO make this an iterable map object that kan be accessed in flexiprepReadSummary.ssp **/
def placeHolder = {
for (sample <- samples.sortBy(_.name))
{
val sampleRowspan = {
libraries.filter(_.sampleId == sample.id).size +
settings.filter(_._1._1 == sample.id).count(_._2("paired").getOrElse(false) == true)
}
if (multisample)
for (lib <- libraries.filter(_.sampleId == sample.id))
val paired = settings.filter(_._1._1 == sample.id).filter(_._1._2 == lib.id).head._2("paired") == Some(true)
val reads = if (paired == true) List("R1", "R2") else List("R1")
for (read <- reads)
if (read == "R2"){
val seqstatPaths = Map("num_total" -> List("reads", "num_total"))
val seqstatStats = summary.getStatKeys(runId, "flexiprep", "seqstat_" + read, sample = sample.id, library = lib.id, keyValues = seqstatPaths)
val seqstatQcStats = summary.getStatKeys(runId, "flexiprep", "seqstat_" + read + "_qc", sample = sample.id, library = lib.id, keyValues = seqstatPaths)
val clippingPaths = Map("num_reads_discarded_too_short" -> List("num_reads_discarded_too_short"),
"num_reads_discarded_too_long" -> List("num_reads_discarded_too_long"))
val clippingStats = summary.getStatKeys(runId, "flexiprep", "clipping_" + read, sample = sample.id, library = lib.id, keyValues = clippingPaths)
val trimmingPaths = Map("num_reads_discarded" -> List("num_reads_discarded_total"))
val trimmingStats = summary.getStatKeys(runId, "flexiprep", "trimming_" + read, sample = sample.id, library = lib.id, keyValues = trimmingPaths)
val beforeTotal = seqstatStats("num_total").getOrElse(0).toString.toLong
val afterTotal = seqstatQcStats("num_total").getOrElse(0).toString.toLong
val clippingDiscardedToShort = clippingStats("num_reads_discarded_too_short").getOrElse(0).toString.toLong
val clippingDiscardedToLong = clippingStats("num_reads_discarded_too_long").getOrElse(0).toString.toLong
val trimmingDiscarded = trimmingStats("num_reads_discarded").getOrElse(0).toString.toLong
}
}
}
}
}
object FlexiprepReadSummaryReportPage {
def values(summary: SummaryDb,
outputDir: File,
runId: Int,
allSamples: Seq[Sample],
allLibraries: Seq[Library],
sampleId: Option[Int] = None,
libId: Option[Int] = None,
showPlot: Boolean = false,
showTable: Boolean = true,
showIntro: Boolean = true,
multisample: Boolean = true
)= {
val settings = summary.getSettingsForLibraries(runId, "flexiprep", keyValues = Map("skip_trim" -> List("skip_trim"), "skip_clip" -> List("skip_clip"), "paired" -> List("paired")))
settings.count(_._2.getOrElse("skip_trim", None) == Some(true))
val paired = if (sampleId.isDefined && libId.isDefined){
summary.getSettingKeys(runId, "flexiprep", NoModule, SampleId(sampleId.get), LibraryId(libId.get), keyValues = Map("paired" -> List("paired"))).getOrElse("paired", None) == Some(true)}
else settings.count(_._2.getOrElse("paired", None) == Some(true)) >= 1
.getOrElse("paired", None)
.contains(true)
else settings.count(_._2.getOrElse("paired", None).contains(true)) >= 1
val samples = sampleId.map(id => allSamples.filter(_.id == id)).getOrElse(allSamples)
val libraries = libId.map(id => allLibraries.filter(_.id == id)).getOrElse(allLibraries)
val trimCount = settings.count(_._2.getOrElse("skip_trim", None) == Some(false))
val clipCount = settings.count(_._2.getOrElse("skip_clip", None) == Some(false))
val trimCount = settings.count(_._2.getOrElse("skip_trim", None).contains(false))
val clipCount = settings.count(_._2.getOrElse("skip_clip", None).contains(false))
val librariesCount = libraries.size
val flexiprepReportPlotRead1: Option[Unit] = if (showPlot){Some(FlexiprepReport.readSummaryPlot(outputDir, "QC_Reads_R1","R1", summary, sampleId = sampleId))}
val flexiprepReportPlotRead2: Option[Unit] = if (showPlot){ if (paired){Some(FlexiprepReport.readSummaryPlot(outputDir, "QC_Reads_R2","R2", summary, sampleId = sampleId))}}
if (showPlot) {
FlexiprepReport.readSummaryPlot(outputDir, "QC_Reads_R1", "R1", summary, sampleId = sampleId)
if (paired)
FlexiprepReport.readSummaryPlot(outputDir,
"QC_Reads_R2",
"R2",
summary,
sampleId = sampleId)
}
val sortableThemeBootstrapValues = sortableThemeBootstrap(samples,libraries,settings,summary,runId)
val seqstatPaths = Map("num_total" -> List("reads", "num_total"))
val clippingPaths = Map(
"num_reads_discarded_too_short" -> List("num_reads_discarded_too_short"))
val trimmingPaths = Map("num_reads_discarded" -> List("num_reads_discarded_total"))
val seqstatStats: Map[(Int, Int), Map[String, Option[Any]]] =
summary.getStatsForLibraries(runId, "flexiprep", "seqstat_R1", sampleId, seqstatPaths)
val seqstatQCStats =
summary.getStatsForLibraries(runId, "flexiprep", "seqstat_R1_QC", sampleId, seqstatPaths)
val clippingStats =
summary.getStatsForLibraries(runId, "flexiprep", "seqstat_R1", sampleId, clippingPaths)
val trimmingStats =
summary.getStatsForLibraries(runId, "flexiprep", "seqstat_R1", sampleId, trimmingPaths)
Map(
"summary" -> summary,
......@@ -332,67 +293,17 @@ object FlexiprepReadSummaryReportPage {
"runId" -> runId,
"sampleId" -> sampleId,
"libId" -> libId,
"showPlot"
"showPlot" -> showPlot,
"settings" -> settings,
"samples" -> samples,
"libraries" -> libraries,
"trimCount" -> trimCount,
"clipCount" -> clipCount,
"librariesCount" -> librariesCount,
"flexipreprReportPlotRead1" -> flexiprepReportPlotRead1,
"flexipreprReportPlotRead2" -> flexiprepReportPlotRead2,
"sortableThemeBootstrap" -> sortableThemeBootstrapValues
"seqstatStats" -> seqstatStats,
"seqstatQCStats" -> seqstatQCStats,
"clippingStats" -> clippingStats,
"trimmingStats" -> trimmingStats
)
}
def sortableThemeBootstrap(
samples: Seq[Sample],
libraries: Seq[Library],
settings: Map[(Int, Int), Map[String, Option[Any]]],
summary: SummaryDb,
runId: Int
):scala.collection.mutable.Map[Int,scala.collection.mutable.Map[Int,Map[String,Map[String,Long]]]] = {
var sortableThemeBootstrap = scala.collection.mutable.Map[Int,scala.collection.mutable.Map[Int,Map[String,Map[String,Long]]]]() /* iterable map */
for (sample <- samples.sortBy(_.name)) {
val sampleRowspan = {
libraries.filter(_.sampleId == sample.id).size +
settings.filter(_._1._1 == sample.id).count(_._2("paired").getOrElse(false) == true)
}
for (lib <- libraries.filter(_.sampleId == sample.id)) {
val paired = settings.filter(_._1._1 == sample.id).filter(_._1._2 == lib.id).head._2("paired") == Some(true)
val reads = if (paired == true) List("R1", "R2") else List("R1")
for (read <- reads)
if (read != "R2") {
val seqstatPaths = Map("num_total" -> List("reads", "num_total"))
val seqstatStats = summary.getStatKeys(runId, "flexiprep", "seqstat_" + read, sample = sample.id, library = lib.id, keyValues = seqstatPaths)
val seqstatQcStats = summary.getStatKeys(runId, "flexiprep", "seqstat_" + read + "_qc", sample = sample.id, library = lib.id, keyValues = seqstatPaths)
val clippingPaths = Map("num_reads_discarded_too_short" -> List("num_reads_discarded_too_short"),
"num_reads_discarded_too_long" -> List("num_reads_discarded_too_long"))
val clippingStats = summary.getStatKeys(runId, "flexiprep", "clipping_" + read, sample = sample.id, library = lib.id, keyValues = clippingPaths)
val trimmingPaths = Map("num_reads_discarded" -> List("num_reads_discarded_total"))
val trimmingStats = summary.getStatKeys(runId, "flexiprep", "trimming_" + read, sample = sample.id, library = lib.id, keyValues = trimmingPaths)
val beforeTotal: Long = seqstatStats("num_total").getOrElse(0).toString.toLong
val afterTotal: Long = seqstatQcStats("num_total").getOrElse(0).toString.toLong
val clippingDiscardedTooShort: Long = clippingStats("num_reads_discarded_too_short").getOrElse(0).toString.toLong
val clippingDiscardedTooLong: Long = clippingStats("num_reads_discarded_too_long").getOrElse(0).toString.toLong
val trimmingDiscarded: Long = trimmingStats("num_reads_discarded").getOrElse(0).toString.toLong
sortableThemeBootstrap(sample.id)(lib.id)(read) = Map(
"beforeTotal" -> beforeTotal,
"afterTotal" -> afterTotal,
"clippingDiscardedTooShort" -> clippingDiscardedTooShort,
"clippingDiscardedTooLong" -> clippingDiscardedTooLong,
"trimmingDiscarded" -> trimmingDiscarded
)
}
}
}
sortableThemeBootstrap
}
}
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