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

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

parents df4cf4cd c8bee878
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#import(scala.concurrent.duration.Duration) #import(scala.concurrent.duration.Duration)
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport) #import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
#import(java.io.File) #import(java.io.File)
#import(scalaz._)
#import(Scalaz._)
<%@ var summary: SummaryDb %> <%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] = None %> <%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %> <%@ var libId: Option[Int] = None %>
...@@ -87,7 +89,7 @@ ...@@ -87,7 +89,7 @@
"Duplicates" -> List("flagstats", "Duplicates"), "Duplicates" -> List("flagstats", "Duplicates"),
"NotPrimaryAlignment" -> List("flagstats", "NotPrimaryAlignment") "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 total = results("All").getOrElse(0L).asInstanceOf[Long]
val mapped = results("Mapped").getOrElse(0L).asInstanceOf[Long] val mapped = results("Mapped").getOrElse(0L).asInstanceOf[Long]
val duplicates = results("Duplicates").getOrElse(0L).asInstanceOf[Long] val duplicates = results("Duplicates").getOrElse(0L).asInstanceOf[Long]
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#import(scala.concurrent.duration.Duration) #import(scala.concurrent.duration.Duration)
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport) #import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
#import(java.io.File) #import(java.io.File)
#import(scalaz._)
#import(Scalaz._)
<%@ var summary: SummaryDb %> <%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] = None %> <%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %> <%@ var libId: Option[Int] = None %>
...@@ -82,7 +84,7 @@ ...@@ -82,7 +84,7 @@
#if (!sampleLevel) <td><a href="${rootPath}Samples/${sample.name}/Libraries/${libName}/index.html">${libName}</a></td> #end #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 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) #for (field <- fields)
<td>${results(field)}</td> <td>${results(field)}</td>
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#import(scala.concurrent.duration.Duration) #import(scala.concurrent.duration.Duration)
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport) #import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
#import(java.io.File) #import(java.io.File)
#import(scalaz._)
#import(Scalaz._)
<%@ var summary: SummaryDb %> <%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] = None %> <%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %> <%@ var libId: Option[Int] = None %>
...@@ -84,7 +86,7 @@ ...@@ -84,7 +86,7 @@
#if (!sampleLevel) <td><a href="${rootPath}Samples/${sample.name}/Libraries/${libName}/index.html">${libName}</a></td> #end #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 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) #for (field <- fields)
<td>${results(field)}</td> <td>${results(field)}</td>
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#import(scala.concurrent.duration.Duration) #import(scala.concurrent.duration.Duration)
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport) #import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
#import(java.io.File) #import(java.io.File)
#import(scalaz._)
#import(Scalaz._)
<%@ var summary: SummaryDb %> <%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] = None %> <%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %> <%@ var libId: Option[Int] = None %>
...@@ -83,7 +85,7 @@ ...@@ -83,7 +85,7 @@
#if (!sampleLevel) <td><a href="${rootPath}Samples/${sample.name}/Libraries/${libName}/index.html">${libName}</a></td> #end #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 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) #for (field <- fields)
<td>${results(field)}</td> <td>${results(field)}</td>
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#import(scala.concurrent.duration.Duration) #import(scala.concurrent.duration.Duration)
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport) #import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
#import(java.io.File) #import(java.io.File)
#import(scalaz._)
#import(Scalaz._)
<%@ var summary: SummaryDb %> <%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] = None %> <%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %> <%@ var libId: Option[Int] = None %>
...@@ -73,7 +75,7 @@ ...@@ -73,7 +75,7 @@
#if (!sampleLevel) <td><a href="${rootPath}Samples/${sample.name}/Libraries/${libName}/index.html">${libName}</a></td> #end #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 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) #for (field <- fields)
<td>${results(field)}</td> <td>${results(field)}</td>
......
...@@ -25,6 +25,8 @@ import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb ...@@ -25,6 +25,8 @@ import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Await import scala.concurrent.Await
import scala.concurrent.duration.Duration import scala.concurrent.duration.Duration
import scalaz._
import Scalaz._
class BammetricsReport(val parent: Configurable) extends ReportBuilderExtension { class BammetricsReport(val parent: Configurable) extends ReportBuilderExtension {
def builder = BammetricsReport def builder = BammetricsReport
...@@ -64,14 +66,14 @@ object BammetricsReport extends ReportBuilder { ...@@ -64,14 +66,14 @@ object BammetricsReport extends ReportBuilder {
//val pipelineId: Int = summary.getPipelineId(runId, metricsTag).map(_.get) //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 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, Right(metricsTag), Some(Right("rna")), sample = sampleId.map(Left(_)), library = libId.map(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")), val insertsizeMetrics = summary.getStatKeys(runId, metricsTag.right, Some("CollectInsertSizeMetrics".right),
sample = sampleId.map(Left(_)), library = libId.map(Left(_)), Map("metrics" -> List("metrics"))) sample = sampleId.map(_.left), library = libId.map(_.left), Map("metrics" -> List("metrics")))
.exists(_._2.isDefined) .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"))) Map("amplicon_name" -> List("amplicon_name"), "roi_name" -> List("roi_name")))
val targets = ( val targets = (
targetSettings("amplicon_name"), targetSettings("amplicon_name"),
...@@ -132,10 +134,10 @@ object BammetricsReport extends ReportBuilder { ...@@ -132,10 +134,10 @@ object BammetricsReport extends ReportBuilder {
) )
val results: Map[(Int, Option[Int]), Map[String, Option[Any]]] = if (libraryLevel) { 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) sampleId = sampleId, keyValues = statsPaths).map(x => (x._1._1, Some(x._1._2)) -> x._2)
} else summary.getStatsForSamples(runId, Right("bammetrics"), Some(Right("bamstats")), } else summary.getStatsForSamples(runId, "bammetrics".right, Some("bamstats".right),
sample = sampleId.map(Left(_)), keyValues = statsPaths).map(x => (x._1, None) -> x._2) sample = sampleId.map(_.left), keyValues = statsPaths).map(x => (x._1, None) -> x._2)
for (((s, l), result) <- results) { for (((s, l), result) <- results) {
val sampleName: String = summary.getSampleName(s).map(_.get) val sampleName: String = summary.getSampleName(s).map(_.get)
...@@ -175,8 +177,8 @@ object BammetricsReport extends ReportBuilder { ...@@ -175,8 +177,8 @@ object BammetricsReport extends ReportBuilder {
statsPaths: Map[String, List[String]], statsPaths: Map[String, List[String]],
xKey: String, xKey: String,
yKey: String, yKey: String,
pipeline: Either[Int, String], pipeline: \/[Int, String],
module: Option[Either[Int, String]], module: Option[\/[Int, String]],
xlabel: Option[String] = None, xlabel: Option[String] = None,
ylabel: Option[String] = None, ylabel: Option[String] = None,
title: Option[String] = None, title: Option[String] = None,
...@@ -187,7 +189,7 @@ object BammetricsReport extends ReportBuilder { ...@@ -187,7 +189,7 @@ object BammetricsReport extends ReportBuilder {
val results: Map[(Int, Option[Int]), Map[String, Option[Array[Any]]]] = if (libraryLevel) { val results: Map[(Int, Option[Int]), Map[String, Option[Array[Any]]]] = if (libraryLevel) {
summary.getStatsForLibraries(runId, pipeline, module, sampleId = sampleId, keyValues = statsPaths) 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))) .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))) .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 { val tables: Array[Map[String, Array[Any]]] = results.map {
...@@ -231,7 +233,7 @@ object BammetricsReport extends ReportBuilder { ...@@ -231,7 +233,7 @@ object BammetricsReport extends ReportBuilder {
) )
writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths, 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") "Insert size", "Reads", "Insert size")
} }
...@@ -247,7 +249,7 @@ object BammetricsReport extends ReportBuilder { ...@@ -247,7 +249,7 @@ object BammetricsReport extends ReportBuilder {
) )
writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths, 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") "Mapping quality", "Reads", "Mapping quality")
} }
...@@ -263,7 +265,7 @@ object BammetricsReport extends ReportBuilder { ...@@ -263,7 +265,7 @@ object BammetricsReport extends ReportBuilder {
) )
writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths, 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") "Clipping", "Reads", "Clipping")
} }
...@@ -288,7 +290,7 @@ object BammetricsReport extends ReportBuilder { ...@@ -288,7 +290,7 @@ object BammetricsReport extends ReportBuilder {
) )
writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths, 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") "Coverage", "Bases", "Whole genome coverage")
} }
...@@ -313,7 +315,7 @@ object BammetricsReport extends ReportBuilder { ...@@ -313,7 +315,7 @@ object BammetricsReport extends ReportBuilder {
) )
writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths, 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") "Relative position", "Coverage", "Rna coverage")
} }
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
#import(nl.lumc.sasc.biopet.core.report.ReportPage) #import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(scala.concurrent.Await) #import(scala.concurrent.Await)
#import(scala.concurrent.duration.Duration) #import(scala.concurrent.duration.Duration)
#import(scalaz._)
#import(Scalaz._)
<%@ var summary: SummaryDb %> <%@ var summary: SummaryDb %>
<%@ var rootPath: String %> <%@ var rootPath: String %>
<%@ var pipeline: String %> <%@ var pipeline: String %>
...@@ -10,7 +11,7 @@ ...@@ -10,7 +11,7 @@
#{ #{
val settings = summary.getSettingKeys(runId, Right(pipeline), val settings = summary.getSettingKeys(runId, pipeline.right,
keyValues = Map( keyValues = Map(
"contigs" -> List("reference", "contigs"), "contigs" -> List("reference", "contigs"),
"species" -> List("reference", "species"), "species" -> List("reference", "species"),
...@@ -18,7 +19,7 @@ ...@@ -18,7 +19,7 @@
)) ))
val contigs = settings.getOrElse("contigs", Some(Map())).getOrElse(Map()).asInstanceOf[Map[String, Map[String, Any]]] 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"> <table class="table">
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
package nl.lumc.sasc.biopet.core.extensions 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.core.BiopetCommandLineFunction
import nl.lumc.sasc.biopet.utils.Logging import nl.lumc.sasc.biopet.utils.Logging
......
...@@ -32,6 +32,8 @@ import org.testng.annotations.{ AfterClass, Test } ...@@ -32,6 +32,8 @@ import org.testng.annotations.{ AfterClass, Test }
import scala.concurrent.Await import scala.concurrent.Await
import scala.concurrent.duration.Duration import scala.concurrent.duration.Duration
import scala.util.matching.Regex import scala.util.matching.Regex
import scalaz._
import Scalaz._
/** /**
* Created by pjvanthof on 15/01/16. * Created by pjvanthof on 15/01/16.
...@@ -98,8 +100,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers { ...@@ -98,8 +100,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers {
val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile) val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile)
basicSummaryTest(summary, qscript.summaryRunId, dir) 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")) 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, Right("test"), Some(Right("tool_1")), None, None, key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum") 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 @Test
...@@ -119,8 +121,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers { ...@@ -119,8 +121,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers {
val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile) val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile)
basicSummaryTest(summary, qscript.summaryRunId, dir) 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")) 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, Right("test"), Some(Right("tool_1")), None, None, key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum") 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 @Test
...@@ -140,8 +142,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers { ...@@ -140,8 +142,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers {
val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile) val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile)
basicSummaryTest(summary, qscript.summaryRunId, dir) 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")) 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, Right("test"), Some(Right("tool_1")), None, None, key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum") 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 @Test
...@@ -161,8 +163,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers { ...@@ -161,8 +163,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers {
val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile) val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile)
basicSummaryTest(summary, qscript.summaryRunId, dir) 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")) 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, Right("test"), Some(Right("tool_1")), Some(Right("sampleName")), Some(Right("libName")), key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum") 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 @Test
...@@ -202,8 +204,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers { ...@@ -202,8 +204,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers {
val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile) val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile)
basicSummaryTest(summary, qscript.summaryRunId, dir) 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")) 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, Right("test"), Some(Right("tool_1")), None, None, key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum") 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 @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 ...@@ -10,6 +10,9 @@ import org.testng.annotations.Test
import scala.concurrent.Await import scala.concurrent.Await
import scala.concurrent.duration.Duration import scala.concurrent.duration.Duration
import scalaz._
import Scalaz._
/** /**
* Testing voor [[SummaryDb]] * Testing voor [[SummaryDb]]
* Created by pjvanthof on 14/02/2017. * Created by pjvanthof on 14/02/2017.
...@@ -133,9 +136,9 @@ class SummaryDbTest extends TestNGSuite with Matchers { ...@@ -133,9 +136,9 @@ class SummaryDbTest extends TestNGSuite with Matchers {
db.createTables() db.createTables()
Await.result(db.createOrUpdateSetting(0, 0, None, None, None, """{"content": "test" }"""), Duration.Inf) 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.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() db.close()
} }
...@@ -155,9 +158,9 @@ class SummaryDbTest extends TestNGSuite with Matchers { ...@@ -155,9 +158,9 @@ class SummaryDbTest extends TestNGSuite with Matchers {
|} |}
| }""".stripMargin), Duration.Inf) | }""".stripMargin), Duration.Inf)
db.getSettingKeys(0, Left(0), Some(Left(0)), Some(Left(0)), Some(Left(0)), keyValues = Map()) shouldBe Map() db.getSettingKeys(0, 0.left, Some(0.left), Some(0.left), Some(0.left), 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, 0.left, Some(0.left), Some(0.left), Some(0.left), 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("content" -> List("content2", "key"))) shouldBe Map("content" -> Some("value"))
db.close() db.close()
} }
...@@ -180,8 +183,8 @@ class SummaryDbTest extends TestNGSuite with Matchers {