Commit 92e0976b authored by Peter van 't Hof's avatar Peter van 't Hof

Merge remote-tracking branch 'remotes/origin/fix-BIOPET-591' into fix-BIOPET-587

parents df4cf4cd c8bee878
......@@ -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>
......
......@@ -25,6 +25,8 @@ import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scalaz._
import Scalaz._
class BammetricsReport(val parent: Configurable) extends ReportBuilderExtension {
def builder = BammetricsReport
......@@ -64,14 +66,14 @@ object BammetricsReport extends ReportBuilder {
//val pipelineId: Int = summary.getPipelineId(runId, metricsTag).map(_.get)
val wgsExecuted = summary.getStatsSize(runId, Right(metricsTag), Some(Right("wgs")), sample = sampleId.map(Left(_)), library = libId.map(Left(_))) >= 1
val rnaExecuted = summary.getStatsSize(runId, Right(metricsTag), Some(Right("rna")), sample = sampleId.map(Left(_)), library = libId.map(Left(_))) >= 1
val wgsExecuted = summary.getStatsSize(runId, Some(metricsTag.right), Some(Some("wgs".right)), sample = sampleId.map(x => Some(x.left)), library = libId.map(x => Some(x.left))) >= 1
val rnaExecuted = summary.getStatsSize(runId, Some(metricsTag.right), Some(Some("rna".right)), sample = sampleId.map(x => Some(x.left)), library = libId.map(x => Some(x.left))) >= 1
val insertsizeMetrics = summary.getStatKeys(runId, Right(metricsTag), Some(Right("CollectInsertSizeMetrics")),
sample = sampleId.map(Left(_)), library = libId.map(Left(_)), Map("metrics" -> List("metrics")))
val insertsizeMetrics = summary.getStatKeys(runId, metricsTag.right, Some("CollectInsertSizeMetrics".right),
sample = sampleId.map(_.left), library = libId.map(_.left), Map("metrics" -> List("metrics")))
.exists(_._2.isDefined)
val targetSettings = summary.getSettingKeys(runId, Right(metricsTag), None, sample = sampleId.map(Left(_)), library = libId.map(Left(_)),
val targetSettings = summary.getSettingKeys(runId, metricsTag.right, None, sample = sampleId.map(_.left), library = libId.map(_.left),
Map("amplicon_name" -> List("amplicon_name"), "roi_name" -> List("roi_name")))
val targets = (
targetSettings("amplicon_name"),
......@@ -132,10 +134,10 @@ object BammetricsReport extends ReportBuilder {
)
val results: Map[(Int, Option[Int]), Map[String, Option[Any]]] = if (libraryLevel) {
summary.getStatsForLibraries(runId, Right("bammetrics"), Some(Right("bamstats")),
summary.getStatsForLibraries(runId, "bammetrics".right, Some("bamstats".right),
sampleId = sampleId, keyValues = statsPaths).map(x => (x._1._1, Some(x._1._2)) -> x._2)
} else summary.getStatsForSamples(runId, Right("bammetrics"), Some(Right("bamstats")),
sample = sampleId.map(Left(_)), keyValues = statsPaths).map(x => (x._1, None) -> x._2)
} else summary.getStatsForSamples(runId, "bammetrics".right, Some("bamstats".right),
sample = sampleId.map(_.left), keyValues = statsPaths).map(x => (x._1, None) -> x._2)
for (((s, l), result) <- results) {
val sampleName: String = summary.getSampleName(s).map(_.get)
......@@ -175,8 +177,8 @@ object BammetricsReport extends ReportBuilder {
statsPaths: Map[String, List[String]],
xKey: String,
yKey: String,
pipeline: Either[Int, String],
module: Option[Either[Int, String]],
pipeline: \/[Int, String],
module: Option[\/[Int, String]],
xlabel: Option[String] = None,
ylabel: Option[String] = None,
title: Option[String] = None,
......@@ -187,7 +189,7 @@ object BammetricsReport extends ReportBuilder {
val results: Map[(Int, Option[Int]), Map[String, Option[Array[Any]]]] = if (libraryLevel) {
summary.getStatsForLibraries(runId, pipeline, module, sampleId = sampleId, keyValues = statsPaths)
.map(x => (x._1._1, Some(x._1._2)) -> x._2.map(x => x._1 -> x._2.map(ConfigUtils.any2list(_).toArray)))
} else summary.getStatsForSamples(runId, pipeline, module, sample = sampleId.map(Left(_)), keyValues = statsPaths)
} else summary.getStatsForSamples(runId, pipeline, module, sample = sampleId.map(_.left), keyValues = statsPaths)
.map(x => (x._1, None) -> x._2.map(x => x._1 -> x._2.map(ConfigUtils.any2list(_).toArray)))
val tables: Array[Map[String, Array[Any]]] = results.map {
......@@ -231,7 +233,7 @@ object BammetricsReport extends ReportBuilder {
)
writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths,
"insert_size", "count", Right("bammetrics"), Some(Right("CollectInsertSizeMetrics")),
"insert_size", "count", "bammetrics".right, Some("CollectInsertSizeMetrics".right),
"Insert size", "Reads", "Insert size")
}
......@@ -247,7 +249,7 @@ object BammetricsReport extends ReportBuilder {
)
writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths,
"mapping_quality", "count", Right("bammetrics"), Some(Right("bamstats")),
"mapping_quality", "count", "bammetrics".right, Some("bamstats".right),
"Mapping quality", "Reads", "Mapping quality")
}
......@@ -263,7 +265,7 @@ object BammetricsReport extends ReportBuilder {
)
writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths,
"clipping", "count", Right("bammetrics"), Some(Right("bamstats")),
"clipping", "count", "bammetrics".right, Some("bamstats".right),
"Clipping", "Reads", "Clipping")
}
......@@ -288,7 +290,7 @@ object BammetricsReport extends ReportBuilder {
)
writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths,
"coverage", "count", Right("bammetrics"), Some(Right("wgs")),
"coverage", "count", "bammetrics".right, Some("wgs".right),
"Coverage", "Bases", "Whole genome coverage")
}
......@@ -313,7 +315,7 @@ object BammetricsReport extends ReportBuilder {
)
writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths,
"coverage", "count", Right("bammetrics"), Some(Right("rna")),
"coverage", "count", "bammetrics".right, Some("rna".right),
"Relative position", "Coverage", "Rna coverage")
}
......
......@@ -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">
......
......@@ -14,7 +14,7 @@
*/
package nl.lumc.sasc.biopet.core.extensions
import java.io.{File, FileOutputStream}
import java.io.{ File, FileOutputStream }
import nl.lumc.sasc.biopet.core.BiopetCommandLineFunction
import nl.lumc.sasc.biopet.utils.Logging
......
......@@ -32,6 +32,8 @@ import org.testng.annotations.{ AfterClass, Test }
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scala.util.matching.Regex
import scalaz._
import Scalaz._
/**
* Created by pjvanthof on 15/01/16.
......@@ -98,8 +100,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers {
val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile)
basicSummaryTest(summary, qscript.summaryRunId, dir)
summary.getStatKeys(qscript.summaryRunId, Right("test"), Some(Right("tool_1")), keyValues = Map("key" -> List("key"))) shouldBe Map("key" -> Some("value"))
Await.result(summary.getFile(qscript.summaryRunId, Right("test"), Some(Right("tool_1")), None, None, key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum")
summary.getStatKeys(qscript.summaryRunId, "test".right, Some("tool_1".right), keyValues = Map("key" -> List("key"))) shouldBe Map("key" -> Some("value"))
Await.result(summary.getFile(qscript.summaryRunId, "test".right, Some("tool_1".right), None, None, key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum")
}
@Test
......@@ -119,8 +121,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers {
val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile)
basicSummaryTest(summary, qscript.summaryRunId, dir)
summary.getStatKeys(qscript.summaryRunId, Right("test"), Some(Right("tool_1")), keyValues = Map("key" -> List("key"))) shouldBe Map("key" -> Some("value"))
Await.result(summary.getFile(qscript.summaryRunId, Right("test"), Some(Right("tool_1")), None, None, key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum")
summary.getStatKeys(qscript.summaryRunId, "test".right, Some("tool_1".right), keyValues = Map("key" -> List("key"))) shouldBe Map("key" -> Some("value"))
Await.result(summary.getFile(qscript.summaryRunId, "test".right, Some("tool_1".right), None, None, key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum")
}
@Test
......@@ -140,8 +142,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers {
val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile)
basicSummaryTest(summary, qscript.summaryRunId, dir)
summary.getStatKeys(qscript.summaryRunId, Right("test"), Some(Right("tool_1")), keyValues = Map("key" -> List("key"))) shouldBe Map("key" -> Some("value"))
Await.result(summary.getFile(qscript.summaryRunId, Right("test"), Some(Right("tool_1")), None, None, key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum")
summary.getStatKeys(qscript.summaryRunId, "test".right, Some("tool_1".right), keyValues = Map("key" -> List("key"))) shouldBe Map("key" -> Some("value"))
Await.result(summary.getFile(qscript.summaryRunId, "test".right, Some("tool_1".right), None, None, key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum")
}
@Test
......@@ -161,8 +163,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers {
val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile)
basicSummaryTest(summary, qscript.summaryRunId, dir)
summary.getStatKeys(qscript.summaryRunId, Right("test"), Some(Right("tool_1")), Some(Right("sampleName")), Some(Right("libName")), keyValues = Map("key" -> List("key"))) shouldBe Map("key" -> Some("value"))
Await.result(summary.getFile(qscript.summaryRunId, Right("test"), Some(Right("tool_1")), Some(Right("sampleName")), Some(Right("libName")), key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum")
summary.getStatKeys(qscript.summaryRunId, "test".right, Some("tool_1".right), Some("sampleName".right), Some("libName".right), keyValues = Map("key" -> List("key"))) shouldBe Map("key" -> Some("value"))
Await.result(summary.getFile(qscript.summaryRunId, "test".right, Some("tool_1".right), Some("sampleName".right), Some("libName".right), key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum")
}
@Test
......@@ -202,8 +204,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers {
val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile)
basicSummaryTest(summary, qscript.summaryRunId, dir)
summary.getStatKeys(qscript.summaryRunId, Right("test"), Some(Right("tool_1")), keyValues = Map("key" -> List("key"))) shouldBe Map("key" -> Some("value"))
Await.result(summary.getFile(qscript.summaryRunId, Right("test"), Some(Right("tool_1")), None, None, key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum")
summary.getStatKeys(qscript.summaryRunId, "test".right, Some("tool_1".right), keyValues = Map("key" -> List("key"))) shouldBe Map("key" -> Some("value"))
Await.result(summary.getFile(qscript.summaryRunId, "test".right, Some("tool_1".right), None, None, key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum")
}
@AfterClass
......
package nl.lumc.sasc.biopet.utils.implicits
/**
* Created by pjvanthof on 20/02/2017.
*/
object Either {
implicit def optionEitherLeft[T](x: Option[Either[T, _]]): Option[Option[T]] = {
x match {
case Some(i: Either[T, _]) if i.isLeft => Some(i.left.toOption)
case _ => None
}
}
implicit def optionEitherRight[T](x: Option[Either[_, T]]): Option[Option[T]] = {
x match {
case Some(i: Either[_, T]) if i.isRight => Some(i.right.toOption)
case _ => None
}
}
implicit def eitherLeft[T](x: Either[T, _]): Option[T] = {
x match {
case Left(x) => Some(x)
case _ => None
}
}
implicit def eitherRight[T](x: Either[_, T]): Option[T] = {
x match {
case Right(x) => Some(x)
case _ => None
}
}
implicit def left[T](x: T): Left[T, _] = Left(x)
implicit def right[T](x: T): Right[_, T] = Right(x)
implicit def left[T](x: Option[T]): Option[Left[T, _]] = x.map(Left(_))
implicit def right[T](x: Option[T]): Option[Right[_, T]] = x.map(Right(_))
}
......@@ -10,6 +10,9 @@ import org.testng.annotations.Test
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scalaz._
import Scalaz._
/**
* Testing voor [[SummaryDb]]
* Created by pjvanthof on 14/02/2017.
......@@ -133,9 +136,9 @@ class SummaryDbTest extends TestNGSuite with Matchers {
db.createTables()
Await.result(db.createOrUpdateSetting(0, 0, None, None, None, """{"content": "test" }"""), Duration.Inf)
Await.result(db.getSetting(0, Left(0), None, None, None), Duration.Inf) shouldBe Some(Map("content" -> "test"))
Await.result(db.getSetting(0, 0.left, None, None, None), Duration.Inf) shouldBe Some(Map("content" -> "test"))
Await.result(db.createOrUpdateSetting(0, 0, None, None, None, """{"content": "test2" }"""), Duration.Inf)
Await.result(db.getSetting(0, Left(0), None, None, None), Duration.Inf) shouldBe Some(Map("content" -> "test2"))
Await.result(db.getSetting(0, 0.left, None, None, None), Duration.Inf) shouldBe Some(Map("content" -> "test2"))
db.close()
}
......@@ -155,9 +158,9 @@ class SummaryDbTest extends TestNGSuite with Matchers {
|}
| }""".stripMargin), Duration.Inf)
db.getSettingKeys(0, Left(0), Some(Left(0)), Some(Left(0)), Some(Left(0)), keyValues = Map()) shouldBe Map()
db.getSettingKeys(0, Left(0), Some(Left(0)), Some(Left(0)), Some(Left(0)), keyValues = Map("content" -> List("content"))) shouldBe Map("content" -> Some("test"))
db.getSettingKeys(0, Left(0), Some(Left(0)), Some(Left(0)), Some(Left(0)), keyValues = Map("content" -> List("content2", "key"))) shouldBe Map("content" -> Some("value"))
db.getSettingKeys(0, 0.left, Some(0.left), Some(0.left), Some(0.left), keyValues = Map()) shouldBe Map()
db.getSettingKeys(0, 0.left, Some(0.left), Some(0.left), Some(0.left), keyValues = Map("content" -> List("content"))) shouldBe Map("content" -> Some("test"))
db.getSettingKeys(0, 0.left, Some(0.left), Some(0.left), Some(0.left), keyValues = Map("content" -> List("content2", "key"))) shouldBe Map("content" -> Some("value"))
db.close()
}
......@@ -180,8 +183,8 @@ class SummaryDbTest extends TestNGSuite with Matchers {
|}
| }""".stripMargin), Duration.Inf)
db.getSettingsForSamples(0, Left(0), Some(Left(0)), keyValues = Map()) shouldBe Map(0 -> Map())
db.getSettingsForSamples(0, Left(0), Some(Left(0)), keyValues = Map("content" -> List("content"))) shouldBe Map(0 -> Map("content" -> Some("test")))
db.getSettingsForSamples(0, 0.left, Some(0.left), keyValues = Map()) shouldBe Map(0 -> Map())
db.getSettingsForSamples(0, 0.left, Some(0.left), keyValues = Map("content" -> List("content"))) shouldBe Map(0 -> Map("content" -> Some("test")))
db.close()
}
......@@ -205,8 +208,8 @@ class SummaryDbTest extends TestNGSuite with Matchers {
|}
| }""".stripMargin), Duration.Inf)
db.getSettingsForLibraries(0, Left(0), Some(Left(0)), keyValues = Map()) shouldBe Map((0, 0) -> Map())
db.getSettingsForLibraries(0, Left(0), Some(Left(0)), keyValues = Map("content" -> List("content"))) shouldBe Map((0, 0) -> Map("content" -> Some("test")))
db.getSettingsForLibraries(0, 0.left, Some(0.left), keyValues = Map()) shouldBe Map((0, 0) -> Map())
db.getSettingsForLibraries(0, 0.left, Some(0.left), keyValues = Map("content" -> List("content"))) shouldBe Map((0, 0) -> Map("content" -> Some("test")))
db.close()
}
......@@ -227,15 +230,15 @@ class SummaryDbTest extends TestNGSuite with Matchers {
Await.result(db.getStatsSize(), Duration.Inf) shouldBe 0
Await.result(db.createOrUpdateStat(runId, pipelineId, None, None, None, """{"content": "test" }"""), Duration.Inf)
Await.result(db.getStat(runId, Left(pipelineId), None, None, None), Duration.Inf) shouldBe Some(Map("content" -> "test"))
Await.result(db.getStat(runId, pipelineId.left, None, None, None), Duration.Inf) shouldBe Some(Map("content" -> "test"))
Await.result(db.getStatsSize(), Duration.Inf) shouldBe 1
Await.result(db.createOrUpdateStat(runId, pipelineId, None, None, None, """{"content": "test2" }"""), Duration.Inf)
Await.result(db.getStat(runId, Left(pipelineId), None, None, None), Duration.Inf) shouldBe Some(Map("content" -> "test2"))
Await.result(db.getStat(runId, pipelineId.left, None, None, None), Duration.Inf) shouldBe Some(Map("content" -> "test2"))
Await.result(db.getStatsSize(), Duration.Inf) shouldBe 1
// Test join queries
Await.result(db.createOrUpdateStat(runId, pipelineId, Some(moduleId), Some(sampleId), Some(libraryId), """{"content": "test3" }"""), Duration.Inf)
Await.result(db.getStat(runId, Right("test_pipeline"), Some(Right("test_module")), Some(Right("test_sample")), Some(Right("test_library"))), Duration.Inf) shouldBe Some(Map("content" -> "test3"))
Await.result(db.getStat(runId, "test_pipeline".right, Some("test_module".right), Some("test_sample".right), Some("test_library".right)), Duration.Inf) shouldBe Some(Map("content" -> "test3"))
Await.result(db.getStatsSize(), Duration.Inf) shouldBe 2
db.close()
......@@ -257,9 +260,9 @@ class SummaryDbTest extends TestNGSuite with Matchers {
|}
| }""".stripMargin), Duration.Inf)
db.getStatKeys(0, Left(0), Some(Left(0)), Some(Left(0)), Some(Left(0)), keyValues = Map()) shouldBe Map()
db.getStatKeys(0, Left(0), Some(Left(0)), Some(Left(0)), Some(Left(0)), keyValues = Map("content" -> List("content"))) shouldBe Map("content" -> Some("test"))
db.getStatKeys(0, Left(0), Some(Left(0)), Some(Left(0)), Some(Left(0)), keyValues = Map("content" -> List("content2", "key"))) shouldBe Map("content" -> Some("value"))
db.getStatKeys(0, 0.left, Some(0.left), Some(0.left), Some(0.left), keyValues = Map()) shouldBe Map()
db.getStatKeys(0, 0.left, Some(0.left), Some(0.left), Some(0.left), keyValues = Map("content" -> List("content"))) shouldBe Map("content" -> Some("test"))
db.getStatKeys(0, 0.left, Some(0.left), Some(0.left), Some(0.left), keyValues = Map("content" -> List("content2", "key"))) shouldBe Map("content" -> Some("value"))
db.close()
}
......@@ -282,8 +285,8 @@ class SummaryDbTest extends TestNGSuite with Matchers {
|}
| }""".stripMargin), Duration.Inf)
db.getStatsForSamples(0, Left(0), Some(Left(0)), keyValues = Map()) shouldBe Map(0 -> Map())
db.getStatsForSamples(0, Left(0), Some(Left(0)), keyValues = Map("content" -> List("content"))) shouldBe Map(0 -> Map("content" -> Some("test")))
db.getStatsForSamples(0, 0.left, Some(0.left), keyValues = Map()) shouldBe Map(0 -> Map())
db.getStatsForSamples(0, 0.left, Some(0.left), keyValues = Map("content" -> List("content"))) shouldBe Map(0 -> Map("content" -> Some("test")))
db.close()
}
......@@ -307,8 +310,8 @@ class SummaryDbTest extends TestNGSuite with Matchers {
|}
| }""".stripMargin), Duration.Inf)
db.getStatsForLibraries(0, Left(0), Some(Left(0)), keyValues = Map()) shouldBe Map((0, 0) -> Map())
db.getStatsForLibraries(0, Left(0), Some(Left(0)), keyValues = Map("content" -> List("content"))) shouldBe Map((0, 0) -> Map("content" -> Some("test")))
db.getStatsForLibraries(0, 0.left, Some(0.left), keyValues = Map()) shouldBe Map((0, 0) -> Map())
db.getStatsForLibraries(0, 0.left, Some(0.left), keyValues = Map("content" -> List("content"))) shouldBe Map((0, 0) -> Map("content" -> Some("test")))
db.close()
}
......@@ -327,15 +330,15 @@ class SummaryDbTest extends TestNGSuite with Matchers {
val libraryId = Await.result(db.createLibrary("test_library", runId, sampleId), Duration.Inf)
Await.result(db.createOrUpdateFile(runId, pipelineId, None, None, None, "key", "path", "md5", link = false, 1), Duration.Inf)
Await.result(db.getFile(runId, Left(pipelineId), None, None, None, "key"), Duration.Inf) shouldBe Some(Schema.File(0, 0, None, None, None, "key", "path", "md5", link = false, 1))
Await.result(db.getFile(runId, pipelineId.left, None, None, None, "key"), Duration.Inf) shouldBe Some(Schema.File(0, 0, None, None, None, "key", "path", "md5", link = false, 1))
Await.result(db.getFiles(), Duration.Inf) shouldBe Seq(Schema.File(0, 0, None, None, None, "key", "path", "md5", link = false, 1))
Await.result(db.createOrUpdateFile(runId, pipelineId, None, None, None, "key", "path2", "md5", link = false, 1), Duration.Inf)
Await.result(db.getFile(runId, Left(pipelineId), None, None, None, "key"), Duration.Inf) shouldBe Some(Schema.File(0, 0, None, None, None, "key", "path2", "md5", link = false, 1))
Await.result(db.getFile(runId, pipelineId.left, None, None, None, "key"), Duration.Inf) shouldBe Some(Schema.File(0, 0, None, None, None, "key", "path2", "md5", link = false, 1))
Await.result(db.getFiles(), Duration.Inf) shouldBe Seq(Schema.File(0, 0, None, None, None, "key", "path2", "md5", link = false, 1))
// Test join queries
Await.result(db.createOrUpdateFile(runId, pipelineId, Some(moduleId), Some(sampleId), Some(libraryId), "key", "path3", "md5", link = false, 1), Duration.Inf)
Await.result(db.getFile(runId, Right("test_pipeline"), Some(Right("test_module")), Some(Right("test_sample")), Some(Right("test_library")), "key"), Duration.Inf) shouldBe Some(Schema.File(0, 0, Some(moduleId), Some(sampleId), Some(libraryId), "key", "path3", "md5", link = false, 1))
Await.result(db.getFile(runId, "test_pipeline".right, Some("test_module".right), Some("test_sample".right), Some("test_library".right), "key"), Duration.Inf) shouldBe Some(Schema.File(0, 0, Some(moduleId), Some(sampleId), Some(libraryId), "key", "path3", "md5", link = false, 1))
Await.result(db.getFiles(), Duration.Inf) shouldBe Seq(Schema.File(0, 0, None, None, None, "key", "path2", "md5", link = false, 1), Schema.File(0, 0, Some(moduleId), Some(sampleId), Some(libraryId), "key", "path3", "md5", link = false, 1))
db.close()
......
......@@ -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
......
......@@ -23,6 +23,8 @@ import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scalaz._
import Scalaz._
class FlexiprepReport(val parent: Configurable) extends ReportBuilderExtension {
def builder = FlexiprepReport
......@@ -95,15 +97,15 @@ object FlexiprepReport extends ReportBuilder {
tsvWriter.println("Library\tAfter_QC\tClipping\tTrimming\tSynced")
val seqstatPaths = Map("num_total" -> List("reads", "num_total"))
val seqstatStats = summary.getStatsForLibraries(runId, Right("flexiprep"), Right("seqstat_" + read), keyValues = seqstatPaths)
val seqstatQcStats = summary.getStatsForLibraries(runId, Right("flexiprep"), Right("seqstat_" + read + "_qc"), keyValues = seqstatPaths)
val seqstatStats = summary.getStatsForLibraries(runId, "flexiprep".right, Some(("seqstat_" + read).right), keyValues = seqstatPaths)
val seqstatQcStats = summary.getStatsForLibraries(runId, "flexiprep".right, Some(("seqstat_" + read + "_qc").right), 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"))