Commit 35926de1 authored by rhpvorderman's avatar rhpvorderman

Remove redundant vars from krakenKrona.ssp and move gearsKronaPlot to its own file

parent 4a192e0a
......@@ -8,18 +8,14 @@
#import(nl.lumc.sasc.biopet.pipelines.gears.GearsKraken)
#import(java.io.File)
#import(java.io.PrintWriter)
<%@ var summary: SummaryDb %>
<%@ var rootPath: String %>
<%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %>
<%@ var args: Map[String, Any] %>
<%@ var outputDir: File %>
<%@ var centrifugeTag: Option[String] = None %>
<%@ var summaryModuleName: String %>
<%@ var summaryPipelineName: String %>
<%@ var runId: Int %>
<%@ var allSamples: Seq[Sample] %>
<%@ var allLibraries: Seq[Library] %>
<%@ val summaries: Map[Int, Map[String, Option[Any]]] %>
<%@ val totalReads: Option[Map[String, Long]] %>
#{
......
package nl.lumc.sasc.biopet.pipelines.gears
import nl.lumc.sasc.biopet.utils.summary.db.Schema.{Library, Sample}
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.{ModuleName, SampleId}
object GearsKronaPlot {
def values(summary: SummaryDb,
runId: Int,
summaryPipelineName: String,
summaryModuleName: String,
allSamples: Seq[Sample],
allLibraries: Seq[Library],
sampleId: Option[Int] = None,
libId: Option[Int] = None,
centrifugeTag: Option[String] = None): Map[String, Any] = {
val summariesVal =
summaries(summary, runId, sampleId, libId, summaryPipelineName, summaryModuleName)
val totalReadsVal = totalReads(summary,
runId,
sampleId,
libId,
summaryPipelineName,
centrifugeTag,
allSamples,
allLibraries)
Map(
"sampleId" -> sampleId,
"summaryPipelineName" -> summaryPipelineName,
"summaryModuleName" -> summaryModuleName,
"centrifugeTag" -> centrifugeTag,
"allSamples" -> allSamples,
"summaries" -> summariesVal,
"totalReads" -> totalReadsVal
)
}
def summaries(summary: SummaryDb,
runId: Int,
sampleId: Option[Int],
libId: Option[Int],
summaryPipelineName: String,
summaryModuleName: String): Map[Int, Map[String, Option[Any]]] = {
if (libId.isDefined)
summary
.getStatsForLibraries(runId,
summaryPipelineName,
summaryModuleName,
sampleId,
Map("all" -> Nil))
.filter(_._1._2 == libId.get)
.map(x => x._1._1 -> x._2)
else
summary.getStatsForSamples(runId,
summaryPipelineName,
summaryModuleName,
sampleId.map(SampleId),
Map("all" -> Nil))
}
def totalReads(
summary: SummaryDb,
runId: Int,
sampleId: Option[Int],
libId: Option[Int],
summaryPipelineName: String,
centrifugeTag: Option[String],
allSamples: Seq[Sample],
allLibraries: Seq[Library]
): Option[Map[String, Long]] = {
centrifugeTag.map { tag =>
if (libId.isDefined) {
val stats = summary
.getStatsForLibraries(runId,
summaryPipelineName,
ModuleName(tag),
sampleId,
Map("total" -> List("metrics", "Read")))
.filter(_._1._2 == libId.get)
.head
val lib = allLibraries.filter(_.id == stats._1._2).head
val sample = allSamples.filter(_.id == stats._1._1).head
Map(s"${sample.name}" -> stats._2("total").map(_.toString.toLong).getOrElse(0L))
} else
summary
.getStatsForSamples(runId,
summaryPipelineName,
ModuleName(tag),
sampleId.map(SummaryDb.SampleId),
Map("total" -> List("metrics", "Read")))
.map(
x =>
allSamples
.find(_.id == x._1)
.head
.name -> x._2("total").map(_.toString.toLong).getOrElse(0L))
}
}
}
......@@ -16,23 +16,12 @@ package nl.lumc.sasc.biopet.pipelines.gears
import java.io.File
import nl.lumc.sasc.biopet.core.report.{
MultisampleReportBuilder,
ReportBuilderExtension,
ReportPage,
ReportSection
}
import nl.lumc.sasc.biopet.pipelines.flexiprep.{
FlexiprepBaseSummary,
FlexiprepReadSummary,
FlexiprepReport
}
import nl.lumc.sasc.biopet.core.report.{MultisampleReportBuilder, ReportBuilderExtension, ReportPage, ReportSection}
import nl.lumc.sasc.biopet.pipelines.flexiprep.{FlexiprepBaseSummary, FlexiprepReadSummary, FlexiprepReport}
import nl.lumc.sasc.biopet.pipelines.gears
import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.utils.summary.db.Schema.{Library, Sample}
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.{ModuleName, NoLibrary, NoModule, SampleId}
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.{NoLibrary, NoModule}
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}
......@@ -445,100 +434,3 @@ object GearsReport extends MultisampleReportBuilder {
}
object GearsKronaPlot {
def values(summary: SummaryDb,
runId: Int,
summaryPipelineName: String,
summaryModuleName: String,
allSamples: Seq[Sample],
allLibraries: Seq[Library],
sampleId: Option[Int] = None,
libId: Option[Int] = None,
centrifugeTag: Option[String] = None): Map[String, Any] = {
val summariesVal =
summaries(summary, runId, sampleId, libId, summaryPipelineName, summaryModuleName)
val totalReadsVal = totalReads(summary,
runId,
sampleId,
libId,
summaryPipelineName,
centrifugeTag,
allSamples,
allLibraries)
Map(
"summary" -> summary,
"runId" -> runId,
"sampleId" -> sampleId,
"libId" -> libId,
"summaryPipelineName" -> summaryPipelineName,
"summaryModuleName" -> summaryModuleName,
"centrifugeTag" -> centrifugeTag,
"allSamples" -> allSamples,
"allLibraries" -> allLibraries,
"summaries" -> summariesVal,
"totalReads" -> totalReadsVal
)
}
def summaries(summary: SummaryDb,
runId: Int,
sampleId: Option[Int],
libId: Option[Int],
summaryPipelineName: String,
summaryModuleName: String): Map[Int, Map[String, Option[Any]]] = {
if (libId.isDefined)
summary
.getStatsForLibraries(runId,
summaryPipelineName,
summaryModuleName,
sampleId,
Map("all" -> Nil))
.filter(_._1._2 == libId.get)
.map(x => x._1._1 -> x._2)
else
summary.getStatsForSamples(runId,
summaryPipelineName,
summaryModuleName,
sampleId.map(SampleId),
Map("all" -> Nil))
}
def totalReads(
summary: SummaryDb,
runId: Int,
sampleId: Option[Int],
libId: Option[Int],
summaryPipelineName: String,
centrifugeTag: Option[String],
allSamples: Seq[Sample],
allLibraries: Seq[Library]
): Option[Map[String, Long]] = {
centrifugeTag.map { tag =>
if (libId.isDefined) {
val stats = summary
.getStatsForLibraries(runId,
summaryPipelineName,
ModuleName(tag),
sampleId,
Map("total" -> List("metrics", "Read")))
.filter(_._1._2 == libId.get)
.head
val lib = allLibraries.filter(_.id == stats._1._2).head
val sample = allSamples.filter(_.id == stats._1._1).head
Map(s"${sample.name}" -> stats._2("total").map(_.toString.toLong).getOrElse(0L))
} else
summary
.getStatsForSamples(runId,
summaryPipelineName,
ModuleName(tag),
sampleId.map(SummaryDb.SampleId),
Map("total" -> List("metrics", "Read")))
.map(
x =>
allSamples
.find(_.id == x._1)
.head
.name -> x._2("total").map(_.toString.toLong).getOrElse(0L))
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment