MappingReport.scala 3.64 KB
Newer Older
Peter van 't Hof's avatar
Peter van 't Hof committed
1
2
3
4
5
6
7
8
9
10
/**
 * 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
 *
11
 * A dual licensing mode is applied. The source code within this project is freely available for non-commercial use under an AGPL
Peter van 't Hof's avatar
Peter van 't Hof committed
12
13
14
 * license; For commercial users or users who do not want to follow the AGPL
 * license, please contact us to obtain a separate license.
 */
15
16
package nl.lumc.sasc.biopet.pipelines.mapping

Peter van 't Hof's avatar
Peter van 't Hof committed
17
import nl.lumc.sasc.biopet.utils.config.Configurable
18
import nl.lumc.sasc.biopet.core.report._
19
20
21
import nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport
import nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport

Peter van 't Hof's avatar
Peter van 't Hof committed
22
23
24
import scala.concurrent.Await
import scala.concurrent.duration.Duration

Peter van 't Hof's avatar
Peter van 't Hof committed
25
class MappingReport(val parent: Configurable) extends ReportBuilderExtension {
26
  def builder = MappingReport
27
28
29
}

/**
Peter van 't Hof's avatar
Peter van 't Hof committed
30
31
 * Object ot generate report for [[Mapping]]
 *
32
33
34
35
36
37
 * Created by pjvanthof on 24/06/15.
 */
object MappingReport extends ReportBuilder {
  /** Name of report */
  val reportName = "Mapping Report"

Peter van 't Hof's avatar
Peter van 't Hof committed
38
39
  override def extFiles = super.extFiles ++ List("js/gears.js", "js/krona-2.0.js", "img/krona/loading.gif", "img/krona/hidden.png", "img/krona/favicon.ico")
    .map(x => ExtFile("/nl/lumc/sasc/biopet/pipelines/gears/report/ext/" + x, x))
40

Peter van 't Hof's avatar
Peter van 't Hof committed
41
42
43
44
  summary.getStatsSize(runId, Right("gears"), Some(Right("krakenreport")),
    sample = sampleId.map(Left(_)), library = libId.map(Left(_)))
  def krakenExecuted: Boolean = Await.result(summary.getStatsSize(runId, Right("gears"), Some(Right("krakenreport")),
    sample = sampleId.map(Left(_)), library = libId.map(Left(_))), Duration.Inf) >= 1
45

46
47
  /** Root page for single BamMetrcis report */
  def indexPage = {
Peter van 't Hof's avatar
Peter van 't Hof committed
48
49
50
51
    val mappingSettings = summary.getSettingKeys(runId, Right("mapping"), None, sample = sampleId.map(Left(_)), library = libId.map(Left(_)),
      keyValues = Map("skip_flexiprep" -> List("skip_flexiprep"), "skip_metrics" -> List("skip_metrics")))
    val skipFlexiprep = mappingSettings.get("skip_flexiprep").flatten.getOrElse(false) == true
    val bamMetricsPage = if (mappingSettings.get("skip_metrics").flatten.getOrElse(false) == true) {
52
53
54
55
56
57
58
59
60
61
62
      Some(BammetricsReport.bamMetricsPage(summary, sampleId, libId))
    } else None
    ReportPage((if (skipFlexiprep) Nil else List("QC" -> FlexiprepReport.flexiprepPage)) :::
      bamMetricsPage.map(_.subPages).getOrElse(Nil) ::: List(
        "Versions" -> ReportPage(List(), List("Executables" -> ReportSection("/nl/lumc/sasc/biopet/core/report/executables.ssp"
        )), Map()),
        "Files" -> ReportPage(List(), (if (skipFlexiprep) Nil else List(
          "Input fastq files" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepInputfiles.ssp"),
          "After QC fastq files" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepOutputfiles.ssp"))) :::
          List("Bam files per lib" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/mapping/outputBamfiles.ssp", Map("sampleLevel" -> false))
          ), Map())
63
64
65
66
67
      ) :::
        (if (krakenExecuted) List("Gears - Metagenomics" -> ReportPage(List(), List(
          "Sunburst analysis" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/gearsSunburst.ssp"
          )), Map()))
        else Nil), List(
68
      "Report" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/mapping/mappingFront.ssp")
69
    ) ::: bamMetricsPage.map(_.sections).getOrElse(Nil),
70
71
72
73
      Map()
    )
  }
}