Commit ea7282d9 authored by Peter van 't Hof's avatar Peter van 't Hof Committed by GitHub
Browse files

Merge pull request #24 from biopet/fix-BIOPET-546

Fix biopet 546
parents 7812d950 8314da08
...@@ -27,7 +27,7 @@ import org.broadinstitute.gatk.queue.QScript ...@@ -27,7 +27,7 @@ import org.broadinstitute.gatk.queue.QScript
* *
* Created by pjvan_thof on 1/29/15. * Created by pjvan_thof on 1/29/15.
*/ */
class Bam2Wig(val root: Configurable) extends QScript with BiopetQScript { class Bam2Wig(val parent: Configurable) extends QScript with BiopetQScript {
def this() = this(null) def this() = this(null)
@Input(doc = "Input bam file", required = true) @Input(doc = "Input bam file", required = true)
......
...@@ -28,7 +28,7 @@ import scala.collection.JavaConversions._ ...@@ -28,7 +28,7 @@ import scala.collection.JavaConversions._
* *
* Created by pjvan_thof on 1/29/15. * Created by pjvan_thof on 1/29/15.
*/ */
class BamToChromSizes(val root: Configurable) extends InProcessFunction with Configurable { class BamToChromSizes(val parent: Configurable) extends InProcessFunction with Configurable {
@Input @Input
var bamFile: File = _ var bamFile: File = _
......
#import(nl.lumc.sasc.biopet.utils.summary.Summary) #import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
#import(nl.lumc.sasc.biopet.core.report.ReportPage) #import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(scala.concurrent.Await)
#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)
<%@ var summary: Summary %> <%@ var summary: SummaryDb %>
<%@ var sampleId: Option[String] = None %> <%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[String] = None %> <%@ var libId: Option[Int] = None %>
<%@ var sampleLevel: Boolean = false %> <%@ var sampleLevel: Boolean = false %>
<%@ var rootPath: String %> <%@ var rootPath: String %>
<%@ var outputDir: File %> <%@ var outputDir: File %>
<%@ var showPlot: Boolean = false %> <%@ var showPlot: Boolean = false %>
<%@ var showTable: Boolean = true %> <%@ var showTable: Boolean = true %>
<%@ var showIntro: Boolean = true%> <%@ var showIntro: Boolean = true%>
<%@ var runId: Int %>
#{ #{
val samples = sampleId match { val samples = Await.result(summary.getSamples(runId = Some(runId)), Duration.Inf)
case Some(sample) => {
List(sample.toString)
}
case _ => summary.samples.toList
}
}# }#
#if (showIntro) #if (showIntro)
<br/> <br/>
...@@ -69,24 +67,31 @@ ...@@ -69,24 +67,31 @@
<th>(%)</th> <th>(%)</th>
</tr></thead> </tr></thead>
<tbody> <tbody>
#for (sample <- samples.toList.sorted) #for (sample <- samples.sortBy(_.name))
#{ #{
val libs = (libId, sampleLevel) match { val libs: List[Option[Int]] = (libId, sampleLevel) match {
case (_, true) => List("") case (_, true) => List(None)
case (Some(libId), _) => List(libId.toString).sorted case (Some(_), _) => List(libId)
case _ => summary.libraries(sample).toList.sorted case _ => Await.result(summary.getLibraries(sampleId = Some(sample.id), runId = Some(runId)), Duration.Inf).map(x => Some(x.id)).toList
} }
}# }#
<tr><td rowspan="${libs.size}"><a href="${rootPath}Samples/${sample}/index.html">${sample}</a></td> <tr><td rowspan="${libs.size}"><a href="${rootPath}Samples/${sample.name}/index.html">${sample.name}</a></td>
#for (libId <- libs) #for (libId <- libs)
#{ val libName = libId.map(l => Await.result(summary.getLibraryName(l), Duration.Inf)) }#
#if (libs.head != libId) <tr> #end #if (libs.head != libId) <tr> #end
#if (!sampleLevel) <td><a href="${rootPath}Samples/${sample}/Libraries/${libId}/index.html">${libId}</a></td> #end #if (!sampleLevel) <td><a href="${rootPath}Samples/${sample.name}/Libraries/${libName}/index.html">${libName}</a></td> #end
#{ #{
val prefixPath = List("samples", sample) ::: (if (libId.isEmpty) Nil else List("libraries", libId)) ::: List("bammetrics", "stats") val statsPaths = Map(
val total = summary.getValue((prefixPath ::: List("bamstats", "flagstats", "All")):_*).getOrElse(0L).asInstanceOf[Long] "All" -> List("flagstats", "All"),
val mapped = summary.getValue((prefixPath ::: List("bamstats", "flagstats", "Mapped")):_*).getOrElse(0L).asInstanceOf[Long] "Mapped" -> List("flagstats", "Mapped"),
val duplicates = summary.getValue((prefixPath ::: List("bamstats", "flagstats", "Duplicates")):_*).getOrElse(0L).asInstanceOf[Long] "Duplicates" -> List("flagstats", "Duplicates"),
val secondary = summary.getValue((prefixPath ::: List("bamstats", "flagstats", "NotPrimaryAlignment")):_*).getOrElse(0L).asInstanceOf[Long] "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 total = results("All").getOrElse(0L).asInstanceOf[Long]
val mapped = results("Mapped").getOrElse(0L).asInstanceOf[Long]
val duplicates = results("Duplicates").getOrElse(0L).asInstanceOf[Long]
val secondary = results("NotPrimaryAlignment").getOrElse(0L).asInstanceOf[Long]
}# }#
<td>${total}</td> <td>${total}</td>
<td>${mapped}</td> <td>${mapped}</td>
......
#import(nl.lumc.sasc.biopet.utils.summary.Summary) #import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
#import(nl.lumc.sasc.biopet.core.report.ReportPage) #import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(scala.concurrent.Await)
#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(org.apache.commons.io.FileUtils) <%@ var summary: SummaryDb %>
<%@ var summary: Summary %> <%@ var sampleId: Option[Int] = None %>
<%@ var sampleId: Option[String] = None %> <%@ var libId: Option[Int] = None %>
<%@ var libId: Option[String] = None %>
<%@ var rootPath: String %>
<%@ var metricsTag: String = "bammetrics" %>
<%@ var sampleLevel: Boolean = false %> <%@ var sampleLevel: Boolean = false %>
<%@ var rootPath: String %>
<%@ var outputDir: File %> <%@ var outputDir: File %>
<%@ var fields: List[String] = List("min", "max", "mean", "median", "modal")%>
<%@ var showPlot: Boolean = false %> <%@ var showPlot: Boolean = false %>
<%@ var showTable: Boolean = true %> <%@ var showTable: Boolean = true %>
<%@ var showIntro: Boolean = true%> <%@ var showIntro: Boolean = true%>
<%@ var runId: Int %>
<%@ var fields: List[String] = List("min", "max", "mean", "median", "modal")%>
#{ #{
val samples = sampleId match { val samples = Await.result(summary.getSamples(runId = Some(runId)), Duration.Inf)
case Some(sample) => {
List(sample.toString)
}
case _ => summary.samples.toList
}
}# }#
#if (showIntro) #if (showIntro)
...@@ -42,7 +38,7 @@ ...@@ -42,7 +38,7 @@
#end #end
#if (showPlot) #if (showPlot)
#{ BammetricsReport.clippingPlot(outputDir, "clipping", summary, !sampleLevel, sampleId = sampleId, libId = libId) }# #{ BammetricsReport.clippingPlot(outputDir, "clipping", summary, !sampleLevel, sampleId = sampleId, libraryId = libId) }#
<div class="panel-body"> <div class="panel-body">
<img src="clipping.png" class="img-responsive" /> <img src="clipping.png" class="img-responsive" />
...@@ -71,27 +67,25 @@ ...@@ -71,27 +67,25 @@
#end #end
</tr></thead> </tr></thead>
<tbody> <tbody>
#for (sample <- samples.toList.sorted) #for (sample <- samples.sortBy(_.name))
#{ #{
val libs = (libId, sampleLevel) match { val libs: List[Option[Int]] = (libId, sampleLevel) match {
case (_, true) => List("") case (_, true) => List(None)
case (Some(libId), _) => List(libId.toString) case (Some(_), _) => List(libId)
case _ => summary.libraries(sample).toList case _ => Await.result(summary.getLibraries(sampleId = Some(sample.id), runId = Some(runId)), Duration.Inf).map(x => Some(x.id)).toList
} }
}# }#
<tr><td rowspan="${libs.size}"><a href="${rootPath}Samples/${sample}/index.html">${sample}</a></td> <tr><td rowspan="${libs.size}"><a href="${rootPath}Samples/${sample.name}/index.html">${sample.name}</a></td>
#for (libId <- libs) #for (libId <- libs)
#{ val libName = libId.map(l => Await.result(summary.getLibraryName(l), Duration.Inf)) }#
#if (libs.head != libId) <tr> #end #if (libs.head != libId) <tr> #end
#if (!sampleLevel) <td><a href="${rootPath}Samples/${sample}/Libraries/${libId}/index.html">${libId}</a></td> #end #if (!sampleLevel) <td><a href="${rootPath}Samples/${sample.name}/Libraries/${libName}/index.html">${libName}</a></td> #end
#{ #{
val prefixPath = List("samples", sample) ::: (if (libId.isEmpty) Nil else List("libraries", libId)) ::: List("bammetrics", "stats") 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 fieldValues = for (field <- fields) yield {
summary.getValue((prefixPath ::: List("bamstats", "clipping", "general", field)):_*).getOrElse("N/A")
}
}# }#
#for (value <- fieldValues) #for (field <- fields)
<td>${value}</td> <td>${results(field)}</td>
#end #end
</tr> </tr>
#end #end
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#end #end
#if (showPlot) #if (showPlot)
#{ BammetricsReport.insertSizePlot(outputDir, "insertsize", summary, !sampleLevel, sampleId = sampleId, libId = libId) }# #{ BammetricsReport.insertSizePlot(outputDir, "insertsize", summary, !sampleLevel, sampleId = sampleId, libraryId = libId) }#
<div class="panel-body"> <div class="panel-body">
<img src="insertsize.png" class="img-responsive" /> <img src="insertsize.png" class="img-responsive" />
......
#import(nl.lumc.sasc.biopet.utils.summary.Summary) #import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
#import(nl.lumc.sasc.biopet.core.report.ReportPage) #import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(scala.concurrent.Await)
#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(org.apache.commons.io.FileUtils) <%@ var summary: SummaryDb %>
<%@ var summary: Summary %> <%@ var sampleId: Option[Int] = None %>
<%@ var sampleId: Option[String] = None %> <%@ var libId: Option[Int] = None %>
<%@ var libId: Option[String] = None %>
<%@ var rootPath: String %>
<%@ var metricsTag: String = "bammetrics" %>
<%@ var sampleLevel: Boolean = false %> <%@ var sampleLevel: Boolean = false %>
<%@ var rootPath: String %>
<%@ var outputDir: File %> <%@ var outputDir: File %>
<%@ var fields: List[String] = List("min", "max", "mean", "median", "modal")%>
<%@ var showPlot: Boolean = false %> <%@ var showPlot: Boolean = false %>
<%@ var showTable: Boolean = true %> <%@ var showTable: Boolean = true %>
<%@ var showIntro: Boolean = true%> <%@ var showIntro: Boolean = true%>
<%@ var runId: Int %>
<%@ var fields: List[String] = List("min", "max", "mean", "median", "modal")%>
#{ #{
val samples = sampleId match { val samples = Await.result(summary.getSamples(runId = Some(runId)), Duration.Inf)
case Some(sample) => {
List(sample.toString)
}
case _ => summary.samples.toList
}
}# }#
#if (showIntro) #if (showIntro)
...@@ -42,7 +39,7 @@ ...@@ -42,7 +39,7 @@
#end #end
#if (showPlot) #if (showPlot)
#{ BammetricsReport.mappingQualityPlot(outputDir, "mapping_quality", summary, !sampleLevel, sampleId = sampleId, libId = libId) }# #{ BammetricsReport.mappingQualityPlot(outputDir, "mapping_quality", summary, !sampleLevel, sampleId = sampleId, libraryId = libId) }#
<div class="panel-body"> <div class="panel-body">
<img src="mapping_quality.png" class="img-responsive" /> <img src="mapping_quality.png" class="img-responsive" />
...@@ -71,27 +68,25 @@ ...@@ -71,27 +68,25 @@
#end #end
</tr></thead> </tr></thead>
<tbody> <tbody>
#for (sample <- samples.toList.sorted) #for (sample <- samples.sortBy(_.name))
#{ #{
val libs = (libId, sampleLevel) match { val libs: List[Option[Int]] = (libId, sampleLevel) match {
case (_, true) => List("") case (_, true) => List(None)
case (Some(libId), _) => List(libId.toString) case (Some(_), _) => List(libId)
case _ => summary.libraries(sample).toList case _ => Await.result(summary.getLibraries(sampleId = Some(sample.id), runId = Some(runId)), Duration.Inf).map(x => Some(x.id)).toList
} }
}# }#
<tr><td rowspan="${libs.size}"><a href="${rootPath}Samples/${sample}/index.html">${sample}</a></td> <tr><td rowspan="${libs.size}"><a href="${rootPath}Samples/${sample.name}/index.html">${sample.name}</a></td>
#for (libId <- libs) #for (libId <- libs)
#{ val libName = libId.map(l => Await.result(summary.getLibraryName(l), Duration.Inf)) }#
#if (libs.head != libId) <tr> #end #if (libs.head != libId) <tr> #end
#if (!sampleLevel) <td><a href="${rootPath}Samples/${sample}/Libraries/${libId}/index.html">${libId}</a></td> #end #if (!sampleLevel) <td><a href="${rootPath}Samples/${sample.name}/Libraries/${libName}/index.html">${libName}</a></td> #end
#{ #{
val prefixPath = List("samples", sample) ::: (if (libId.isEmpty) Nil else List("libraries", libId)) ::: List("bammetrics", "stats") 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 fieldValues = for (field <- fields) yield {
summary.getValue((prefixPath ::: List("bamstats", "mapping_quality", "general", field)):_*).getOrElse("N/A")
}
}# }#
#for (value <- fieldValues) #for (field <- fields)
<td>${value}</td> <td>${results(field)}</td>
#end #end
</tr> </tr>
#end #end
......
#import(nl.lumc.sasc.biopet.utils.summary.Summary) #import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
#import(nl.lumc.sasc.biopet.core.report.ReportPage) #import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(scala.concurrent.Await)
#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(org.apache.commons.io.FileUtils) <%@ var summary: SummaryDb %>
<%@ var summary: Summary %> <%@ var sampleId: Option[Int] = None %>
<%@ var sampleId: Option[String] = None %> <%@ var libId: Option[Int] = None %>
<%@ var libId: Option[String] = None %>
<%@ var rootPath: String %>
<%@ var metricsTag: String = "bammetrics" %>
<%@ var sampleLevel: Boolean = false %> <%@ var sampleLevel: Boolean = false %>
<%@ var rootPath: String %>
<%@ var outputDir: File %> <%@ var outputDir: File %>
<%@ var fields: List[String] = List("mean_coverage", "pct_5x", "pct_10x", "pct_15x", "pct_20x", "pct_25x", "pct_30x", "pct_40x", "pct_50x", "pct_60x", "pct_70x", "pct_80x", "pct_90x", "pct_100x")%>
<%@ var showPlot: Boolean = false %> <%@ var showPlot: Boolean = false %>
<%@ var showTable: Boolean = true %> <%@ var showTable: Boolean = true %>
<%@ var showIntro: Boolean = true%> <%@ var showIntro: Boolean = true%>
<%@ var runId: Int %>
<%@ var fields: List[String] = List("mean_coverage", "pct_5x", "pct_10x", "pct_15x", "pct_20x", "pct_25x", "pct_30x", "pct_40x", "pct_50x", "pct_60x", "pct_70x", "pct_80x", "pct_90x", "pct_100x")%>
#{ #{
val samples = sampleId match { val samples = Await.result(summary.getSamples(runId = Some(runId)), Duration.Inf)
case Some(sample) => {
List(sample.toString)
}
case _ => summary.samples.toList
}
}# }#
#if (showIntro) #if (showIntro)
...@@ -36,7 +32,7 @@ ...@@ -36,7 +32,7 @@
#end #end
#if (showPlot) #if (showPlot)
#{ BammetricsReport.wgsHistogramPlot(outputDir, "wgs", summary, !sampleLevel, sampleId = sampleId, libId = libId) }# #{ BammetricsReport.wgsHistogramPlot(outputDir, "wgs", summary, !sampleLevel, sampleId = sampleId, libraryId = libId) }#
<div class="panel-body"> <div class="panel-body">
<img src="wgs.png" class="img-responsive" /> <img src="wgs.png" class="img-responsive" />
...@@ -62,27 +58,25 @@ ...@@ -62,27 +58,25 @@
#end #end
</tr></thead> </tr></thead>
<tbody> <tbody>
#for (sample <- samples.toList.sorted) #for (sample <- samples.sortBy(_.name))
#{ #{
val libs = (libId, sampleLevel) match { val libs: List[Option[Int]] = (libId, sampleLevel) match {
case (_, true) => List("") case (_, true) => List(None)
case (Some(libId), _) => List(libId.toString) case (Some(_), _) => List(libId)
case _ => summary.libraries(sample).toList case _ => Await.result(summary.getLibraries(sampleId = Some(sample.id), runId = Some(runId)), Duration.Inf).map(x => Some(x.id)).toList
} }
}# }#
<tr><td rowspan="${libs.size}"><a href="${rootPath}Samples/${sample}/index.html">${sample}</a></td> <tr><td rowspan="${libs.size}"><a href="${rootPath}Samples/${sample.name}/index.html">${sample.name}</a></td>
#for (libId <- libs) #for (libId <- libs)
#{ val libName = libId.map(l => Await.result(summary.getLibraryName(l), Duration.Inf)) }#
#if (libs.head != libId) <tr> #end #if (libs.head != libId) <tr> #end
#if (!sampleLevel) <td><a href="${rootPath}Samples/${sample}/Libraries/${libId}/index.html">${libId}</a></td> #end #if (!sampleLevel) <td><a href="${rootPath}Samples/${sample.name}/Libraries/${libName}/index.html">${libName}</a></td> #end
#{ #{
val prefixPath = List("samples", sample) ::: (if (libId.isEmpty) Nil else List("libraries", libId)) ::: List("bammetrics", "stats") 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 fieldValues = for (field <- fields) yield {
summary.getValue((prefixPath ::: List("wgs", "metrics", field.toUpperCase)):_*).getOrElse(prefixPath ::: metricsTag :: Nil)
}
}# }#
#for (value <- fieldValues) #for (field <- fields)
<td>${value}</td> <td>${results(field)}</td>
#end #end
</tr> </tr>
#end #end
......
...@@ -28,7 +28,7 @@ import nl.lumc.sasc.biopet.utils.config.Configurable ...@@ -28,7 +28,7 @@ import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.utils.intervals.BedCheck import nl.lumc.sasc.biopet.utils.intervals.BedCheck
import org.broadinstitute.gatk.queue.QScript import org.broadinstitute.gatk.queue.QScript
class BamMetrics(val root: Configurable) extends QScript class BamMetrics(val parent: Configurable) extends QScript
with SummaryQScript with SummaryQScript
with SampleLibraryTag with SampleLibraryTag
with Reference with Reference
...@@ -43,13 +43,6 @@ class BamMetrics(val root: Configurable) extends QScript ...@@ -43,13 +43,6 @@ class BamMetrics(val root: Configurable) extends QScript
override def defaults = Map("bedtoolscoverage" -> Map("sorted" -> true)) override def defaults = Map("bedtoolscoverage" -> Map("sorted" -> true))
/** return location of summary file */
def summaryFile = (sampleId, libId) match {
case (Some(s), Some(l)) => new File(outputDir, s + "-" + l + ".BamMetrics.summary.json")
case (Some(s), _) => new File(outputDir, s + ".BamMetrics.summary.json")
case _ => new File(outputDir, "BamMetrics.summary.json")
}
/** returns files to store in summary */ /** returns files to store in summary */
def summaryFiles = Map("reference" -> referenceFasta(), def summaryFiles = Map("reference" -> referenceFasta(),
"input_bam" -> inputBam) ++ "input_bam" -> inputBam) ++
...@@ -63,7 +56,7 @@ class BamMetrics(val root: Configurable) extends QScript ...@@ -63,7 +56,7 @@ class BamMetrics(val root: Configurable) extends QScript
override def reportClass = { override def reportClass = {
val bammetricsReport = new BammetricsReport(this) val bammetricsReport = new BammetricsReport(this)
bammetricsReport.outputDir = new File(outputDir, "report") bammetricsReport.outputDir = new File(outputDir, "report")
bammetricsReport.summaryFile = summaryFile bammetricsReport.summaryDbFile = summaryDbFile
bammetricsReport.args = if (libId.isDefined) Map( bammetricsReport.args = if (libId.isDefined) Map(
"sampleId" -> sampleId.getOrElse("."), "sampleId" -> sampleId.getOrElse("."),
"libId" -> libId.getOrElse(".")) "libId" -> libId.getOrElse("."))
......
...@@ -17,11 +17,16 @@ package nl.lumc.sasc.biopet.pipelines.bammetrics ...@@ -17,11 +17,16 @@ package nl.lumc.sasc.biopet.pipelines.bammetrics
import java.io.{ File, PrintWriter } import java.io.{ File, PrintWriter }
import nl.lumc.sasc.biopet.utils.config.Configurable import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.core.report.{ ReportBuilderExtension, ReportBuilder, ReportPage, ReportSection } import nl.lumc.sasc.biopet.core.report.{ ReportBuilder, ReportBuilderExtension, ReportPage, ReportSection }
import nl.lumc.sasc.biopet.utils.summary.{ Summary, SummaryValue } import nl.lumc.sasc.biopet.utils.ConfigUtils
import nl.lumc.sasc.biopet.utils.rscript.{ StackedBarPlot, LinePlot } import nl.lumc.sasc.biopet.utils.rscript.{ LinePlot, StackedBarPlot }
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
class BammetricsReport(val root: Configurable) extends ReportBuilderExtension { import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Await
import scala.concurrent.duration.Duration
class BammetricsReport(val parent: Configurable) extends ReportBuilderExtension {
def builder = BammetricsReport def builder = BammetricsReport
} }
...@@ -52,23 +57,25 @@ object BammetricsReport extends ReportBuilder { ...@@ -52,23 +57,25 @@ object BammetricsReport extends ReportBuilder {
} }
/** Generates a page with alignment stats */ /** Generates a page with alignment stats */
def bamMetricsPage(summary: Summary, def bamMetricsPage(summary: SummaryDb,
sampleId: Option[String], sampleId: Option[Int],
libId: Option[String], libId: Option[Int],
metricsTag: String = "bammetrics") = { metricsTag: String = "bammetrics") = {
val wgsExecuted = summary.getValue(sampleId, libId, metricsTag, "stats", "wgs").isDefined //val pipelineId: Int = summary.getPipelineId(runId, metricsTag).map(_.get)
val rnaExecuted = summary.getValue(sampleId, libId, metricsTag, "stats", "rna").isDefined
val insertsizeMetrics = summary.getValue(sampleId, libId, metricsTag, "stats", "CollectInsertSizeMetrics", "metrics") match { val wgsExecuted = summary.getStatsSize(runId, Right(metricsTag), Some(Right("wgs")), sample = sampleId.map(Left(_)), library = libId.map(Left(_))) >= 1
case Some(None) => false val rnaExecuted = summary.getStatsSize(runId, Right(metricsTag), Some(Right("rna")), sample = sampleId.map(Left(_)), library = libId.map(Left(_))) >= 1
case Some(_) => true
case _ => false
}
val insertsizeMetrics = summary.getStatKeys(runId, Right(metricsTag), Some(Right("CollectInsertSizeMetrics")),
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(_)),
Map("amplicon_name" -> List("amplicon_name"), "roi_name" -> List("roi_name")))
val targets = ( val targets = (
summary.getValue(sampleId, libId, metricsTag, "settings", "amplicon_name"), targetSettings("amplicon_name"),
summary.getValue(sampleId, libId, metricsTag, "settings", "roi_name") targetSettings("roi_name")
) match { ) match {
case (Some(amplicon: String), Some(roi: List[_])) => amplicon :: roi.map(_.toString) case (Some(amplicon: String), Some(roi: List[_])) => amplicon :: roi.map(_.toString)
case (_, Some(roi: List[_])) => roi.map(_.toString) case (_, Some(roi: List[_])) => roi.map(_.toString)
...@@ -108,44 +115,42 @@ object BammetricsReport extends ReportBuilder { ...@@ -108,44 +115,42 @@ object BammetricsReport extends ReportBuilder {
*/ */