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

Adding plots to flexiprep

parent e24802ad
......@@ -11,67 +11,76 @@ nav {
padding:5px;
}
nav ul ul {
display: none;
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
background: #efefef;
background: linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: -moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: -webkit-linear-gradient(top, #efefef 0%,#bbbbbb 100%);
box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
padding: 0 20px;
border-radius: 10px;
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content: ""; clear: both; display: block;
}
background: #efefef;
background: linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: -moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: -webkit-linear-gradient(top, #efefef 0%,#bbbbbb 100%);
box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
padding: 0 20px;
border-radius: 10px;
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content: ""; clear: both; display: block;
}
nav ul li {
float: left;
}
nav ul li:hover {
background: #4b545f;
background: linear-gradient(top, #4f5964 0%, #5f6975 40%);
background: -moz-linear-gradient(top, #4f5964 0%, #5f6975 40%);
background: -webkit-linear-gradient(top, #4f5964 0%,#5f6975 40%);
}
nav ul li:hover a {
color: #fff;
}
nav ul li {
float: left;
}
nav ul li:hover {
background: #4b545f;
background: linear-gradient(top, #4f5964 0%, #5f6975 40%);
background: -moz-linear-gradient(top, #4f5964 0%, #5f6975 40%);
background: -webkit-linear-gradient(top, #4f5964 0%,#5f6975 40%);
}
nav ul li:hover a {
color: #fff;
}
nav ul li a {
display: block; padding: 10px 10px;
color: #757575; text-decoration: none;
}
nav ul ul {
background: #5f6975; border-radius: 0px; padding: 0;
position: absolute; top: 100%;
}
nav ul ul li {
float: none;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position: relative;
}
nav ul ul li a {
padding: 15px 40px;
color: #fff;
}
nav ul ul li a:hover {
background: #4b545f;
}
nav ul li a {
display: block; padding: 2px 10px;
color: #757575; text-decoration: none;
}
nav ul ul {
background: #5f6975; border-radius: 0px; padding: 0;
position: absolute; top: 100%;
}
nav ul ul li {
float: none;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position: relative;
}
nav ul ul li a {
padding: 5px 15px;
color: #fff;
}
nav ul ul li a:hover {
background: #4b545f;
}
nav ul ul ul {
position: absolute; left: 100%; top:0;
position: absolute; left: 100%; top:0;
}
#main {
float: left;
padding: 15px;
}
section {
padding:10px;
#index {
left: 0;
float: left;
line-height:30px;
background-color:#eeeeee;
padding:5px;
}
footer {
background-color:black;
......@@ -89,7 +98,3 @@ th {
border: 1px solid white;
color: white;
}
aside {
#float: left;
height: 100%;
}
\ No newline at end of file
......@@ -40,7 +40,7 @@
<body>
<header><h1>${reportName}</h1></header>
<nav>
<nav id="menu">
<ul>
#for (t <- 0 to path.size)
<li>
......@@ -55,19 +55,21 @@
#end
</ul>
</nav>
<aside>
<aside id="index">
<ul>
#for ((name, url) <- page.sections)
<li><a href="#${name}">${name}</a></li>
#end
</ul>
</aside>
<aside id="main">
#for ((name, url) <- page.sections)
<section id="${name}">
<h3>${name}</h3>
${include(url)}
</section>
<section id="${name}">
<h3>${name}</h3>
${unescape(url.render(args))}
</section>
#end
</aside>
<footer>Footer</footer>
</body>
......
......@@ -16,7 +16,7 @@ trait MultisampleReportBuilder extends ReportBuilder {
val samplePages = summary.samples
.map(sampleId => (sampleId -> samplePage(sampleId, args ++ Map("sampleId" -> Some(sampleId)))))
.toMap
ReportPage(samplePages, Map(), args)
ReportPage(samplePages, List(), args)
}
def generateLibraryPage(args: Map[String, Any]): ReportPage = {
......@@ -26,8 +26,8 @@ trait MultisampleReportBuilder extends ReportBuilder {
})
.map(libId => (libId -> libraryPage(libId, args ++ Map("libId" -> Some(libId)))))
.toMap
ReportPage(libPages, Map(), args)
ReportPage(libPages, List(), args)
}
def indexPage = ReportPage(Map("General" -> generalPage, "Samples" -> generateSamplesPage(pageArgs)), Map(), pageArgs)
def indexPage = ReportPage(Map("General" -> generalPage, "Samples" -> generateSamplesPage(pageArgs)), List(), pageArgs)
}
......@@ -61,8 +61,6 @@ trait ReportBuilder extends ToolCommand {
logger.info("Done")
}
protected val engine = new TemplateEngine()
def indexPage: ReportPage
def reportName: String
......@@ -73,13 +71,14 @@ trait ReportBuilder extends ToolCommand {
path: List[String] = Nil,
args: Map[String, Any] = Map()): Unit = {
val templateText = Source.fromInputStream(getClass.getResourceAsStream("/nl/lumc/sasc/biopet/core/report/main.ssp")).getLines().mkString("\n")
val template = engine.compileText("ssp", templateText)
val pageArgs = args ++ page.args ++ Map("page" -> page, "path" -> path)
val output = engine.layout(template.source, pageArgs ++ Map("args" -> pageArgs))
val pageOutputDir = new File(outputDir, path.mkString(File.separator))
pageOutputDir.mkdirs()
val pageArgs = args ++ page.args ++ Map("page" -> page, "path" -> path, "outputDir" -> pageOutputDir)
val file = new File(outputDir, path.mkString("", File.separator, File.separator) + "index.html")
file.getParentFile.mkdirs()
val output = ReportBuilder.renderTemplate("/nl/lumc/sasc/biopet/core/report/main.ssp",
pageArgs ++ Map("args" -> pageArgs))
val file = new File(pageOutputDir, "index.html")
val writer = new PrintWriter(file)
writer.println(output)
writer.close()
......@@ -90,3 +89,15 @@ trait ReportBuilder extends ToolCommand {
}
}
}
object ReportBuilder {
protected val engine = new TemplateEngine()
def renderTemplate(location: String, args:Map[String, Any]) : String = {
val templateText = Source.fromInputStream(getClass.getResourceAsStream(location)).getLines().mkString("\n")
val template = engine.compileText("ssp", templateText)
engine.layout(template.source, args)
}
}
\ No newline at end of file
package nl.lumc.sasc.biopet.core.report
import java.net.URL
/**
* Created by pjvan_thof on 3/27/15.
*/
case class ReportPage(val subPages: Map[String, ReportPage],
val sections: Map[String, String],
val sections: List[(String, ReportSection)],
val args: Map[String, Any])
package nl.lumc.sasc.biopet.core.report
/**
* Created by pjvan_thof on 4/8/15.
*/
case class ReportSection(location: String,
args: Map[String, Any] = Map()) {
def render(args: Map[String, Any]): String = {
ReportBuilder.renderTemplate(location, args ++ this.args)
}
}
\ No newline at end of file
#import(nl.lumc.sasc.biopet.core.summary.Summary)
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(org.apache.commons.io.FileUtils)
#import(java.io.File)
<%@ var summary: Summary %>
<%@ var sampleId: Option[String] %>
<%@ var libId: Option[String] %>
<%@ var plot: String %>
<%@ var outputDir: File %>
#{
val paired: Boolean = summary.getLibraryValue(sampleId.get, libId.get, "flexiprep", "settings", "paired").get.asInstanceOf[Boolean]
val skipClip: Boolean = summary.getLibraryValue(sampleId.get, libId.get, "flexiprep", "settings", "skip_clip").get.asInstanceOf[Boolean]
val skipTrim: Boolean = summary.getLibraryValue(sampleId.get, libId.get, "flexiprep", "settings", "skip_trim").get.asInstanceOf[Boolean]
def getPlot(read:String) = {
summary.getLibraryValue(sampleId.get, libId.get, "flexiprep", "files", read, plot, "path").collect {
case value => {
val file = new File(value.toString)
val newFile = new File(outputDir, read + "_" + file.getName)
FileUtils.copyFile(file, newFile)
newFile.getName
}
}
}
}#
<table>
<tbody>
<tr><td></td>
<th>Before QC</th>
#if (!skipTrim || !skipClip) <th>after QC</th> #end
</tr>
<tr><th>R1</th>
<td><img src="${getPlot("fastqc_R1")}" width="75%"></td>
#if (!skipTrim || !skipClip) <td><img src="${getPlot("fastqc_R1_qc")}" width="75%"></td> #end
</tr>
#if (paired)
<tr><th>R2</th>
<td><img src="${getPlot("fastqc_R2")}" width="75%"></td>
#if (!skipTrim || !skipClip) <td><img src="${getPlot("fastqc_R2_qc")}" width="75%"></td> #end
</tr>
#end
</tbody>
</table>
\ No newline at end of file
package nl.lumc.sasc.biopet.pipelines.flexiprep
import nl.lumc.sasc.biopet.core.report.{ ReportPage, ReportBuilder }
import nl.lumc.sasc.biopet.core.report.{ReportSection, ReportPage, ReportBuilder}
/**
* Created by pjvan_thof on 3/30/15.
......@@ -9,7 +9,21 @@ object FlexiprepReport extends ReportBuilder {
val reportName = "Flexiprep"
def indexPage = {
ReportPage(Map(), Map("Summary" -> "/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepSummary.ssp"), Map())
ReportPage(Map(), List(
"Summary" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepSummary.ssp"),
fastqcPlotSection("Base quality", "plot_per_base_quality"),
fastqcPlotSection("Sequence quality", "plot_per_sequence_quality"),
fastqcPlotSection("Base GC content", "plot_per_base_gc_content"),
fastqcPlotSection("Sequence GC content", "plot_per_sequence_gc_content"),
fastqcPlotSection("Base seqeunce content", "plot_per_base_sequence_content"),
fastqcPlotSection("Duplication", "plot_duplication_levels"),
fastqcPlotSection("Kmers", "plot_kmer_profiles"),
fastqcPlotSection("Length distribution", "plot_sequence_length_distribution")
), Map())
}
protected def fastqcPlotSection(name:String, tag: String) = {
name -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepFastaqcPlot.ssp", Map("plot" -> tag))
}
// FIXME: Not yet finished
......
package nl.lumc.sasc.biopet.pipelines.shiva
import nl.lumc.sasc.biopet.core.report.{ MultisampleReportBuilder, ReportPage }
import nl.lumc.sasc.biopet.core.report.{ReportSection, MultisampleReportBuilder, ReportPage}
import nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport
/**
......@@ -8,20 +8,20 @@ import nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport
*/
object ShivaReport extends MultisampleReportBuilder {
def samplePage(sampleId: String, args: Map[String, Any]) = {
ReportPage(Map("Libraries" -> generateLibraryPage(args)), Map(
"Variantcalling" -> "/nl/lumc/sasc/biopet/core/report/ShivaVariantcalling.ssp"
ReportPage(Map("Libraries" -> generateLibraryPage(args)), List(
"Variantcalling" -> ReportSection("/nl/lumc/sasc/biopet/core/report/ShivaVariantcalling.ssp")
), args)
}
def libraryPage(libId: String, args: Map[String, Any]) = {
ReportPage(Map("Flexiprep" -> FlexiprepReport.indexPage), Map(), args)
ReportPage(Map("Flexiprep" -> FlexiprepReport.indexPage), List(), args)
}
def reportName = "Title Test"
def generalPage = ReportPage(Map(), Map(
"Variantcalling" -> "/nl/lumc/sasc/biopet/core/report/ShivaVariantcalling.ssp",
"Flexiprep" -> "/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepSummary.ssp"
def generalPage = ReportPage(Map(), List(
"Variantcalling" -> ReportSection("/nl/lumc/sasc/biopet/core/report/ShivaVariantcalling.ssp"),
"Flexiprep" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepSummary.ssp")
), Map())
// FIXME: Not yet finished
......
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