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

Adding plots to flexiprep

parent e24802ad
...@@ -29,49 +29,58 @@ nav ul { ...@@ -29,49 +29,58 @@ nav ul {
position: relative; position: relative;
display: inline-table; display: inline-table;
} }
nav ul:after { nav ul:after {
content: ""; clear: both; display: block; content: ""; clear: both; display: block;
} }
nav ul li { nav ul li {
float: left; float: left;
} }
nav ul li:hover { nav ul li:hover {
background: #4b545f; background: #4b545f;
background: linear-gradient(top, #4f5964 0%, #5f6975 40%); background: linear-gradient(top, #4f5964 0%, #5f6975 40%);
background: -moz-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%); background: -webkit-linear-gradient(top, #4f5964 0%,#5f6975 40%);
} }
nav ul li:hover a { nav ul li:hover a {
color: #fff; color: #fff;
} }
nav ul li a { nav ul li a {
display: block; padding: 10px 10px; display: block; padding: 2px 10px;
color: #757575; text-decoration: none; color: #757575; text-decoration: none;
} }
nav ul ul { nav ul ul {
background: #5f6975; border-radius: 0px; padding: 0; background: #5f6975; border-radius: 0px; padding: 0;
position: absolute; top: 100%; position: absolute; top: 100%;
} }
nav ul ul li { nav ul ul li {
float: none; float: none;
border-top: 1px solid #6b727c; border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a; border-bottom: 1px solid #575f6a;
position: relative; position: relative;
} }
nav ul ul li a { nav ul ul li a {
padding: 15px 40px; padding: 5px 15px;
color: #fff; color: #fff;
} }
nav ul ul li a:hover { nav ul ul li a:hover {
background: #4b545f; background: #4b545f;
} }
nav ul ul ul { nav ul ul ul {
position: absolute; left: 100%; top:0; position: absolute; left: 100%; top:0;
} }
section { #main {
padding:10px; float: left;
padding: 15px;
}
#index {
left: 0;
float: left;
line-height:30px;
background-color:#eeeeee;
padding:5px;
} }
footer { footer {
background-color:black; background-color:black;
...@@ -89,7 +98,3 @@ th { ...@@ -89,7 +98,3 @@ th {
border: 1px solid white; border: 1px solid white;
color: white; color: white;
} }
aside {
#float: left;
height: 100%;
}
\ No newline at end of file
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<body> <body>
<header><h1>${reportName}</h1></header> <header><h1>${reportName}</h1></header>
<nav> <nav id="menu">
<ul> <ul>
#for (t <- 0 to path.size) #for (t <- 0 to path.size)
<li> <li>
...@@ -55,19 +55,21 @@ ...@@ -55,19 +55,21 @@
#end #end
</ul> </ul>
</nav> </nav>
<aside> <aside id="index">
<ul> <ul>
#for ((name, url) <- page.sections) #for ((name, url) <- page.sections)
<li><a href="#${name}">${name}</a></li> <li><a href="#${name}">${name}</a></li>
#end #end
</ul> </ul>
</aside> </aside>
<aside id="main">
#for ((name, url) <- page.sections) #for ((name, url) <- page.sections)
<section id="${name}"> <section id="${name}">
<h3>${name}</h3> <h3>${name}</h3>
${include(url)} ${unescape(url.render(args))}
</section> </section>
#end #end
</aside>
<footer>Footer</footer> <footer>Footer</footer>
</body> </body>
......
...@@ -16,7 +16,7 @@ trait MultisampleReportBuilder extends ReportBuilder { ...@@ -16,7 +16,7 @@ trait MultisampleReportBuilder extends ReportBuilder {
val samplePages = summary.samples val samplePages = summary.samples
.map(sampleId => (sampleId -> samplePage(sampleId, args ++ Map("sampleId" -> Some(sampleId))))) .map(sampleId => (sampleId -> samplePage(sampleId, args ++ Map("sampleId" -> Some(sampleId)))))
.toMap .toMap
ReportPage(samplePages, Map(), args) ReportPage(samplePages, List(), args)
} }
def generateLibraryPage(args: Map[String, Any]): ReportPage = { def generateLibraryPage(args: Map[String, Any]): ReportPage = {
...@@ -26,8 +26,8 @@ trait MultisampleReportBuilder extends ReportBuilder { ...@@ -26,8 +26,8 @@ trait MultisampleReportBuilder extends ReportBuilder {
}) })
.map(libId => (libId -> libraryPage(libId, args ++ Map("libId" -> Some(libId))))) .map(libId => (libId -> libraryPage(libId, args ++ Map("libId" -> Some(libId)))))
.toMap .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 { ...@@ -61,8 +61,6 @@ trait ReportBuilder extends ToolCommand {
logger.info("Done") logger.info("Done")
} }
protected val engine = new TemplateEngine()
def indexPage: ReportPage def indexPage: ReportPage
def reportName: String def reportName: String
...@@ -73,13 +71,14 @@ trait ReportBuilder extends ToolCommand { ...@@ -73,13 +71,14 @@ trait ReportBuilder extends ToolCommand {
path: List[String] = Nil, path: List[String] = Nil,
args: Map[String, Any] = Map()): Unit = { args: Map[String, Any] = Map()): Unit = {
val templateText = Source.fromInputStream(getClass.getResourceAsStream("/nl/lumc/sasc/biopet/core/report/main.ssp")).getLines().mkString("\n") val pageOutputDir = new File(outputDir, path.mkString(File.separator))
val template = engine.compileText("ssp", templateText) pageOutputDir.mkdirs()
val pageArgs = args ++ page.args ++ Map("page" -> page, "path" -> path) val pageArgs = args ++ page.args ++ Map("page" -> page, "path" -> path, "outputDir" -> pageOutputDir)
val output = engine.layout(template.source, pageArgs ++ Map("args" -> pageArgs))
val file = new File(outputDir, path.mkString("", File.separator, File.separator) + "index.html") val output = ReportBuilder.renderTemplate("/nl/lumc/sasc/biopet/core/report/main.ssp",
file.getParentFile.mkdirs() pageArgs ++ Map("args" -> pageArgs))
val file = new File(pageOutputDir, "index.html")
val writer = new PrintWriter(file) val writer = new PrintWriter(file)
writer.println(output) writer.println(output)
writer.close() writer.close()
...@@ -90,3 +89,15 @@ trait ReportBuilder extends ToolCommand { ...@@ -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 package nl.lumc.sasc.biopet.core.report
import java.net.URL
/** /**
* Created by pjvan_thof on 3/27/15. * Created by pjvan_thof on 3/27/15.
*/ */
case class ReportPage(val subPages: Map[String, ReportPage], case class ReportPage(val subPages: Map[String, ReportPage],
val sections: Map[String, String], val sections: List[(String, ReportSection)],
val args: Map[String, Any]) 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 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. * Created by pjvan_thof on 3/30/15.
...@@ -9,7 +9,21 @@ object FlexiprepReport extends ReportBuilder { ...@@ -9,7 +9,21 @@ object FlexiprepReport extends ReportBuilder {
val reportName = "Flexiprep" val reportName = "Flexiprep"
def indexPage = { 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 // FIXME: Not yet finished
......
package nl.lumc.sasc.biopet.pipelines.shiva 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 import nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport
/** /**
...@@ -8,20 +8,20 @@ import nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport ...@@ -8,20 +8,20 @@ import nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport
*/ */
object ShivaReport extends MultisampleReportBuilder { object ShivaReport extends MultisampleReportBuilder {
def samplePage(sampleId: String, args: Map[String, Any]) = { def samplePage(sampleId: String, args: Map[String, Any]) = {
ReportPage(Map("Libraries" -> generateLibraryPage(args)), Map( ReportPage(Map("Libraries" -> generateLibraryPage(args)), List(
"Variantcalling" -> "/nl/lumc/sasc/biopet/core/report/ShivaVariantcalling.ssp" "Variantcalling" -> ReportSection("/nl/lumc/sasc/biopet/core/report/ShivaVariantcalling.ssp")
), args) ), args)
} }
def libraryPage(libId: String, args: Map[String, Any]) = { 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 reportName = "Title Test"
def generalPage = ReportPage(Map(), Map( def generalPage = ReportPage(Map(), List(
"Variantcalling" -> "/nl/lumc/sasc/biopet/core/report/ShivaVariantcalling.ssp", "Variantcalling" -> ReportSection("/nl/lumc/sasc/biopet/core/report/ShivaVariantcalling.ssp"),
"Flexiprep" -> "/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepSummary.ssp" "Flexiprep" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepSummary.ssp")
), Map()) ), Map())
// FIXME: Not yet finished // 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