CoverageStats.scala 2.16 KB
Newer Older
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.
 */
Peter van 't Hof's avatar
Peter van 't Hof committed
16
package nl.lumc.sasc.biopet.pipelines.bammetrics.scripts
17

Peter van 't Hof's avatar
Peter van 't Hof committed
18
19
import java.io.File

20
import nl.lumc.sasc.biopet.core.extensions.PythonCommandLineFunction
Peter van 't Hof's avatar
Peter van 't Hof committed
21
import nl.lumc.sasc.biopet.utils.config.Configurable
22
import nl.lumc.sasc.biopet.core.summary.Summarizable
23
import nl.lumc.sasc.biopet.utils.ConfigUtils
bow's avatar
bow committed
24
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
25

26
class CoverageStats(val root: Configurable) extends PythonCommandLineFunction with Summarizable {
27
  setPythonScript("bedtools_cov_stats.py")
bow's avatar
bow committed
28

29
  @Input(doc = "Input file", required = false)
30
  var input: File = _
bow's avatar
bow committed
31
32

  @Output(doc = "output File")
33
  var output: File = _
bow's avatar
bow committed
34
35

  @Output(doc = "plot File (png)")
36
  var plot: File = _
Peter van 't Hof's avatar
Peter van 't Hof committed
37

38
39
40
  var title: Option[String] = None
  var subTitle: Option[String] = None

Peter van 't Hof's avatar
Peter van 't Hof committed
41
  override def defaultCoreMemory = 9.0
bow's avatar
bow committed
42

43
  def cmdLine = getPythonCommand +
44
    (if (inputAsStdin) " - " else required(input)) +
45
46
47
48
    required("--plot", plot) +
    optional("--title", title) +
    optional("--subtitle", subTitle) +
    " > " + required(output)
49

50
  def summaryFiles: Map[String, File] = Map("plot" -> plot)
51

52
53
54
  def summaryStats: Map[String, Any] = {
    ConfigUtils.fileToConfigMap(output)
  }
55
56
57
}

object CoverageStats {
58
  def apply(root: Configurable, outputDir: File, name: String): CoverageStats = {
59
    val coverageStats = new CoverageStats(root)
60
61
    coverageStats.output = new File(outputDir, name + ".stats")
    coverageStats.plot = new File(outputDir, name + ".stats.png")
62
    coverageStats
63
64
  }
}