GearsSingleReport.scala 2.87 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.
 */
Wai Yi Leung's avatar
Wai Yi Leung committed
15
16
package nl.lumc.sasc.biopet.pipelines.gears

17
import nl.lumc.sasc.biopet.core.report._
Wai Yi Leung's avatar
Wai Yi Leung committed
18
import nl.lumc.sasc.biopet.utils.config.Configurable
Peter van 't Hof's avatar
Peter van 't Hof committed
19
20
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.{ LibraryId, SampleId }
Wai Yi Leung's avatar
Wai Yi Leung committed
21

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

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

29
object GearsSingleReport extends ReportBuilder {
Wai Yi Leung's avatar
Wai Yi Leung committed
30

Peter van 't Hof's avatar
Peter van 't Hof committed
31
  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")
Peter van 't Hof's avatar
Peter van 't Hof committed
32
    .map(x => ExtFile("/nl/lumc/sasc/biopet/pipelines/gears/report/ext/" + x, x))
33

Peter van 't Hof's avatar
Peter van 't Hof committed
34
  def indexPage: Future[ReportPage] = Future {
Peter van 't Hof's avatar
Peter van 't Hof committed
35
36
37
    val sampleName = sampleId.flatMap(x => Await.result(summary.getSampleName(x), Duration.Inf))
    val libraryName = libId.flatMap(x => Await.result(summary.getLibraryName(x), Duration.Inf))

Peter van 't Hof's avatar
Peter van 't Hof committed
38
39
    val krakenExecuted = Await.result(summary.getStatsSize(runId, "gearskraken", "krakenreport", sample = sampleId.map(SampleId), library = libId.map(LibraryId)), Duration.Inf) == 1
    val centrifugeExecuted = Await.result(summary.getStatsSize(runId, "gearscentrifuge", "centrifuge_report", sample = sampleId.map(SampleId), library = libId.map(LibraryId)), Duration.Inf) == 1
Peter van 't Hof's avatar
Peter van 't Hof committed
40

Wai Yi Leung's avatar
Wai Yi Leung committed
41
    ReportPage(
Peter van 't Hof's avatar
Peter van 't Hof committed
42
      List(
Peter van 't Hof's avatar
Peter van 't Hof committed
43
44
        "Versions" -> Future(ReportPage(List(),
          List(("Executables" -> ReportSection("/nl/lumc/sasc/biopet/core/report/executables.ssp"))), Map()))
Wai Yi Leung's avatar
Wai Yi Leung committed
45
      ),
Peter van 't Hof's avatar
Peter van 't Hof committed
46
      List("Gears intro" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/gearsSingleFront.ssp")) ++
Peter van 't Hof's avatar
Peter van 't Hof committed
47
48
49
50
51
        (if (krakenExecuted) List("Kraken analysis" ->
          ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp"))
        else Nil) ++
        (if (centrifugeExecuted) List("Centrifuge analysis" ->
          ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp",
52
            Map("summaryModuleTag" -> "gearscentrifuge", "summaryStatsTag" -> "centrifuge_unique_report", "centrifugeTag" -> Some("centrifuge"))))
Peter van 't Hof's avatar
Peter van 't Hof committed
53
        else Nil),
Wai Yi Leung's avatar
Wai Yi Leung committed
54
55
56
57
58
59
60
      pageArgs
    )
  }

  def reportName = "Gears :: Metagenomics Report"

}