Commit 3e35c32b authored by Peter van 't Hof's avatar Peter van 't Hof Committed by GitHub

Merge branch 'develop' into fix-BIOPET-635

parents 172d242a 625bb514
node('local') { node('local') {
timeout(45) { try {
try {
stage('Init') { stage('Init') {
tool 'JDK 8u102' tool 'JDK 8u102'
tool 'Apache Maven 3.3.9' tool 'Apache Maven 3.3.9'
} }
timeout(45) {
stage('Checkout') { stage('Checkout') {
checkout scm checkout scm
sh 'git submodule update --init --recursive' sh 'git submodule update --init --recursive'
} }
}
timeout(45) {
stage('Build and Test') { stage('Build and Test') {
withMaven(maven: 'Apache Maven 3.3.9', jdk: 'JDK 8u102') { withMaven(maven: 'Apache Maven 3.3.9', jdk: 'JDK 8u102') {
sh 'mvn -B -T 2 -Dmaven.test.failure.ignore clean package' sh 'mvn -B -T 2 -Dmaven.test.failure.ignore clean package'
} }
} }
}
stage('Report Tests') { stage('Report Tests') {
junit '*/target/surefire-reports/*.xml' junit '*/target/surefire-reports/*.xml'
} }
stage('Check git on changes') {
sh 'if [ $(git diff | wc -l) -eq 0 ]; then true; else echo "[ERROR] Git is not clean anymore after build"; git diff; echo "[ERROR] This might be caused by reformated code, if so run maven locally"; false; fi'
}
stage('Check Documentation') { stage('Check git on changes') {
sh 'mkdocs build --clean --strict' sh 'if [ $(git diff | wc -l) -eq 0 ]; then true; else echo "[ERROR] Git is not clean anymore after build"; git diff; echo "[ERROR] This might be caused by reformated code, if so run maven locally"; false; fi'
} }
if (currentBuild.result == null || "SUCCESS".equals(currentBuild.result)) { stage('Check Documentation') {
currentBuild.result = "SUCCESS" sh 'mkdocs build --clean --strict'
slackSend(color: '#00FF00', message: "${currentBuild.result}: Job '${env.JOB_NAME} #${env.BUILD_NUMBER}' (<${env.BUILD_URL}|Open>)", channel: '#biopet-bot', teamDomain: 'lumc', tokenCredentialId: 'lumc') }
} else {
slackSend(color: '#FFFF00', message: "${currentBuild.result}: Job '${env.JOB_NAME} #${env.BUILD_NUMBER}' (<${env.BUILD_URL}|Open>)", channel: '#biopet-bot', teamDomain: 'lumc', tokenCredentialId: 'lumc')
}
} catch (e) { if (currentBuild.result == null || "SUCCESS".equals(currentBuild.result)) {
if (currentBuild.result == null || "FAILED".equals(currentBuild.result)) { currentBuild.result = "SUCCESS"
currentBuild.result = "FAILED" slackSend(color: '#00FF00', message: "${currentBuild.result}: Job '${env.JOB_NAME} #${env.BUILD_NUMBER}' (<${env.BUILD_URL}|Open>)", channel: '#biopet-bot', teamDomain: 'lumc', tokenCredentialId: 'lumc')
} } else {
slackSend(color: '#FF0000', message: "${currentBuild.result}: Job '${env.JOB_NAME} #${env.BUILD_NUMBER}' (<${env.BUILD_URL}|Open>)", channel: '#biopet-bot', teamDomain: 'lumc', tokenCredentialId: 'lumc') slackSend(color: '#FFFF00', message: "${currentBuild.result}: Job '${env.JOB_NAME} #${env.BUILD_NUMBER}' (<${env.BUILD_URL}|Open>)", channel: '#biopet-bot', teamDomain: 'lumc', tokenCredentialId: 'lumc')
}
throw e } catch (e) {
if (currentBuild.result == null || "FAILED".equals(currentBuild.result)) {
currentBuild.result = "FAILED"
} }
slackSend(color: '#FF0000', message: "${currentBuild.result}: Job '${env.JOB_NAME} #${env.BUILD_NUMBER}' (<${env.BUILD_URL}|Open>)", channel: '#biopet-bot', teamDomain: 'lumc', tokenCredentialId: 'lumc')
throw e
} }
} }
...@@ -24,8 +24,7 @@ import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb ...@@ -24,8 +24,7 @@ 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.Implicts._
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._ import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._
import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.{ Await, Future }
import scala.concurrent.Await
import scala.concurrent.duration.Duration import scala.concurrent.duration.Duration
class BammetricsReport(val parent: Configurable) extends ReportBuilderExtension { class BammetricsReport(val parent: Configurable) extends ReportBuilderExtension {
...@@ -42,28 +41,27 @@ object BammetricsReport extends ReportBuilder { ...@@ -42,28 +41,27 @@ object BammetricsReport extends ReportBuilder {
/** Name of report */ /** Name of report */
val reportName = "Bam Metrics" val reportName = "Bam Metrics"
def pipelineName = "bammetrics"
/** Root page for single BamMetrcis report */ /** Root page for single BamMetrcis report */
def indexPage = { def indexPage: Future[ReportPage] =
val bamMetricsPage = this.bamMetricsPage(summary, sampleId, libId) bamMetricsPage(summary, sampleId, libId).map { bamMetricsPage =>
ReportPage(bamMetricsPage.subPages ::: List( ReportPage(bamMetricsPage.subPages ::: List(
"Versions" -> ReportPage(List(), List("Executables" -> ReportSection("/nl/lumc/sasc/biopet/core/report/executables.ssp" "Versions" -> Future(ReportPage(List(), List("Executables" -> ReportSection("/nl/lumc/sasc/biopet/core/report/executables.ssp"
)), Map()), )), Map())),
"Files" -> ReportPage(List(), List(), Map()) "Files" -> filesPage(sampleId, libId)
), List( ), List(
"Report" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/bamMetricsFront.ssp") "Report" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/bamMetricsFront.ssp")
) ::: bamMetricsPage.sections, ) ::: bamMetricsPage.sections,
Map() Map()
) )
} }
/** Generates a page with alignment stats */ /** Generates a page with alignment stats */
def bamMetricsPage(summary: SummaryDb, def bamMetricsPage(summary: SummaryDb,
sampleId: Option[Int], sampleId: Option[Int],
libId: Option[Int], libId: Option[Int],
metricsTag: String = "bammetrics") = { metricsTag: String = "bammetrics"): Future[ReportPage] = Future {
//val pipelineId: Int = summary.getPipelineId(runId, metricsTag).map(_.get)
val wgsExecuted = summary.getStatsSize(runId, metricsTag, "wgs", sample = sampleId.map(SampleId), library = libId.map(LibraryId)) >= 1 val wgsExecuted = summary.getStatsSize(runId, metricsTag, "wgs", sample = sampleId.map(SampleId), library = libId.map(LibraryId)) >= 1
val rnaExecuted = summary.getStatsSize(runId, metricsTag, "rna", sample = sampleId.map(SampleId), library = libId.map(LibraryId)) >= 1 val rnaExecuted = summary.getStatsSize(runId, metricsTag, "rna", sample = sampleId.map(SampleId), library = libId.map(LibraryId)) >= 1
...@@ -85,10 +83,10 @@ object BammetricsReport extends ReportBuilder { ...@@ -85,10 +83,10 @@ object BammetricsReport extends ReportBuilder {
ReportPage( ReportPage(
if (targets.isEmpty) List() if (targets.isEmpty) List()
else List("Targets" -> ReportPage( else List("Targets" -> Future.successful(ReportPage(
List(), List(),
targets.map(t => t -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/covstatsPlot.ssp", Map("target" -> Some(t)))), targets.map(t => t -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/covstatsPlot.ssp", Map("target" -> Some(t)))),
Map())), Map()))),
List( List(
"Summary" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp"), "Summary" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp"),
"Mapping Quality" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/mappingQuality.ssp", Map("showPlot" -> true)), "Mapping Quality" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/mappingQuality.ssp", Map("showPlot" -> true)),
...@@ -161,7 +159,7 @@ object BammetricsReport extends ReportBuilder { ...@@ -161,7 +159,7 @@ object BammetricsReport extends ReportBuilder {
plot.output = pngFile plot.output = pngFile
plot.ylabel = Some("Reads") plot.ylabel = Some("Reads")
plot.width = Some(200 + (results.size * 10)) plot.width = Some(200 + (results.size * 10))
plot.title = Some("Aligned reads") plot.title = Some("Aligned_reads")
plot.runLocal() plot.runLocal()
} }
......
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb) #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(scala.concurrent.Future)
<%@ var summary: SummaryDb %> <%@ var summary: SummaryDb %>
<%@ var indexPage: ReportPage %> <%@ var indexPage: Future[ReportPage] %>
<%@ var reportName: String %> <%@ var reportName: String %>
<%@ var page: ReportPage %> <%@ var page: ReportPage %>
<%@ var path: List[String] %> <%@ var path: List[String] %>
<%@ var args: Map[String, Any] %> <%@ var args: Map[String, Any] %>
<%@ var rootPath: String %> <%@ var rootPath: String %>
#{ #{
val iPage = Await.result(indexPage, Duration.Inf)
def createMenu(page: ReportPage, path: List[String] = Nil, first: Boolean = true): String = { def createMenu(page: ReportPage, path: List[String] = Nil, first: Boolean = true): String = {
val buffer: StringBuffer = new StringBuffer() val buffer: StringBuffer = new StringBuffer()
...@@ -15,11 +20,13 @@ ...@@ -15,11 +20,13 @@
buffer.append("<ul class=\"dropdown-menu list-group\">") buffer.append("<ul class=\"dropdown-menu list-group\">")
} }
for (subPage <- page.subPages.sortBy(_._1)) { for (subPageFuture <- page.subPages.sortBy(_._1)) {
val subPageName = subPageFuture._1
val subPage = Await.result(subPageFuture._2, Duration.Inf)
val href: String = { val href: String = {
if (path.isEmpty) rootPath + subPage._1 + "/index.html" if (path.isEmpty) rootPath + subPageName + "/index.html"
else rootPath + path.mkString("","/","/") + subPage._1 + "/index.html" else rootPath + path.mkString("","/","/") + subPageName + "/index.html"
} }
// buffer.append("<li") // buffer.append("<li")
...@@ -30,16 +37,16 @@ ...@@ -30,16 +37,16 @@
// buffer.append(createMenu(subPage._2, path ::: subPage._1 :: Nil, first = false)) // buffer.append(createMenu(subPage._2, path ::: subPage._1 :: Nil, first = false))
// buffer.append("</li>") // buffer.append("</li>")
val listSubmenu = if(subPage._2.subPages.nonEmpty) "dropdown-submenu" else "" val listSubmenu = if(subPage.subPages.nonEmpty) "dropdown-submenu" else ""
// val subMenuBadgeCount = if(subPage._2.subPages.nonEmpty && first) "<span class='badge'>%d</span>".format(subPage._2.subPages.size) else "" // val subMenuBadgeCount = if(subPage._2.subPages.nonEmpty && first) "<span class='badge'>%d</span>".format(subPage._2.subPages.size) else ""
val tabIndex = if (first) " tabindex='-1'" else "" val tabIndex = if (first) " tabindex='-1'" else ""
// val listGroupA = if(subPage._2.subPages.nonEmpty) "list-group-item" else "" // val listGroupA = if(subPage._2.subPages.nonEmpty) "list-group-item" else ""
var menuItem: String = "<li class='%s'>".format(listSubmenu) + var menuItem: String = "<li class='%s'>".format(listSubmenu) +
"<a href='%s' class='%s'%s>".format(href, "", tabIndex) + "<a href='%s' class='%s'%s>".format(href, "", tabIndex) +
"%s".format(subPage._1) + "%s".format(subPageName) +
"</a>" + "</a>" +
createMenu(subPage._2, path ::: subPage._1 :: Nil, first = false) + createMenu(subPage, path ::: subPageName :: Nil, first = false) +
"</li>" "</li>"
buffer.append(menuItem) buffer.append(menuItem)
...@@ -51,10 +58,10 @@ ...@@ -51,10 +58,10 @@
} }
def getSubPage(path:List[String]): ReportPage = { def getSubPage(path:List[String]): ReportPage = {
path.foldLeft(indexPage)((c, p) => { path.foldLeft(iPage)((c, p) => {
val foundPages = c.subPages.filter(_._1 == p) val foundPages = c.subPages.filter(_._1 == p)
require(foundPages.size == 1, "Name of page not found or duplicate is found, page:: " + p + " in path: " + path) require(foundPages.size == 1, "Name of page not found or duplicate is found, page:: " + p + " in path: " + path)
foundPages.head._2 Await.result(foundPages.head._2, Duration.Inf)
}) })
} }
}# }#
...@@ -111,9 +118,9 @@ ...@@ -111,9 +118,9 @@
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li class="root #if (path.isEmpty) active #end"> <li class="root #if (path.isEmpty) active #end">
<a class="navbar-brand" href="${rootPath}index.html">${reportName} <a class="navbar-brand" href="${rootPath}index.html">${reportName}
#if (indexPage.subPages.nonEmpty) <b class="caret"></b> #end #if (iPage.subPages.nonEmpty) <b class="caret"></b> #end
</a> </a>
${unescape(createMenu(indexPage))} ${unescape(createMenu(iPage))}
</li> </li>
</ul> </ul>
</div> </div>
...@@ -126,9 +133,9 @@ ...@@ -126,9 +133,9 @@
#if(t == 0) #if(t == 0)
<li class="root"> <li class="root">
<a href="${rootPath}index.html">Home <a href="${rootPath}index.html">Home
#if (indexPage.subPages.nonEmpty) <b class="caret"></b> #end #if (iPage.subPages.nonEmpty) <b class="caret"></b> #end
</a> </a>
${unescape(createMenu(indexPage, Nil, false))} ${unescape(createMenu(iPage, Nil, false))}
</li> </li>
#else #else
<li class="root #if (t == path.size) active #end"> <li class="root #if (t == path.size) active #end">
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
package nl.lumc.sasc.biopet.core.report package nl.lumc.sasc.biopet.core.report
import scala.concurrent.Await import scala.concurrent.{ Await, Future }
import scala.concurrent.duration.Duration import scala.concurrent.duration.Duration
/** /**
...@@ -25,46 +25,44 @@ import scala.concurrent.duration.Duration ...@@ -25,46 +25,44 @@ import scala.concurrent.duration.Duration
trait MultisampleReportBuilder extends ReportBuilder { trait MultisampleReportBuilder extends ReportBuilder {
/** Method to generate a single sample page */ /** Method to generate a single sample page */
def samplePage(sampleId: Int, args: Map[String, Any]): ReportPage def samplePage(sampleId: Int, args: Map[String, Any]): Future[ReportPage]
/** Default list of samples, can be override */ /** Default list of samples, can be override */
def samplesSections: List[(String, ReportSection)] = { def samplesSections: List[(String, ReportSection)] = {
List( List("Samples" -> ReportSection("/nl/lumc/sasc/biopet/core/report/samplesList.ssp"))
("Samples", ReportSection("/nl/lumc/sasc/biopet/core/report/samplesList.ssp"))
)
} }
/** Method to generate a single library page */ /** Method to generate a single library page */
def libraryPage(sampleId: Int, libraryId: Int, args: Map[String, Any]): ReportPage def libraryPage(sampleId: Int, libraryId: Int, args: Map[String, Any]): Future[ReportPage]
/** Default list of libraries, can be override */ /** Default list of libraries, can be override */
def librariesSections: List[(String, ReportSection)] = { def librariesSections: List[(String, ReportSection)] = {
List( List("Libraries" -> ReportSection("/nl/lumc/sasc/biopet/core/report/librariesList.ssp"))
("Libraries", ReportSection("/nl/lumc/sasc/biopet/core/report/librariesList.ssp"))
)
} }
/** Generate the samples page including a single sample page for each sample in the summary */ /** Generate the samples page including a single sample page for each sample in the summary */
def generateSamplesPage(args: Map[String, Any]): ReportPage = { def generateSamplesPage(args: Map[String, Any]): Future[ReportPage] =
val samples = Await.result(summary.getSamples(runId = Some(runId)), Duration.Inf) summary.getSamples(runId = Some(runId)).map { samples =>
val samplePages = samples.map(_.id) val samplePages = samples.map(_.id)
.map(sampleId => sampleId -> samplePage(sampleId, args ++ Map("sampleId" -> Some(sampleId)))) .map(sampleId => sampleId -> samplePage(sampleId, args ++ Map("sampleId" -> Some(sampleId)))
.toList .map(x => x.copy(subPages = x.subPages ::: "Files" -> filesPage(sampleId, None) :: Nil)))
ReportPage(samplePages.map(x => samples.find(_.id == x._1).get.name -> x._2), samplesSections, args) .toList
} ReportPage(samplePages.map(x => samples.find(_.id == x._1).get.name -> x._2), samplesSections, args)
}
/** Generate the libraries page for a single sample with a subpage for eacht library */ /** Generate the libraries page for a single sample with a subpage for eacht library */
def generateLibraryPage(args: Map[String, Any]): ReportPage = { def generateLibraryPage(args: Map[String, Any]): Future[ReportPage] = {
val sampleId = args("sampleId") match { val sampleId = args("sampleId") match {
case Some(x: Int) => x case Some(x: Int) => x
case None => throw new IllegalStateException("Sample not found") case None => throw new IllegalStateException("Sample not found")
} }
val libraries = Await.result(summary.getLibraries(runId = Some(runId), sampleId = Some(sampleId)), Duration.Inf) summary.getLibraries(runId = Some(runId), sampleId = Some(sampleId)).map { libraries =>
val libPages = libraries.map(_.id)
val libPages = libraries.map(_.id) .map(libId => libId -> libraryPage(sampleId, libId, args ++ Map("libId" -> Some(libId)))
.map(libId => libId -> libraryPage(sampleId, libId, args ++ Map("libId" -> Some(libId)))) .map(x => x.copy(subPages = x.subPages ::: "Files" -> filesPage(sampleId, libId) :: Nil)))
.toList .toList
ReportPage(libPages.map(x => libraries.find(_.id == x._1).get.name -> x._2), librariesSections, args) ReportPage(libPages.map(x => libraries.find(_.id == x._1).get.name -> x._2), librariesSections, args)
}
} }
} }
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
*/ */
package nl.lumc.sasc.biopet.core.report package nl.lumc.sasc.biopet.core.report
import scala.concurrent.Future
/** /**
* Created by pjvan_thof on 3/27/15. * Created by pjvan_thof on 3/27/15.
* *
...@@ -21,6 +23,6 @@ package nl.lumc.sasc.biopet.core.report ...@@ -21,6 +23,6 @@ package nl.lumc.sasc.biopet.core.report
* @param sections Sections for this page * @param sections Sections for this page
* @param args Arguments for this page, this arguments get passed to all section and subpages * @param args Arguments for this page, this arguments get passed to all section and subpages
*/ */
case class ReportPage(subPages: List[(String, ReportPage)], case class ReportPage(subPages: List[(String, Future[ReportPage])],
sections: List[(String, ReportSection)], sections: List[(String, ReportSection)],
args: Map[String, Any]) args: Map[String, Any])
...@@ -26,6 +26,7 @@ import nl.lumc.sasc.biopet.LastCommitHash ...@@ -26,6 +26,7 @@ import nl.lumc.sasc.biopet.LastCommitHash
import scala.collection.mutable import scala.collection.mutable
import scala.concurrent.Await import scala.concurrent.Await
import scala.concurrent.duration.Duration import scala.concurrent.duration.Duration
import scala.concurrent.ExecutionContext.Implicits.global
import scala.io.Source import scala.io.Source
/** /**
......
...@@ -16,6 +16,7 @@ package nl.lumc.sasc.biopet.core.report ...@@ -16,6 +16,7 @@ package nl.lumc.sasc.biopet.core.report
import java.io.File import java.io.File
import java.nio.file.Paths import java.nio.file.Paths
import java.sql.Date
import com.google.common.io.Files import com.google.common.io.Files
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
...@@ -23,7 +24,7 @@ import org.scalatest.Matchers ...@@ -23,7 +24,7 @@ import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test import org.testng.annotations.Test
import scala.concurrent.Await import scala.concurrent.{ Await, Future }
import scala.concurrent.duration.Duration import scala.concurrent.duration.Duration
/** /**
...@@ -37,19 +38,26 @@ class MultisampleReportBuilderTest extends TestNGSuite with Matchers { ...@@ -37,19 +38,26 @@ class MultisampleReportBuilderTest extends TestNGSuite with Matchers {
@Test @Test
def testGeneratePages(): Unit = { def testGeneratePages(): Unit = {
val builder = new MultisampleReportBuilder { val builder = new MultisampleReportBuilder {
def pipelineName = "test"
def reportName: String = "test" def reportName: String = "test"
def indexPage: ReportPage = ReportPage("Samples" -> generateSamplesPage(Map()) :: Nil, Nil, Map()) def indexPage: Future[ReportPage] = Future(ReportPage("Samples" -> generateSamplesPage(Map()) :: Nil, Nil, Map()))
def samplePage(sampleId: Int, args: Map[String, Any]): ReportPage = def samplePage(sampleId: Int, args: Map[String, Any]): Future[ReportPage] =
ReportPage("Libraries" -> generateLibraryPage(Map("sampleId" -> Some(sampleId))) :: Nil, Nil, Map()) Future(ReportPage("Libraries" -> generateLibraryPage(Map("sampleId" -> Some(sampleId))) :: Nil, Nil, Map()))
def libraryPage(sampleId: Int, libraryId: Int, args: Map[String, Any]) = ReportPage(Nil, Nil, Map()) def libraryPage(sampleId: Int, libraryId: Int, args: Map[String, Any]) = Future(ReportPage(Nil, Nil, Map()))
} }
import scala.concurrent.ExecutionContext.Implicits.global
val dbFile = File.createTempFile("summary.", ".db") val dbFile = File.createTempFile("summary.", ".db")
dbFile.deleteOnExit() dbFile.deleteOnExit()
val db = SummaryDb.openSqliteSummary(dbFile) val db = SummaryDb.openSqliteSummary(dbFile)
db.createTables() db.createTables()
Await.ready(db.createPipeline("test", 0), Duration.Inf)
Await.ready(db.createRun("test", "", "", "", new Date(System.currentTimeMillis())), Duration.Inf)
val sample = Some("sampleName") val sample = Some("sampleName")
val lib = Some("libName") val lib = Some("libName")
......
...@@ -16,6 +16,7 @@ package nl.lumc.sasc.biopet.core.report ...@@ -16,6 +16,7 @@ package nl.lumc.sasc.biopet.core.report
import java.io.File import java.io.File
import java.nio.file.Paths import java.nio.file.Paths
import java.sql.Date
import com.google.common.io.Files import com.google.common.io.Files
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
...@@ -23,7 +24,7 @@ import org.scalatest.Matchers ...@@ -23,7 +24,7 @@ import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite import org.scalatest.testng.TestNGSuite
import org.testng.annotations.{ DataProvider, Test } import org.testng.annotations.{ DataProvider, Test }
import scala.concurrent.Await import scala.concurrent.{ Await, Future }
import scala.concurrent.duration.Duration import scala.concurrent.duration.Duration
/** /**
...@@ -46,11 +47,14 @@ class ReportBuilderTest extends TestNGSuite with Matchers { ...@@ -46,11 +47,14 @@ class ReportBuilderTest extends TestNGSuite with Matchers {
@Test(dataProvider = "testGeneratePages") @Test(dataProvider = "testGeneratePages")
def testGeneratePages(sample: Option[String], lib: Option[String], nested: Boolean): Unit = { def testGeneratePages(sample: Option[String], lib: Option[String], nested: Boolean): Unit = {
val builder = new ReportBuilder { val builder = new ReportBuilder {
def pipelineName = "test"
def reportName: String = "test" def reportName: String = "test"
def indexPage: ReportPage = ReportPage( def indexPage: Future[ReportPage] = Future(ReportPage(
(if (nested) "p1" -> ReportPage(Nil, Nil, Map()) :: Nil else Nil), Nil, Map()) (if (nested) "p1" -> Future(ReportPage(Nil, Nil, Map())) :: Nil else Nil), Nil, Map()))
} }
import scala.concurrent.ExecutionContext.Implicits.global
val dbFile = File.createTempFile("summary.", ".db") val dbFile = File.createTempFile("summary.", ".db")
dbFile.deleteOnExit() dbFile.deleteOnExit()
val db = SummaryDb.openSqliteSummary(dbFile) val db = SummaryDb.openSqliteSummary(dbFile)
...@@ -61,6 +65,8 @@ class ReportBuilderTest extends TestNGSuite with Matchers { ...@@ -61,6 +65,8 @@ class ReportBuilderTest extends TestNGSuite with Matchers {
Await.result(db.createLibrary(libName, 0, sampleId), Duration.Inf) Await.result(db.createLibrary(libName, 0, sampleId), Duration.Inf)
} }
} }
Await.ready(db.createPipeline("test", 0), Duration.Inf)
Await.ready(db.createRun("test", "", "", "", new Date(System.currentTimeMillis())), Duration.Inf)
val tempDir = Files.createTempDir() val tempDir = Files.createTempDir()
tempDir.deleteOnExit() tempDir.deleteOnExit()
...@@ -77,22 +83,22 @@ class ReportBuilderTest extends TestNGSuite with Matchers { ...@@ -77,22 +83,22 @@ class ReportBuilderTest extends TestNGSuite with Matchers {
db.close() db.close()
} }
@Test // @Test
def testCountPages: Unit = { // def testCountPages: Unit = {
ReportBuilder.countPages(ReportPage(Nil, Nil, Map())) shouldBe 1 // ReportBuilder.countPages(ReportPage(Nil, Nil, Map())) shouldBe 1
ReportBuilder.countPages(ReportPage( // ReportBuilder.countPages(ReportPage(
"p1" -> ReportPage(Nil, Nil, Map()) :: Nil, // "p1" -> ReportPage(Nil, Nil, Map()) :: Nil,
Nil, Map())) shouldBe 2 // Nil, Map())) shouldBe 2
ReportBuilder.countPages(ReportPage( // ReportBuilder.countPages(ReportPage(
"p1" -> ReportPage(Nil, Nil, Map()) :: "p2" -> ReportPage(Nil, Nil, Map()) :: Nil, // "p1" -> ReportPage(Nil, Nil, Map()) :: "p2" -> ReportPage(Nil, Nil, Map()) :: Nil,
Nil, Map())) shouldBe 3 // Nil, Map())) shouldBe 3
ReportBuilder.countPages(ReportPage( // ReportBuilder.countPages(ReportPage(
"p1" -> ReportPage("p1" -> ReportPage(Nil, Nil, Map()) :: Nil, Nil, Map()) :: Nil, // "p1" -> ReportPage("p1" -> ReportPage(Nil, Nil, Map()) :: Nil, Nil, Map()) :: Nil,
Nil, Map())) shouldBe 3 // Nil, Map())) shouldBe 3
ReportBuilder.countPages(ReportPage( // ReportBuilder.countPages(ReportPage(
"p1" -> ReportPage(Nil, Nil, Map()) :: "p2" -> ReportPage("p1" -> ReportPage(Nil, Nil, Map()) :: Nil, Nil, Map()) :: Nil, // "p1" -> ReportPage(Nil, Nil, Map()) :: "p2" -> ReportPage("p1" -> ReportPage(Nil, Nil, Map()) :: Nil, Nil, Map()) :: Nil,
Nil, Map())) shouldBe 4 // Nil, Map())) shouldBe 4
} // }
@Test @Test
def testRenderTemplate: Unit = { def testRenderTemplate: Unit = {
......
...@@ -32,6 +32,7 @@ import org.testng.annotations.{ AfterClass, Test } ...@@ -32,6 +32,7 @@ import org.testng.annotations.{ AfterClass, Test }
import scala.concurrent.Await import scala.concurrent.Await
import scala.concurrent.duration.Duration import scala.concurrent.duration.Duration
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.matching.Regex import scala.util.matching.Regex
/** /**
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
package nl.lumc.sasc.biopet.tools package nl.lumc.sasc.biopet.tools
import java.io.{ PrintWriter, InputStream, File } import java.io.{ File, PrintWriter }
import java.util import java.util
import htsjdk.variant.vcf.VCFFileReader import htsjdk.variant.vcf.VCFFileReader
...@@ -24,6 +24,8 @@ import nl.lumc.sasc.biopet.utils.intervals.{ BedRecord, BedRecordList } ...@@ -24,6 +24,8 @@ import nl.lumc.sasc.biopet.utils.intervals.{ BedRecord, BedRecordList }
import scala.collection.JavaConversions._ import scala.collection.JavaConversions._
import scala.collection.mutable