Cnmops.scala 2.15 KB
Newer Older
Wai Yi Leung's avatar
Wai Yi Leung committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/**
 * 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 2015 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.
 */
package nl.lumc.sasc.biopet.extensions

import java.io.File
19 20 21

import nl.lumc.sasc.biopet.core.extensions.RscriptCommandLineFunction
import nl.lumc.sasc.biopet.utils.config.Configurable
Peter van 't Hof's avatar
Peter van 't Hof committed
22
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
Wai Yi Leung's avatar
Wai Yi Leung committed
23 24 25 26 27

/**
 * Wrapper for the Cnmops command line tool.
 * Written based on Cnmops version v2.2.1.
 */
Wai Yi Leung's avatar
Wai Yi Leung committed
28
class Cnmops(val root: Configurable) extends RscriptCommandLineFunction {
Wai Yi Leung's avatar
Wai Yi Leung committed
29

Peter van 't Hof's avatar
Peter van 't Hof committed
30
  protected var script: File = new File("/nl/lumc/sasc/biopet/extensions/cnmops.R")
31

Wai Yi Leung's avatar
Wai Yi Leung committed
32 33 34
  @Input(doc = "Input file BAM", required = true)
  var input: List[File] = List()

Peter van 't Hof's avatar
Peter van 't Hof committed
35
  // output files, computed automatically from output directory
Wai Yi Leung's avatar
Wai Yi Leung committed
36
  @Output(doc = "Output CNV file")
Peter van 't Hof's avatar
Peter van 't Hof committed
37
  private lazy val outputCnv: File = {
Peter van 't Hof's avatar
Peter van 't Hof committed
38
    require(outputDir == null, "Unexpected error when trying to set cn.MOPS CNV output")
Peter van 't Hof's avatar
Peter van 't Hof committed
39
    new File(outputDir, "cnv.txt")
Wai Yi Leung's avatar
Wai Yi Leung committed
40
  }
Peter van 't Hof's avatar
Peter van 't Hof committed
41

Wai Yi Leung's avatar
Wai Yi Leung committed
42
  @Output(doc = "Output CNR file")
Peter van 't Hof's avatar
Peter van 't Hof committed
43
  private lazy val outputCnr: File = {
Peter van 't Hof's avatar
Peter van 't Hof committed
44
    require(outputDir == null, "Unexpected error when trying to set cn.MOPS CNR output")
Peter van 't Hof's avatar
Peter van 't Hof committed
45
    new File(outputDir, "cnr.txt")
Wai Yi Leung's avatar
Wai Yi Leung committed
46 47 48
  }

  /** write all output files to this directory [./] */
Peter van 't Hof's avatar
Peter van 't Hof committed
49
  var outputDir: String = _
Wai Yi Leung's avatar
Wai Yi Leung committed
50 51 52

  override def beforeGraph = {
    super.beforeGraph
Peter van 't Hof's avatar
Peter van 't Hof committed
53 54
    require(!outputDir.isEmpty, "Outputdir for cn.MOPS should not be empty")
    require(input.length >= 2, "Please supply at least 2 BAM files for cn.MOPS")
Wai Yi Leung's avatar
Wai Yi Leung committed
55
  }
Wai Yi Leung's avatar
Wai Yi Leung committed
56

Peter van 't Hof's avatar
Peter van 't Hof committed
57 58
  override def cmdLine = super.cmdLine +
    required(input.foreach(f => f.getAbsolutePath).toString.mkString(" "))
Wai Yi Leung's avatar
Wai Yi Leung committed
59
}