MultisampleReportBuilder.scala 2.52 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
package nl.lumc.sasc.biopet.core.report

/**
19
20
21
 * This trait will generate a report with added function to generate sample and library pages for those existing in the summary.
 *
 * @author pjvan_thof
22
23
 */
trait MultisampleReportBuilder extends ReportBuilder {
24
25

  /** Method to generate a single sample page */
Peter van 't Hof's avatar
Peter van 't Hof committed
26
  def samplePage(sampleId: String, args: Map[String, Any]): ReportPage
27

28
  /** Default list of samples, can be override */
29
30
31
32
33
34
  def samplesSections: List[(String, ReportSection)] = {
    List(
      ("Samples", ReportSection("/nl/lumc/sasc/biopet/core/report/samplesList.ssp"))
    )
  }

35
  /** Method to generate a single library page */
Peter van 't Hof's avatar
Peter van 't Hof committed
36
  def libraryPage(sampleId: String, libraryId: String, args: Map[String, Any]): ReportPage
37

38
  /** Default list of libraries, can be override */
39
40
41
42
43
44
  def libririesSections: List[(String, ReportSection)] = {
    List(
      ("Libraries", ReportSection("/nl/lumc/sasc/biopet/core/report/librariesList.ssp"))
    )
  }

45
  /** Generate the samples page including a single sample page for each sample in the summary */
Peter van 't Hof's avatar
Peter van 't Hof committed
46
  def generateSamplesPage(args: Map[String, Any]): ReportPage = {
47
    val samplePages = summary.samples
48
      .map(sampleId => sampleId -> samplePage(sampleId, args ++ Map("sampleId" -> Some(sampleId))))
49
      .toList
50
    ReportPage(samplePages, samplesSections, args)
51
52
  }

53
  /** Generate the libraries page for a single sample with a subpage for eacht library */
Peter van 't Hof's avatar
Peter van 't Hof committed
54
  def generateLibraryPage(args: Map[String, Any]): ReportPage = {
55
    val sampleId = args("sampleId") match {
56
      case Some(x) => x.toString
Peter van 't Hof's avatar
Peter van 't Hof committed
57
      case None    => throw new IllegalStateException("Sample not found")
58
59
60
    }

    val libPages = summary.libraries(sampleId)
61
      .map(libId => libId -> libraryPage(sampleId, libId, args ++ Map("libId" -> Some(libId))))
62
      .toList
63
    ReportPage(libPages, libririesSections, args)
64
65
  }
}