Commit 346fcbff authored by Peter van 't Hof's avatar Peter van 't Hof

Switch to use of traits

parent 0bc5bbe7
......@@ -21,12 +21,12 @@ import nl.lumc.sasc.biopet.core.report.{ ReportBuilder, ReportBuilderExtension,
import nl.lumc.sasc.biopet.utils.ConfigUtils
import nl.lumc.sasc.biopet.utils.rscript.{ LinePlot, StackedBarPlot }
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._
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
......@@ -66,14 +66,15 @@ object BammetricsReport extends ReportBuilder {
//val pipelineId: Int = summary.getPipelineId(runId, metricsTag).map(_.get)
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 wgsExecuted = summary.getStatsSize(runId, metricsTag, "wgs", sample = sampleId.map(SampleId), library = libId.map(LibraryId)) >= 1
val rnaExecuted = summary.getStatsSize(runId, metricsTag, "rna", sample = sampleId.map(SampleId), library = libId.map(LibraryId)) >= 1
val insertsizeMetrics = summary.getStatKeys(runId, metricsTag.right, Some("CollectInsertSizeMetrics".right),
sample = sampleId.map(_.left), library = libId.map(_.left), Map("metrics" -> List("metrics")))
val insertsizeMetrics = summary.getStatKeys(runId, metricsTag, "CollectInsertSizeMetrics",
sampleId.map(SampleId).getOrElse(NoSample), libId.map(LibraryId).getOrElse(NoLibrary), Map("metrics" -> List("metrics")))
.exists(_._2.isDefined)
val targetSettings = summary.getSettingKeys(runId, metricsTag.right, None, sample = sampleId.map(_.left), library = libId.map(_.left),
val targetSettings = summary.getSettingKeys(runId, metricsTag, NoModule,
sample = sampleId.map(SampleId).getOrElse(NoSample), library = libId.map(LibraryId).getOrElse(NoLibrary),
Map("amplicon_name" -> List("amplicon_name"), "roi_name" -> List("roi_name")))
val targets = (
targetSettings("amplicon_name"),
......@@ -134,10 +135,10 @@ object BammetricsReport extends ReportBuilder {
)
val results: Map[(Int, Option[Int]), Map[String, Option[Any]]] = if (libraryLevel) {
summary.getStatsForLibraries(runId, "bammetrics".right, Some("bamstats".right),
summary.getStatsForLibraries(runId, "bammetrics", "bamstats",
sampleId = sampleId, keyValues = statsPaths).map(x => (x._1._1, Some(x._1._2)) -> x._2)
} else summary.getStatsForSamples(runId, "bammetrics".right, Some("bamstats".right),
sample = sampleId.map(_.left), keyValues = statsPaths).map(x => (x._1, None) -> x._2)
} else summary.getStatsForSamples(runId, "bammetrics", "bamstats",
sample = sampleId.map(SampleId), keyValues = statsPaths).map(x => (x._1, None) -> x._2)
for (((s, l), result) <- results) {
val sampleName: String = summary.getSampleName(s).map(_.get)
......@@ -177,8 +178,8 @@ object BammetricsReport extends ReportBuilder {
statsPaths: Map[String, List[String]],
xKey: String,
yKey: String,
pipeline: \/[Int, String],
module: Option[\/[Int, String]],
pipeline: PipelineQuery,
module: ModuleQuery,
xlabel: Option[String] = None,
ylabel: Option[String] = None,
title: Option[String] = None,
......@@ -189,7 +190,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(SampleId), 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 {
......@@ -199,7 +200,7 @@ object BammetricsReport extends ReportBuilder {
val libraryName = library.flatMap(l => Await.result(summary.getLibraryName(l), Duration.Inf))
Map(
yKey -> map(yKey).getOrElse(Array()),
(sampleName + libraryName.map("-" + _) getOrElse ("")) -> map(xKey).getOrElse(Array())
(sampleName + libraryName.map("-" + _).getOrElse("")) -> map(xKey).getOrElse(Array())
)
}.toArray
......@@ -233,7 +234,7 @@ object BammetricsReport extends ReportBuilder {
)
writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths,
"insert_size", "count", "bammetrics".right, Some("CollectInsertSizeMetrics".right),
"insert_size", "count", "bammetrics", "CollectInsertSizeMetrics",
"Insert size", "Reads", "Insert size")
}
......@@ -249,7 +250,7 @@ object BammetricsReport extends ReportBuilder {
)
writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths,
"mapping_quality", "count", "bammetrics".right, Some("bamstats".right),
"mapping_quality", "count", "bammetrics", "bamstats",
"Mapping quality", "Reads", "Mapping quality")
}
......@@ -265,7 +266,7 @@ object BammetricsReport extends ReportBuilder {
)
writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths,
"clipping", "count", "bammetrics".right, Some("bamstats".right),
"clipping", "count", "bammetrics", "bamstats",
"Clipping", "Reads", "Clipping")
}
......@@ -290,7 +291,7 @@ object BammetricsReport extends ReportBuilder {
)
writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths,
"coverage", "count", "bammetrics".right, Some("wgs".right),
"coverage", "count", "bammetrics", "wgs",
"Coverage", "Bases", "Whole genome coverage")
}
......@@ -315,7 +316,7 @@ object BammetricsReport extends ReportBuilder {
)
writePlotFromSummary(outputDir, prefix, summary, libraryLevel, sampleId, libraryId, statsPaths,
"coverage", "count", "bammetrics".right, Some("rna".right),
"coverage", "count", "bammetrics", "rna",
"Relative position", "Coverage", "Rna coverage")
}
......
......@@ -19,21 +19,20 @@ import java.io.{ File, PrintWriter }
import com.google.common.io.Files
import nl.lumc.sasc.biopet.core._
import nl.lumc.sasc.biopet.utils.config.{ Config, Configurable }
import nl.lumc.sasc.biopet.utils.summary.Summary
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._
import org.broadinstitute.gatk.queue.function.CommandLineFunction
import org.broadinstitute.gatk.queue.{ QScript, QSettings }
import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import WriteSummaryTest._
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.{ NoLibrary, NoSample }
import org.apache.commons.io.FileUtils
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.
......@@ -100,8 +99,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers {
val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile)
basicSummaryTest(summary, qscript.summaryRunId, dir)
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")
summary.getStatKeys(qscript.summaryRunId, "test", "tool_1", keyValues = Map("key" -> List("key"))) shouldBe Map("key" -> Some("value"))
Await.result(summary.getFile(qscript.summaryRunId, "test", "tool_1", key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum")
}
@Test
......@@ -121,8 +120,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers {
val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile)
basicSummaryTest(summary, qscript.summaryRunId, dir)
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")
summary.getStatKeys(qscript.summaryRunId, "test", "tool_1", keyValues = Map("key" -> List("key"))) shouldBe Map("key" -> Some("value"))
Await.result(summary.getFile(qscript.summaryRunId, "test", "tool_1", NoSample, NoLibrary, key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum")
}
@Test
......@@ -142,8 +141,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers {
val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile)
basicSummaryTest(summary, qscript.summaryRunId, dir)
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")
summary.getStatKeys(qscript.summaryRunId, "test", "tool_1", keyValues = Map("key" -> List("key"))) shouldBe Map("key" -> Some("value"))
Await.result(summary.getFile(qscript.summaryRunId, "test", "tool_1", key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum")
}
@Test
......@@ -163,8 +162,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers {
val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile)
basicSummaryTest(summary, qscript.summaryRunId, dir)
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")
summary.getStatKeys(qscript.summaryRunId, "test", "tool_1", "sampleName", "libName", keyValues = Map("key" -> List("key"))) shouldBe Map("key" -> Some("value"))
Await.result(summary.getFile(qscript.summaryRunId, "test", "tool_1", "sampleName", "libName", key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum")
}
@Test
......@@ -204,8 +203,8 @@ class WriteSummaryTest extends TestNGSuite with Matchers {
val summary = SummaryDb.openSqliteSummary(qscript.summaryDbFile)
basicSummaryTest(summary, qscript.summaryRunId, dir)
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")
summary.getStatKeys(qscript.summaryRunId, "test", "tool_1", keyValues = Map("key" -> List("key"))) shouldBe Map("key" -> Some("value"))
Await.result(summary.getFile(qscript.summaryRunId, "test", "tool_1", key = "file_1"), Duration.Inf).map(_.md5) shouldBe Some("checksum")
}
@AfterClass
......
......@@ -9,9 +9,8 @@ import org.testng.annotations.Test
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scalaz._
import Scalaz._
import SummaryDb.Implicts._
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.{ NoLibrary, NoModule, NoSample }
/**
* Testing voor [[SummaryDb]]
......@@ -140,9 +139,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, 0.left, None, None, None), Duration.Inf) shouldBe Some(Map("content" -> "test"))
Await.result(db.getSetting(0, 0, NoModule, NoSample, NoLibrary), 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, 0.left, None, None, None), Duration.Inf) shouldBe Some(Map("content" -> "test2"))
Await.result(db.getSetting(0, 0, NoModule, NoSample, NoLibrary), Duration.Inf) shouldBe Some(Map("content" -> "test2"))
db.close()
}
......@@ -162,9 +161,9 @@ class SummaryDbTest extends TestNGSuite with Matchers {
|}
| }""".stripMargin), Duration.Inf)
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.getSettingKeys(0, 0, 0, 0, 0, keyValues = Map()) shouldBe Map()
db.getSettingKeys(0, 0, 0, 0, 0, keyValues = Map("content" -> List("content"))) shouldBe Map("content" -> Some("test"))
db.getSettingKeys(0, 0, 0, 0, 0, keyValues = Map("content" -> List("content2", "key"))) shouldBe Map("content" -> Some("value"))
db.close()
}
......@@ -187,8 +186,8 @@ class SummaryDbTest extends TestNGSuite with Matchers {
|}
| }""".stripMargin), Duration.Inf)
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.getSettingsForSamples(0, 0, 0, keyValues = Map()) shouldBe Map(0 -> Map())
db.getSettingsForSamples(0, 0, 0, keyValues = Map("content" -> List("content"))) shouldBe Map(0 -> Map("content" -> Some("test")))
db.close()
}
......@@ -212,8 +211,8 @@ class SummaryDbTest extends TestNGSuite with Matchers {
|}
| }""".stripMargin), Duration.Inf)
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.getSettingsForLibraries(0, 0, 0, keyValues = Map()) shouldBe Map((0, 0) -> Map())
db.getSettingsForLibraries(0, 0, 0, keyValues = Map("content" -> List("content"))) shouldBe Map((0, 0) -> Map("content" -> Some("test")))
db.close()
}
......@@ -234,15 +233,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, pipelineId.left, None, None, None), Duration.Inf) shouldBe Some(Map("content" -> "test"))
Await.result(db.getStat(runId, pipelineId, NoModule, NoSample, NoLibrary), 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, pipelineId.left, None, None, None), Duration.Inf) shouldBe Some(Map("content" -> "test2"))
Await.result(db.getStat(runId, pipelineId, NoModule, NoSample, NoLibrary), 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, "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.getStat(runId, "test_pipeline", "test_module", "test_sample", "test_library"), Duration.Inf) shouldBe Some(Map("content" -> "test3"))
Await.result(db.getStatsSize(), Duration.Inf) shouldBe 2
db.close()
......@@ -264,9 +263,9 @@ class SummaryDbTest extends TestNGSuite with Matchers {
|}
| }""".stripMargin), Duration.Inf)
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.getStatKeys(0, 0, 0, 0, 0, keyValues = Map()) shouldBe Map()
db.getStatKeys(0, 0, 0, 0, 0, keyValues = Map("content" -> List("content"))) shouldBe Map("content" -> Some("test"))
db.getStatKeys(0, 0, 0, 0, 0, keyValues = Map("content" -> List("content2", "key"))) shouldBe Map("content" -> Some("value"))
db.close()
}
......@@ -289,8 +288,8 @@ class SummaryDbTest extends TestNGSuite with Matchers {
|}
| }""".stripMargin), Duration.Inf)
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.getStatsForSamples(0, 0, 0, keyValues = Map()) shouldBe Map(0 -> Map())
db.getStatsForSamples(0, 0, 0, keyValues = Map("content" -> List("content"))) shouldBe Map(0 -> Map("content" -> Some("test")))
db.close()
}
......@@ -314,8 +313,8 @@ class SummaryDbTest extends TestNGSuite with Matchers {
|}
| }""".stripMargin), Duration.Inf)
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.getStatsForLibraries(0, 0, 0, keyValues = Map()) shouldBe Map((0, 0) -> Map())
db.getStatsForLibraries(0, 0, 0, keyValues = Map("content" -> List("content"))) shouldBe Map((0, 0) -> Map("content" -> Some("test")))
db.close()
}
......@@ -334,15 +333,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, 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.getFile(runId, pipelineId, NoModule, NoSample, NoLibrary, "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, 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.getFile(runId, pipelineId, NoModule, NoSample, NoLibrary, "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, "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.getFile(runId, "test_pipeline", "test_module", "test_sample", "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.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()
......
......@@ -20,11 +20,10 @@ import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.core.report.{ ReportBuilder, ReportBuilderExtension, ReportPage, ReportSection }
import nl.lumc.sasc.biopet.utils.rscript.StackedBarPlot
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scalaz._
import Scalaz._
class FlexiprepReport(val parent: Configurable) extends ReportBuilderExtension {
def builder = FlexiprepReport
......@@ -97,15 +96,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, "flexiprep".right, Some(("seqstat_" + read).right), keyValues = seqstatPaths)
val seqstatQcStats = summary.getStatsForLibraries(runId, "flexiprep".right, Some(("seqstat_" + read + "_qc").right), keyValues = seqstatPaths)
val seqstatStats = summary.getStatsForLibraries(runId, "flexiprep", "seqstat_" + read, keyValues = seqstatPaths)
val seqstatQcStats = summary.getStatsForLibraries(runId, "flexiprep", "seqstat_" + read + "_qc", 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.getStatsForLibraries(runId, "flexiprep".right, Some(("clipping_" + read).right), keyValues = clippingPaths)
val clippingStats = summary.getStatsForLibraries(runId, "flexiprep", "clipping_" + read, keyValues = clippingPaths)
val trimmingPaths = Map("num_reads_discarded" -> List("num_reads_discarded_" + read))
val trimmingStats = summary.getStatsForLibraries(runId, "flexiprep".right, Some("trimming".right), keyValues = trimmingPaths)
val trimmingStats = summary.getStatsForLibraries(runId, "flexiprep", "trimming", keyValues = trimmingPaths)
val libraries = Await.result(summary.getLibraries(runId = runId, sampleId = sampleId), Duration.Inf)
......@@ -156,8 +155,8 @@ object FlexiprepReport extends ReportBuilder {
tsvWriter.println("Library\tAfter_QC\tDiscarded")
val statsPaths = Map("num_total" -> List("bases", "num_total"))
val seqstatStats = summary.getStatsForLibraries(runId, "flexiprep".right, Some(("seqstat_" + read).right), keyValues = statsPaths)
val seqstatQcStats = summary.getStatsForLibraries(runId, "flexiprep".right, Some(("seqstat_" + read + "_qc").right), keyValues = statsPaths)
val seqstatStats = summary.getStatsForLibraries(runId, "flexiprep", "seqstat_" + read, keyValues = statsPaths)
val seqstatQcStats = summary.getStatsForLibraries(runId, "flexiprep", "seqstat_" + read + "_qc", keyValues = statsPaths)
val libraries = Await.result(summary.getLibraries(runId = runId, sampleId = sampleId), Duration.Inf)
......
......@@ -17,13 +17,12 @@ package nl.lumc.sasc.biopet.pipelines.gears
import nl.lumc.sasc.biopet.core.report.{ MultisampleReportBuilder, ReportBuilderExtension, ReportPage, ReportSection }
import nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport
import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.{ NoLibrary, NoModule, SampleId }
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scalaz._
import Scalaz._
/**
* Report for Gears
*
......@@ -41,10 +40,10 @@ object GearsReport extends MultisampleReportBuilder {
.map(x => ExtFile("/nl/lumc/sasc/biopet/pipelines/gears/report/ext/" + x, x))
def indexPage = {
val krakenExecuted = summary.getStatsSize(runId = runId, pipeline = Some("gearskraken".right), module = Some(Some("krakenreport".right)), library = Some(None), mustHaveSample = true) >= samples.size
val centrifugeExecuted = summary.getStatsSize(runId, Some("gearscentrifuge".right), Some(Some("centrifuge_report".right)), library = Some(None), mustHaveSample = true) >= samples.size
val qiimeClosesOtuTable = summary.getFile(runId, "gears".right, None, None, None, key = "qiime_closed_otu_table")
val qiimeOpenOtuTable = summary.getFile(runId, "gears".right, None, None, None, key = "qiime_open_otu_table")
val krakenExecuted = summary.getStatsSize(runId = runId, pipeline = "gearskraken", module = "krakenreport", library = NoLibrary, mustHaveSample = true) >= samples.size
val centrifugeExecuted = summary.getStatsSize(runId, "gearscentrifuge", "centrifuge_report", library = NoLibrary, mustHaveSample = true) >= samples.size
val qiimeClosesOtuTable = summary.getFile(runId, "gears", key = "qiime_closed_otu_table")
val qiimeOpenOtuTable = summary.getFile(runId, "gears", key = "qiime_open_otu_table")
ReportPage(
(if (centrifugeExecuted) List("Centriguge analysis" -> ReportPage(List("Non-unique" -> ReportPage(List(), List("All mappings" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp",
......@@ -82,10 +81,10 @@ object GearsReport extends MultisampleReportBuilder {
/** Single sample page */
def samplePage(sampleId: Int, args: Map[String, Any]): ReportPage = {
val krakenExecuted = Await.result(summary.getStatsSize(runId, Some("gearskraken".right), Some(Some("krakenreport".right)), sample = Some(Some(sampleId.left)), library = Some(None)), Duration.Inf) == 1
val centrifugeExecuted = Await.result(summary.getStatsSize(runId, Some("gearscentrifuge".right), Some(Some("centrifuge_report".right)), sample = Some(Some(sampleId.left)), library = None), Duration.Inf) == 1
val qiimeClosesOtuTable = Await.result(summary.getFile(runId, "gears".right, None, Some(sampleId.left), None, "qiime_closed_otu_table"), Duration.Inf)
val qiimeOpenOtuTable = Await.result(summary.getFile(runId, "gears".right, None, Some(sampleId.left), None, "qiime_open_otu_table"), Duration.Inf)
val krakenExecuted = Await.result(summary.getStatsSize(runId, "gearskraken", "krakenreport", sample = sampleId, library = NoLibrary), Duration.Inf) == 1
val centrifugeExecuted = Await.result(summary.getStatsSize(runId, "gearscentrifuge", "centrifuge_report", sample = sampleId, library = None), Duration.Inf) == 1
val qiimeClosesOtuTable = Await.result(summary.getFile(runId, "gears", NoModule, sampleId, NoLibrary, "qiime_closed_otu_table"), Duration.Inf)
val qiimeOpenOtuTable = Await.result(summary.getFile(runId, "gears", NoModule, sampleId, NoLibrary, "qiime_open_otu_table"), Duration.Inf)
ReportPage((if (centrifugeExecuted) List("Centriguge analysis" -> ReportPage(List("Non-unique" -> ReportPage(List(), List("All mappings" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp",
Map("summaryStatsTag" -> "centrifuge_report")
......@@ -114,12 +113,12 @@ object GearsReport extends MultisampleReportBuilder {
val sName = Await.result(summary.getSampleName(sampleId), Duration.Inf)
val lName = Await.result(summary.getLibraryName(libId), Duration.Inf)
val flexiprepExecuted = Await.result(summary.getStatsSize(runId, Some("flexiprep".right), sample = Some(Some(sampleId.left)), library = Some(Some(libId.left))), Duration.Inf) >= 1
val flexiprepExecuted = Await.result(summary.getStatsSize(runId, "flexiprep", sample = sampleId, library = libId), Duration.Inf) >= 1
val krakenExecuted = Await.result(summary.getStatsSize(runId, Some("gearskraken".right), Some(Some("krakenreport".right)), sample = Some(Some(sampleId.left)), library = Some(Some(libId.left))), Duration.Inf) == 1
val centrifugeExecuted = Await.result(summary.getStatsSize(runId, Some("gearscentrifuge".right), Some(Some("centrifuge_report".right)), sample = Some(Some(sampleId.left)), library = Some(Some(libId.left))), Duration.Inf) == 1
val qiimeClosesOtuTable = Await.result(summary.getFile(runId, "gears".right, None, Some(sampleId.left), Some(libId.left), "qiime_closed_otu_table"), Duration.Inf)
val qiimeOpenOtuTable = Await.result(summary.getFile(runId, "gears".right, None, Some(sampleId.left), Some(libId.left), "qiime_open_otu_table"), Duration.Inf)
val krakenExecuted = Await.result(summary.getStatsSize(runId, "gearskraken", "krakenreport", sample = sampleId, library = libId), Duration.Inf) == 1
val centrifugeExecuted = Await.result(summary.getStatsSize(runId, "gearscentrifuge", "centrifuge_report", sample = sampleId, library = libId), Duration.Inf) == 1
val qiimeClosesOtuTable = Await.result(summary.getFile(runId, "gears", NoModule, sampleId, libId, "qiime_closed_otu_table"), Duration.Inf)
val qiimeOpenOtuTable = Await.result(summary.getFile(runId, "gears", NoModule, sampleId, libId, "qiime_open_otu_table"), Duration.Inf)
ReportPage(
(if (flexiprepExecuted) List("QC" -> FlexiprepReport.flexiprepPage) else Nil
......
......@@ -16,11 +16,11 @@ package nl.lumc.sasc.biopet.pipelines.gears
import nl.lumc.sasc.biopet.core.report._
import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.{ LibraryId, SampleId }
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scalaz._
import Scalaz._
class GearsSingleReport(val parent: Configurable) extends ReportBuilderExtension {
def builder = GearsSingleReport
......@@ -35,8 +35,8 @@ object GearsSingleReport extends ReportBuilder {
val sampleName = sampleId.flatMap(x => Await.result(summary.getSampleName(x), Duration.Inf))
val libraryName = libId.flatMap(x => Await.result(summary.getLibraryName(x), Duration.Inf))
val krakenExecuted = Await.result(summary.getStatsSize(runId, Some("gearskraken".right), Some(Some("krakenreport".right)), sample = Some(sampleId.map(_.left)), library = Some(libId.map(_.left))), Duration.Inf) == 1
val centrifugeExecuted = Await.result(summary.getStatsSize(runId, Some("gearscentrifuge".right), Some(Some("centrifuge_report".right)), sample = Some(sampleId.map(_.left)), library = Some(libId.map(_.left))), Duration.Inf) == 1
val krakenExecuted = Await.result(summary.getStatsSize(runId, "gearskraken", "krakenreport", sample = sampleId.map(SampleId), library = libId.map(LibraryId)), Duration.Inf) == 1
val centrifugeExecuted = Await.result(summary.getStatsSize(runId, "gearscentrifuge", "centrifuge_report", sample = sampleId.map(SampleId), library = libId.map(LibraryId)), Duration.Inf) == 1
ReportPage(
List(
......
......@@ -18,11 +18,11 @@ import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.core.report._
import nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport
import nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scalaz._
import Scalaz._
class MappingReport(val parent: Configurable) extends ReportBuilderExtension {
def builder = MappingReport
......@@ -40,12 +40,13 @@ object MappingReport extends ReportBuilder {
override def extFiles = super.extFiles ++ List("js/gears.js", "js/krona-2.0.js", "img/krona/loading.gif", "img/krona/hidden.png", "img/krona/favicon.ico")
.map(x => ExtFile("/nl/lumc/sasc/biopet/pipelines/gears/report/ext/" + x, x))
def krakenExecuted: Boolean = Await.result(summary.getStatsSize(runId, Some("gears".right), Some(Some("krakenreport".right)),
sample = Some(sampleId.map(_.left)), library = Some(libId.map(_.left))), Duration.Inf) >= 1
def krakenExecuted: Boolean = Await.result(summary.getStatsSize(runId, "gears", "krakenreport",
sample = sampleId.map(SampleId), library = libId.map(LibraryId)), Duration.Inf) >= 1
/** Root page for single BamMetrcis report */
def indexPage = {
val mappingSettings = summary.getSettingKeys(runId, "mapping".right, None, sample = sampleId.map(_.left), library = libId.map(_.left),
val mappingSettings = summary.getSettingKeys(runId, "mapping", NoModule,
sample = sampleId.map(SampleId).getOrElse(NoSample), library = libId.map(LibraryId).getOrElse(NoLibrary),
keyValues = Map("skip_flexiprep" -> List("skip_flexiprep"), "skip_metrics" -> List("skip_metrics")))
val skipFlexiprep = mappingSettings.get("skip_flexiprep").flatten.getOrElse(false) == true
val bamMetricsPage = if (mappingSettings.get("skip_metrics").flatten.getOrElse(false) == true) {
......
......@@ -18,11 +18,11 @@ import nl.lumc.sasc.biopet.core.report.{ MultisampleReportBuilder, ReportBuilder
import nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport
import nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport
import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.{ NoLibrary, NoModule }
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scalaz._
import Scalaz._
/**
* Created by pjvanthof on 11/01/16.
......@@ -50,20 +50,20 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
/** Root page for the carp report */
def indexPage = {
val krakenExecuted = Await.result(summary.getStatsSize(runId, Some("gearskraken".right), Some(Some("krakenreport".right)),
library = Some(None), mustHaveSample = true), Duration.Inf) >= 1
val centrifugeExecuted = Await.result(summary.getStatsSize(runId, Some("gearscentrifuge".right), Some(Some("centrifuge_report".right)),
library = Some(None), mustHaveSample = true), Duration.Inf) >= 1
val wgsExecuted = Await.result(summary.getStatsSize(runId, Some("bammetrics".right), Some(Some("wgs".right)),
library = Some(None), mustHaveSample = true), Duration.Inf) >= 1
val rnaExecuted = Await.result(summary.getStatsSize(runId, Some("bammetrics".right), Some(Some("rna".right)),
library = Some(None), mustHaveSample = true), Duration.Inf) >= 1
val insertsizeExecuted = Await.result(summary.getStatsSize(runId, Some("bammetrics".right), Some(Some("CollectInsertSizeMetrics".right)),
library = Some(None), mustHaveSample = true), Duration.Inf) >= 1
val mappingExecuted = Await.result(summary.getStatsSize(runId, Some("mapping".right), Some(None), mustHaveLibrary = true), Duration.Inf) >= 1
val mappingSettings = summary.getSettingsForLibraries(runId, "mapping".right, None, keyValues = Map("paired" -> List("paired")))
val krakenExecuted = Await.result(summary.getStatsSize(runId, "gearskraken", "krakenreport",
library = NoLibrary, mustHaveSample = true), Duration.Inf) >= 1
val centrifugeExecuted = Await.result(summary.getStatsSize(runId, "gearscentrifuge", "centrifuge_report",
library = NoLibrary, mustHaveSample = true), Duration.Inf) >= 1
val wgsExecuted = Await.result(summary.getStatsSize(runId, "bammetrics", "wgs",
library = NoLibrary, mustHaveSample = true), Duration.Inf) >= 1
val rnaExecuted = Await.result(summary.getStatsSize(runId, "bammetrics", "rna",
library = NoLibrary, mustHaveSample = true), Duration.Inf) >= 1
val insertsizeExecuted = Await.result(summary.getStatsSize(runId, "bammetrics", "CollectInsertSizeMetrics",
library = NoLibrary, mustHaveSample = true), Duration.Inf) >= 1
val mappingExecuted = Await.result(summary.getStatsSize(runId, "mapping", NoModule, mustHaveLibrary = true), Duration.Inf) >= 1
val mappingSettings = summary.getSettingsForLibraries(runId, "mapping", NoModule, keyValues = Map("paired" -> List("paired")))
val pairedFound = !mappingExecuted || mappingSettings.exists(_._2.exists(_._2 == Option(true)))
val flexiprepExecuted = Await.result(summary.getStatsSize(runId, Some("flexiprep".right), mustHaveLibrary = true), Duration.Inf) >= 1
val flexiprepExecuted = Await.result(summary.getStatsSize(runId, "flexiprep", mustHaveLibrary = true), Duration.Inf) >= 1
ReportPage(
List("Samples" -> generateSamplesPage(pageArgs)) ++
......@@ -115,19 +115,19 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
/** Files page, can be used general or at sample level */
def filesPage(sampleId: Option[Int] = None, libraryId: Option[Int] = None): ReportPage = {
val flexiprepExecuted = Await.result(summary.getStatsSize(runId, Some("flexiprep".right), Some(None), mustHaveLibrary = true), Duration.Inf) >= 1
val flexiprepExecuted = Await.result(summary.getStatsSize(runId, "flexiprep", NoModule, mustHaveLibrary = true), Duration.Inf) >= 1
ReportPage(List(), Nil, Map())
}
/** Single sample page */
def samplePage(sampleId: Int, args: Map[String, Any]): ReportPage = {
val krakenExecuted = Await.result(summary.getStatsSize(runId, Some("gearskraken".right), Some(Some("krakenreport".right)),
library = Some(None), sample = Some(Some(sampleId.left))), Duration.Inf) >= 1
val centrifugeExecuted = Await.result(summary.getStatsSize(runId, Some("gearscentrifuge".right), Some(Some("centrifuge_report".right)),
library = Some(None), sample = Some(Some(sampleId.left)), mustHaveSample = true), Duration.Inf) >= 1
val flexiprepExecuted = Await.result(summary.getStatsSize(runId, Some("flexiprep".right),
sample = Some(Some(sampleId.left)), mustHaveLibrary = true), Duration.Inf) >= 1
val krakenExecuted = Await.result(summary.getStatsSize(runId, "gearskraken", "krakenreport",
library = NoLibrary, sample = sampleId), Duration.Inf) >= 1