Commit 9b5627e5 authored by akaljuvee's avatar akaljuvee

Merge remote-tracking branch 'origin/develop' into fix-BIOPET-306-2

# Conflicts:
#	biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/rscript/LinePlot.scala
#	shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaReport.scala
parents 484b342d 7edefbcd
...@@ -44,18 +44,6 @@ ...@@ -44,18 +44,6 @@
<artifactId>BiopetExtensions</artifactId> <artifactId>BiopetExtensions</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.10</artifactId>
<version>2.2.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -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 = _
......
...@@ -42,17 +42,5 @@ ...@@ -42,17 +42,5 @@
<artifactId>BiopetToolsExtensions</artifactId> <artifactId>BiopetToolsExtensions</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.10</artifactId>
<version>2.2.1</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>
#import(nl.lumc.sasc.biopet.utils.summary.Summary) #import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._)
#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 +69,31 @@ ...@@ -69,24 +69,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, "bammetrics", "bamstats", sample = sample.id, library = libId.map(LibraryId).getOrElse(NoLibrary), 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.utils.summary.db.SummaryDb._)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._)
#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 +40,7 @@ ...@@ -42,7 +40,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 +69,25 @@ ...@@ -71,27 +69,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, "bammetrics", "bamstats", sample = sample.id, library = libId.map(LibraryId).getOrElse(NoLibrary), 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
......
#import(nl.lumc.sasc.biopet.utils.IoUtils) #import(nl.lumc.sasc.biopet.utils.IoUtils)
#import(nl.lumc.sasc.biopet.utils.summary.Summary)
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(org.apache.commons.io.FileUtils) #import(org.apache.commons.io.FileUtils)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._)
#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(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 sampleLevel: Boolean = true %> <%@ var sampleLevel: Boolean = true %>
<%@ var rootPath: String %> <%@ var libId: Option[Int] = None %>
<%@ var outputDir: File %> <%@ var outputDir: File %>
<%@ var rootPath: String %>
<%@ var metricsTag: String = "bammetrics" %> <%@ var metricsTag: String = "bammetrics" %>
<%@ var target: Option[String] %> <%@ var target: Option[String] %>
<%@ var runId: Int %>
<%@ var fields: List[String] = List("mean", "median", "max", "horizontal", "frac_min_10x", "frac_min_20x", "frac_min_30x", "frac_min_40x", "frac_min_50x") %>
#{ #{
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
}
}# }#
<table class="table"> <table class="table">
<thead><tr> <thead><tr>
<th>sample</th> <th>sample</th>
<th>mean</th> #for (field <- fields)
<th>median</th> <th>${field}</th>
<th>max</th> #end
<th>horizontal</th>
<th>frac min 10x</th>
<th>frac min 20x</th>
<th>frac min 30x</th>
<th>frac min 40x</th>
<th>frac min 50x</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) 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)
#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
#{ #{
val prefixPath = List("samples", sample) ::: (if (libId.isEmpty) Nil else List("libraries", libId)) ::: List(metricsTag, "stats", target.get + "_cov_stats", "coverage", "_all") val moduleName = target.get + "_cov_stats"
val total = summary.getValue((prefixPath ::: List("biopet_flagstat", "All")):_*).getOrElse(0L).asInstanceOf[Long] val statsPaths = fields.map(x => x -> List("coverage", "_all", x)).toMap
val mapped = summary.getValue((prefixPath ::: List("biopet_flagstat", "Mapped")):_*).getOrElse(0L).asInstanceOf[Long] val values = summary.getStatKeys(runId, PipelineName(metricsTag), ModuleName(moduleName), SampleId(sample.id), libId.map(LibraryId).getOrElse(NoLibrary), statsPaths)
val duplicates = summary.getValue((prefixPath ::: List("biopet_flagstat", "Duplicates")):_*).getOrElse(0L).asInstanceOf[Long]
}# }#
<td>${summary.getValue((prefixPath ::: "mean" :: Nil):_*)}</td> #for (field <- fields)
<td>${summary.getValue((prefixPath ::: "median" :: Nil):_*)}</td> <th>${values(field)}</th>
<td>${summary.getValue((prefixPath ::: "max" :: Nil):_*)}</td> #end
<td>${summary.getValue((prefixPath ::: "horizontal" :: Nil):_*)}</td>
<td>${summary.getValue((prefixPath ::: "frac_min_10x" :: Nil):_*)}</td>
<td>${summary.getValue((prefixPath ::: "frac_min_20x" :: Nil):_*)}</td>
<td>${summary.getValue((prefixPath ::: "frac_min_30x" :: Nil):_*)}</td>
<td>${summary.getValue((prefixPath ::: "frac_min_40x" :: Nil):_*)}</td>
<td>${summary.getValue((prefixPath ::: "frac_min_50x" :: Nil):_*)}</td>
</tr> </tr>
#end #end
#end #end
......
#import(nl.lumc.sasc.biopet.utils.IoUtils) #import(nl.lumc.sasc.biopet.utils.IoUtils)
#import(nl.lumc.sasc.biopet.utils.summary.Summary)
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(org.apache.commons.io.FileUtils) #import(org.apache.commons.io.FileUtils)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._)
#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(java.io.File) #import(java.io.File)
<%@ var summary: Summary %> <%@ var summary: SummaryDb %>
<%@ var sampleId: Option[String] %> <%@ var sampleId: Option[Int] %>
<%@ var libId: Option[String] = None %> <%@ var libId: Option[Int] = None %>
<%@ var outputDir: File %> <%@ var outputDir: File %>
<%@ var metricsTag: String = "bammetrics" %> <%@ var metricsTag: String = "bammetrics" %>
<%@ var target: Option[String] %> <%@ var target: Option[String] %>
<%@ var runId: Int %>
<%@ var fields: List[String] = List("mean", "median", "max", "horizontal", "frac_min_10x", "frac_min_20x", "frac_min_30x", "frac_min_40x", "frac_min_50x") %>
#{ #{
val originalPlot = new File(summary.getValue(sampleId, libId, metricsTag, "files", target.get + "_cov_stats", "plot", "path") val moduleName = target.get + "_cov_stats"
.getOrElse(throw new IllegalArgumentException("No plot found in summary")).toString)
val statsPaths = fields.map(x => x -> List("coverage", "_all", x)).toMap
val plotFile = Await.result(summary.getFile(runId, PipelineName(metricsTag), ModuleName(moduleName), sampleId.map(SampleId).get, libId.map(LibraryId).getOrElse(NoLibrary), "plot"), Duration.Inf)
val originalPlot = new File(plotFile.get.path)
val plot = new File(outputDir, target.get + "_cov_stats.png") val plot = new File(outputDir, target.get + "_cov_stats.png")
val values = summary.getValue(sampleId, libId, metricsTag, "stats", target.get + "_cov_stats", "coverage", "_all") val values = summary.getStatKeys(runId, PipelineName(metricsTag), ModuleName(moduleName), sampleId.map(SampleId).get, libId.map(LibraryId).getOrElse(NoLibrary), statsPaths)
.getOrElse(throw new IllegalArgumentException("No plot found in summary")).asInstanceOf[Map[String, Any]]
if (originalPlot.exists()) IoUtils.copyFile(originalPlot, plot) if (originalPlot.exists()) IoUtils.copyFile(originalPlot, plot)
}# }#
<img src="${plot.getName}"> <img src="${plot.getName}">
<table class="table"> <table class="table">
<thead><tr> <thead><tr>
<th>mean</th> #for (field <- fields)
<th>median</th> <th>${field}</th>
<th>max</th> #end
<th>horizontal</th>
<th>frac min 10x</th>
<th>frac min 20x</th>
<th>frac min 30x</th>
<th>frac min 40x</th>
<th>frac min 50x</th>
</tr></thead> </tr></thead>
<tbody> <tbody>
<tr> <tr>