MappingReport.scala 3.1 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
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
21
22
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._
23

Peter van 't Hof's avatar
Peter van 't Hof committed
24
import scala.concurrent.{ Await, Future }
Peter van 't Hof's avatar
Peter van 't Hof committed
25
26
import scala.concurrent.duration.Duration

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

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

40
41
  def pipelineName = "mapping"

Peter van 't Hof's avatar
Peter van 't Hof committed
42
43
  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))
44

Peter van 't Hof's avatar
Peter van 't Hof committed
45
46
  def krakenExecuted: Boolean = Await.result(summary.getStatsSize(runId, "gears", "krakenreport",
    sample = sampleId.map(SampleId), library = libId.map(LibraryId)), Duration.Inf) >= 1
47

48
  /** Root page for single BamMetrcis report */
Peter van 't Hof's avatar
Peter van 't Hof committed
49
  def indexPage: Future[ReportPage] = Future {
Peter van 't Hof's avatar
Peter van 't Hof committed
50
51
    val mappingSettings = summary.getSettingKeys(runId, "mapping", NoModule,
      sample = sampleId.map(SampleId).getOrElse(NoSample), library = libId.map(LibraryId).getOrElse(NoLibrary),
Peter van 't Hof's avatar
Peter van 't Hof committed
52
53
54
      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) {
55
56
57
      Some(BammetricsReport.bamMetricsPage(summary, sampleId, libId))
    } else None
    ReportPage((if (skipFlexiprep) Nil else List("QC" -> FlexiprepReport.flexiprepPage)) :::
58
      bamMetricsPage.map(_.subPages).getOrElse(Nil) :::
59
      (if (krakenExecuted) List("Gears - Metagenomics" -> Future.successful(ReportPage(List(), List(
Peter van 't Hof's avatar
Peter van 't Hof committed
60
61
62
        "Sunburst analysis" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/gearsSunburst.ssp"
        )), Map())))
      else Nil), List(
63
      "Report" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/mapping/mappingFront.ssp")
64
    ) ::: bamMetricsPage.map(_.sections).getOrElse(Nil),
65
66
67
68
      Map()
    )
  }
}