CleverCaller.scala 2.27 KB
Newer Older
1
package nl.lumc.sasc.biopet.extensions.clever
2 3 4

import java.io.File

Peter van 't Hof's avatar
Peter van 't Hof committed
5
import nl.lumc.sasc.biopet.core.{ Reference, BiopetCommandLineFunction }
6
import nl.lumc.sasc.biopet.core.config.Configurable
7
import org.broadinstitute.gatk.utils.commandline.{ Argument, Input, Output }
8

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

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

Peter van 't Hof's avatar
Peter van 't Hof committed
14
  override def defaultThreads = 8
Peter van 't Hof's avatar
Peter van 't Hof committed
15
  override def defaultCoreMemory = 3.0
16

Peter van 't Hof's avatar
Peter van 't Hof committed
17
  override def versionCommand = versionExecutable.getAbsolutePath
Peter van 't Hof's avatar
Peter van 't Hof committed
18 19
  override def versionRegex = """(.*)""".r
  override def versionExitcode = List(0, 1)
20 21 22 23 24 25 26

  @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
27
  protected def workDir: File = new File(cwd, "work")
Peter van 't Hof's avatar
Peter van 't Hof committed
28
  var cwd: File = _
29 30 31

  @Output(doc = "Clever VCF output")
  lazy val outputvcf: File = {
Peter van 't Hof's avatar
Peter van 't Hof committed
32
    new File(cwd, "predictions.vcf")
33 34 35 36
  }

  @Output(doc = "Clever raw output")
  lazy val outputraw: File = {
Peter van 't Hof's avatar
Peter van 't Hof committed
37
    new File(workDir, "predictions.raw.txt")
38 39 40 41 42 43 44 45 46
  }

  //  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
47 48
  override def beforeGraph() {
    super.beforeGraph()
Peter van 't Hof's avatar
Peter van 't Hof committed
49
    if (workDir == null) throw new Exception("Clever :: Workdirectory is not defined")
Peter van 't Hof's avatar
Peter van 't Hof committed
50
    if (reference == null) reference = referenceFasta()
51 52 53 54 55
  }

  def cmdLine = required(executable) +
    " --sorted " +
    " --use_xa " +
Peter van 't Hof's avatar
Peter van 't Hof committed
56
    optional("-T", threads) +
57 58 59 60
    conditional(f, "-f") +
    conditional(a, "-a") +
    conditional(k, "-k") +
    conditional(r, "-r") +
Peter van 't Hof's avatar
Peter van 't Hof committed
61 62 63
    required(input) +
    required(reference) +
    required(workDir)
64 65 66
}

object CleverCaller {
Peter van 't Hof's avatar
Peter van 't Hof committed
67
  def apply(root: Configurable, input: File, svDir: File): CleverCaller = {
68 69 70
    val clever = new CleverCaller(root)
    clever.input = input
    clever.cwd = svDir
Peter van 't Hof's avatar
Peter van 't Hof committed
71
    clever
72 73
  }
}