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

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

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

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

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

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

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

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

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

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

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

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

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