CleverCaller.scala 2.95 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
package nl.lumc.sasc.biopet.extensions.clever
16 17 18

import java.io.File

19
import nl.lumc.sasc.biopet.core.{ BiopetCommandLineFunction, Reference, Version }
Peter van 't Hof's avatar
Peter van 't Hof committed
20
import nl.lumc.sasc.biopet.utils.config.Configurable
21
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
22

23
class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction with Reference with Version {
24 25
  executable = config("exe", default = "clever")

Peter van 't Hof's avatar
Peter van 't Hof committed
26
  private lazy val versionExecutable: File = config("version_exe", default = new File(executable).getParent + "/ctk-version")
27

Peter van 't Hof's avatar
Peter van 't Hof committed
28
  override def defaultThreads = 8
Peter van 't Hof's avatar
Peter van 't Hof committed
29
  override def defaultCoreMemory = 3.0
30

31 32
  def versionCommand = versionExecutable.getAbsolutePath
  def versionRegex = """(.*)""".r
Peter van 't Hof's avatar
Peter van 't Hof committed
33
  override def versionExitcode = List(0, 1)
34 35 36 37 38 39 40

  @Input(doc = "Input file (bam)")
  var input: File = _

  @Input(doc = "Reference")
  var reference: File = _

41
  var cleverWorkDir: File = _
42 43 44

  @Output(doc = "Clever VCF output")
  lazy val outputvcf: File = {
45
    new File(cleverWorkDir, "predictions.vcf")
46 47 48 49
  }

  @Output(doc = "Clever raw output")
  lazy val outputraw: File = {
50
    new File(cleverWorkDir, "predictions.raw.txt")
51 52 53 54 55 56 57 58 59
  }

  //  var T: Option[Int] = config("T", default = defaultThreads)
  var f: Boolean = config("f", default = true) // delete work directory before running
  //  var w: String = config("w", default = workdir + "/work")
  var a: Boolean = config("a", default = false) // don't recompute AS tags
  var k: Boolean = config("k", default = false) // keep working directory
  var r: Boolean = config("r", default = false) // take read groups into account

Peter van 't Hof's avatar
Peter van 't Hof committed
60 61
  override def beforeGraph() {
    super.beforeGraph()
62
    if (cleverWorkDir == null) throw new Exception("Clever :: Workdirectory is not defined")
Peter van 't Hof's avatar
Peter van 't Hof committed
63
    if (reference == null) reference = referenceFasta()
64 65 66
  }

  def cmdLine = required(executable) +
67 68
    required("--sorted") +
    required("--use_xa") +
Peter van 't Hof's avatar
Peter van 't Hof committed
69
    optional("-T", threads) +
70 71 72 73
    conditional(f, "-f") +
    conditional(a, "-a") +
    conditional(k, "-k") +
    conditional(r, "-r") +
Peter van 't Hof's avatar
Peter van 't Hof committed
74 75
    required(input) +
    required(reference) +
76
    required(cleverWorkDir)
77 78 79
}

object CleverCaller {
Peter van 't Hof's avatar
Peter van 't Hof committed
80
  def apply(root: Configurable, input: File, svDir: File): CleverCaller = {
81 82
    val clever = new CleverCaller(root)
    clever.input = input
83
    clever.cleverWorkDir = svDir
Peter van 't Hof's avatar
Peter van 't Hof committed
84
    clever
85 86
  }
}