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

Switch templates to scalaz

parent 18b8594a
......@@ -4,6 +4,8 @@
#import(scala.concurrent.duration.Duration)
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
#import(java.io.File)
#import(scalaz._)
#import(Scalaz._)
<%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %>
......@@ -87,7 +89,7 @@
"Duplicates" -> List("flagstats", "Duplicates"),
"NotPrimaryAlignment" -> List("flagstats", "NotPrimaryAlignment")
)
val results = summary.getStatKeys(runId, Right("bammetrics"), Some(Right("bamstats")), sample = Some(Left(sample.id)), library = libId.map(Left(_)), keyValues = statsPaths)
val results = summary.getStatKeys(runId, "bammetrics".right, Some("bamstats".right), sample = Some(sample.id.left), library = libId.map(_.left), keyValues = statsPaths)
val total = results("All").getOrElse(0L).asInstanceOf[Long]
val mapped = results("Mapped").getOrElse(0L).asInstanceOf[Long]
val duplicates = results("Duplicates").getOrElse(0L).asInstanceOf[Long]
......
......@@ -4,6 +4,8 @@
#import(scala.concurrent.duration.Duration)
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
#import(java.io.File)
#import(scalaz._)
#import(Scalaz._)
<%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %>
......@@ -82,7 +84,7 @@
#if (!sampleLevel) <td><a href="${rootPath}Samples/${sample.name}/Libraries/${libName}/index.html">${libName}</a></td> #end
#{
val statsPaths = fields.map(x => x -> List("clipping", "general", x)).toMap
val results = summary.getStatKeys(runId, Right("bammetrics"), Some(Right("bamstats")), sample = Some(Left(sample.id)), library = libId.map(Left(_)), keyValues = statsPaths)
val results = summary.getStatKeys(runId, "bammetrics".right, Some("bamstats".right), sample = Some(sample.id.left), library = libId.map(_.left), keyValues = statsPaths)
}#
#for (field <- fields)
<td>${results(field)}</td>
......
......@@ -4,6 +4,8 @@
#import(scala.concurrent.duration.Duration)
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
#import(java.io.File)
#import(scalaz._)
#import(Scalaz._)
<%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %>
......@@ -84,7 +86,7 @@
#if (!sampleLevel) <td><a href="${rootPath}Samples/${sample.name}/Libraries/${libName}/index.html">${libName}</a></td> #end
#{
val statsPaths = fields.map(x => x -> List("metrics", x.toUpperCase)).toMap
val results = summary.getStatKeys(runId, Right("bammetrics"), Some(Right("CollectInsertSizeMetrics")), sample = Some(Left(sample.id)), library = libId.map(Left(_)), keyValues = statsPaths)
val results = summary.getStatKeys(runId, "bammetrics".right, Some("CollectInsertSizeMetrics".right), sample = Some(sample.id.left), library = libId.map(_.left), keyValues = statsPaths)
}#
#for (field <- fields)
<td>${results(field)}</td>
......
......@@ -4,6 +4,8 @@
#import(scala.concurrent.duration.Duration)
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
#import(java.io.File)
#import(scalaz._)
#import(Scalaz._)
<%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %>
......@@ -83,7 +85,7 @@
#if (!sampleLevel) <td><a href="${rootPath}Samples/${sample.name}/Libraries/${libName}/index.html">${libName}</a></td> #end
#{
val statsPaths = fields.map(x => x -> List("mapping_quality", "general", x)).toMap
val results = summary.getStatKeys(runId, Right("bammetrics"), Some(Right("bamstats")), sample = Some(Left(sample.id)), library = libId.map(Left(_)), keyValues = statsPaths)
val results = summary.getStatKeys(runId, "bammetrics".right, Some("bamstats".right), sample = Some(sample.id.left), library = libId.map(_.left), keyValues = statsPaths)
}#
#for (field <- fields)
<td>${results(field)}</td>
......
......@@ -4,6 +4,8 @@
#import(scala.concurrent.duration.Duration)
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
#import(java.io.File)
#import(scalaz._)
#import(Scalaz._)
<%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %>
......@@ -73,7 +75,7 @@
#if (!sampleLevel) <td><a href="${rootPath}Samples/${sample.name}/Libraries/${libName}/index.html">${libName}</a></td> #end
#{
val statsPaths = fields.map(x => x -> List("metrics", x)).toMap
val results = summary.getStatKeys(runId, Right("bammetrics"), Some(Right("wgs")), sample = Some(Left(sample.id)), library = libId.map(Left(_)), keyValues = statsPaths)
val results = summary.getStatKeys(runId, "bammetrics".right, Some("wgs".right), sample = Some(sample.id.left), library = libId.map(_.left), keyValues = statsPaths)
}#
#for (field <- fields)
<td>${results(field)}</td>
......
......@@ -2,7 +2,8 @@
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(scala.concurrent.Await)
#import(scala.concurrent.duration.Duration)
#import(scalaz._)
#import(Scalaz._)
<%@ var summary: SummaryDb %>
<%@ var rootPath: String %>
<%@ var pipeline: String %>
......@@ -10,7 +11,7 @@
#{
val settings = summary.getSettingKeys(runId, Right(pipeline),
val settings = summary.getSettingKeys(runId, pipeline.right,
keyValues = Map(
"contigs" -> List("reference", "contigs"),
"species" -> List("reference", "species"),
......@@ -18,7 +19,7 @@
))
val contigs = settings.getOrElse("contigs", Some(Map())).getOrElse(Map()).asInstanceOf[Map[String, Map[String, Any]]]
val referenceFile = Await.result(summary.getFile(runId, Right(pipeline), None, None, None, key = "referenceFasta"), Duration.Inf)
val referenceFile = Await.result(summary.getFile(runId, pipeline.right, None, None, None, key = "referenceFasta"), Duration.Inf)
}#
<table class="table">
......
......@@ -5,6 +5,8 @@
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport)
#import(java.io.File)
#import(scalaz._)
#import(Scalaz._)
<%@ var summary: SummaryDb %>
<%@ var runId: Int %>
<%@ var sampleId: Option[Int] = None %>
......@@ -18,7 +20,7 @@
#{
val samples = Await.result(summary.getSamples(runId = Some(runId), sampleId = sampleId), Duration.Inf)
val libraries = Await.result(summary.getLibraries(runId = Some(runId), sampleId = sampleId), Duration.Inf)
val settings = summary.getSettingsForLibraries(runId, Right("flexiprep"), keyValues = Map(
val settings = summary.getSettingsForLibraries(runId, "flexiprep".right, 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 trimCount = settings.count(_._2.getOrElse("skip_trim", None) == Some(true))
......@@ -26,7 +28,7 @@
val librariesCount = libraries.size
val paired: Boolean = if (sampleId.isDefined && libId.isDefined)
summary.getSettingKeys(runId, Right("flexiprep"), None, sampleId.map(Left(_)), libId.map(Left(_)), keyValues = Map("paired" -> List("paired"))).getOrElse("paired", None) == Some(true)
summary.getSettingKeys(runId, "flexiprep".right, None, sampleId.map(_.left), libId.map(_.left), keyValues = Map("paired" -> List("paired"))).getOrElse("paired", None) == Some(true)
else settings.count(_._2.getOrElse("paired", None) == Some(true)) >= 1
}#
#if (showIntro)
......@@ -137,8 +139,8 @@
#if (read == "R2") </tr><tr> #end
#{
val statsPaths = Map("num_total" -> List("bases", "num_total"))
val seqstatStats = summary.getStatKeys(runId, Right("flexiprep"), Some(Right("seqstat_" + read)), sample = Some(Left(sample.id)), library = Some(Left(lib.id)), keyValues = statsPaths)
val seqstatQcStats = summary.getStatKeys(runId, Right("flexiprep"), Some(Right("seqstat_" + read + "_qc")), sample = Some(Left(sample.id)), library = Some(Left(lib.id)), keyValues = statsPaths)
val seqstatStats = summary.getStatKeys(runId, "flexiprep".right, Some(("seqstat_" + read).right), sample = Some(sample.id.left), library = Some(lib.id.left), keyValues = statsPaths)
val seqstatQcStats = summary.getStatKeys(runId, "flexiprep".right, Some(("seqstat_" + read + "_qc").right), sample = Some(sample.id.left), library = Some(lib.id.left), keyValues = statsPaths)
val beforeTotal = seqstatStats("num_total").getOrElse(0).toString.toLong
val afterTotal = seqstatQcStats("num_total").getOrElse(0).toString.toLong
......
......@@ -5,6 +5,8 @@
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(org.apache.commons.io.FileUtils)
#import(java.io.File)
#import(scalaz._)
#import(Scalaz._)
<%@ var summary: SummaryDb %>
<%@ var runId: Int %>
<%@ var sampleId: Option[Int] %>
......@@ -12,7 +14,7 @@
<%@ var plot: String %>
<%@ var outputDir: File %>
#{
val settings = summary.getSettingKeys(runId, Right("flexiprep"), None, sampleId.map(Left(_)), libId.map(Left(_)), keyValues = Map(
val settings = summary.getSettingKeys(runId, "flexiprep".right, None, sampleId.map(_.left), libId.map(_.left), keyValues = Map(
"skip_trim" -> List("skip_trim"), "skip_clip" -> List("skip_clip"), "paired" -> List("paired")))
val paired: Boolean = settings("paired") == Some(true)
......@@ -20,7 +22,7 @@
val skipTrim: Boolean = settings("skip_trim") == Some(true)
def getPlot(read:String) = {
val file = Await.result(summary.getFile(runId, Right("flexiprep"), Some(Right(read)), sampleId.map(Left(_)), libId.map(Left(_)), plot), Duration.Inf)
val file = Await.result(summary.getFile(runId, "flexiprep".right, Some(read.right), sampleId.map(_.left), libId.map(_.left), plot), Duration.Inf)
file.collect {
case path => {
val file = new File(path.path.toString)
......@@ -32,7 +34,7 @@
}
def plotAvailable(read:String) = {
val file = Await.result(summary.getFile(runId, Right("flexiprep"), Some(Right(read)), sampleId.map(Left(_)), libId.map(Left(_)), plot), Duration.Inf)
val file = Await.result(summary.getFile(runId, "flexiprep".right, Some(read.right), sampleId.map(_.left), libId.map(_.left), plot), Duration.Inf)
file.map(x => new File(x.path).exists()).getOrElse(false)
}
......
......@@ -4,6 +4,8 @@
#import(scala.concurrent.duration.Duration)
#import(java.io.File)
#import(nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport)
#import(scalaz._)
#import(Scalaz._)
<%@ var summary: SummaryDb %>
<%@ var runId: Int %>
<%@ var sampleId: Option[Int] = None %>
......@@ -17,7 +19,7 @@
#{
val samples = Await.result(summary.getSamples(runId = Some(runId), sampleId = sampleId), Duration.Inf)
val libraries = Await.result(summary.getLibraries(runId = Some(runId), sampleId = sampleId), Duration.Inf)
val settings = summary.getSettingsForLibraries(runId, Right("flexiprep"), keyValues = Map(
val settings = summary.getSettingsForLibraries(runId, "flexiprep".right, 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 trimCount = settings.count(_._2.getOrElse("skip_trim", None) == Some(true))
......@@ -25,7 +27,7 @@
val librariesCount = libraries.size
val paired: Boolean = if (sampleId.isDefined && libId.isDefined)
summary.getSettingKeys(runId, Right("flexiprep"), None, sampleId.map(Left(_)), libId.map(Left(_)), keyValues = Map("paired" -> List("paired"))).getOrElse("paired", None) == Some(true)
summary.getSettingKeys(runId, "flexiprep".right, None, sampleId.map(_.left), libId.map(_.left), keyValues = Map("paired" -> List("paired"))).getOrElse("paired", None) == Some(true)
else settings.count(_._2.getOrElse("paired", None) == Some(true)) >= 1
}#
......@@ -142,15 +144,15 @@
#if (read == "R2") </tr><tr> #end
#{
val seqstatPaths = Map("num_total" -> List("reads", "num_total"))
val seqstatStats = summary.getStatKeys(runId, Right("flexiprep"), Some(Right("seqstat_" + read)), sample = Some(Left(sample.id)), library = Some(Left(lib.id)), keyValues = seqstatPaths)
val seqstatQcStats = summary.getStatKeys(runId, Right("flexiprep"), Some(Right("seqstat_" + read + "_qc")), sample = Some(Left(sample.id)), library = Some(Left(lib.id)), keyValues = seqstatPaths)
val seqstatStats = summary.getStatKeys(runId, "flexiprep".right, Some(("seqstat_" + read).right), sample = Some(sample.id.left), library = Some(lib.id.left), keyValues = seqstatPaths)
val seqstatQcStats = summary.getStatKeys(runId, "flexiprep".right, Some(("seqstat_" + read + "_qc").right), sample = Some(sample.id.left), library = Some(lib.id.left), 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, Right("flexiprep"), Some(Right("clipping_" + read)), sample = Some(Left(sample.id)), library = Some(Left(lib.id)), keyValues = clippingPaths)
val clippingStats = summary.getStatKeys(runId, "flexiprep".right, Some(("clipping_" + read).right), sample = Some(sample.id.left), library = Some(lib.id.left), keyValues = clippingPaths)
val trimmingPaths = Map("num_reads_discarded" -> List("num_reads_discarded_" + read))
val trimmingStats = summary.getStatKeys(runId, Right("flexiprep"), Some(Right("trimming")), sample = Some(Left(sample.id)), library = Some(Left(lib.id)), keyValues = trimmingPaths)
val trimmingStats = summary.getStatKeys(runId, "flexiprep".right, Some("trimming".right), sample = Some(sample.id.left), library = Some(lib.id.left), keyValues = trimmingPaths)
val beforeTotal = seqstatStats("num_total").getOrElse(0).toString.toLong
val afterTotal = seqstatQcStats("num_total").getOrElse(0).toString.toLong
......
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