MultisampleReportBuilderTest.scala 2.38 KB
Newer Older
Peter van 't Hof's avatar
Peter van 't Hof committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
 * Biopet is built on top of GATK Queue for building bioinformatic
 * pipelines. It is mainly intended to support LUMC SHARK cluster which is running
 * SGE. But other types of HPC that are supported by GATK Queue (such as PBS)
 * should also be able to execute Biopet tools and pipelines.
 *
 * Copyright 2014 Sequencing Analysis Support Core - Leiden University Medical Center
 *
 * Contact us at: sasc@lumc.nl
 *
 * A dual licensing mode is applied. The source code within this project that are
 * not part of GATK Queue is freely available for non-commercial use under an AGPL
 * license; For commercial users or users who do not want to follow the AGPL
 * license, please contact us to obtain a separate license.
 */
16
17
18
19
20
21
22
23
24
25
26
package nl.lumc.sasc.biopet.core.report

import java.io.File
import java.nio.file.Paths

import com.google.common.io.Files
import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test

/**
Peter van 't Hof's avatar
Peter van 't Hof committed
27
28
 * Created by pjvanthof on 24/02/16.
 */
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class MultisampleReportBuilderTest extends TestNGSuite with Matchers {
  private def resourcePath(p: String): String = {
    Paths.get(getClass.getResource(p).toURI).toString
  }

  @Test
  def testGeneratePages(): Unit = {
    val builder = new MultisampleReportBuilder {
      def reportName: String = "test"
      def indexPage: ReportPage = ReportPage("Samples" -> generateSamplesPage(Map()) :: Nil, Nil, Map())

      def samplePage(sampleId: String, args: Map[String, Any]): ReportPage =
        ReportPage("Libraries" -> generateLibraryPage(Map("sampleId" -> Some(sampleId))) :: Nil, Nil, Map())

      def libraryPage(sampleId: String, libraryId: String, args: Map[String, Any]) = ReportPage(Nil, Nil, Map())
    }

    val tempDir = Files.createTempDir()
    tempDir.deleteOnExit()
    val args = Array("-s", resourcePath("/empty_summary.json"), "-o", tempDir.getAbsolutePath)
    builder.main(args)
    builder.extFiles.foreach(x => new File(tempDir, "ext" + File.separator + x.targetPath) should exist)
Peter van 't Hof's avatar
Peter van 't Hof committed
51
52
53
54
55
56
57
58

    def createFile(path: String*) = new File(tempDir, path.mkString(File.separator))

    createFile("index.html") should exist
    createFile("Samples", "index.html") should exist
    createFile("Samples", "sampleName", "index.html") should exist
    createFile("Samples", "sampleName", "Libraries", "index.html") should exist
    createFile("Samples", "sampleName", "Libraries", "libName", "index.html") should exist
59
60
61
  }

}