CleverCaller.scala 2.98 KB
Newer Older
Peter van 't Hof's avatar
Peter van 't Hof committed
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.
 */
16
package nl.lumc.sasc.biopet.extensions.clever
17
18
19

import java.io.File

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

Peter van 't Hof's avatar
Peter van 't Hof committed
24
class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction with Reference {
25
26
  executable = config("exe", default = "clever")

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

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

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

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

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

Peter van 't Hof's avatar
Peter van 't Hof committed
42
  protected def workDir: File = new File(cwd, "work")
Peter van 't Hof's avatar
Peter van 't Hof committed
43
  var cwd: File = _
44
45
46

  @Output(doc = "Clever VCF output")
  lazy val outputvcf: File = {
Peter van 't Hof's avatar
Peter van 't Hof committed
47
    new File(cwd, "predictions.vcf")
48
49
50
51
  }

  @Output(doc = "Clever raw output")
  lazy val outputraw: File = {
Peter van 't Hof's avatar
Peter van 't Hof committed
52
    new File(workDir, "predictions.raw.txt")
53
54
55
56
57
58
59
60
61
  }

  //  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
62
63
  override def beforeGraph() {
    super.beforeGraph()
Peter van 't Hof's avatar
Peter van 't Hof committed
64
    if (workDir == null) throw new Exception("Clever :: Workdirectory is not defined")
Peter van 't Hof's avatar
Peter van 't Hof committed
65
    if (reference == null) reference = referenceFasta()
66
67
68
69
70
  }

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

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