BiopetQScript.scala 2.04 KB
Newer Older
1
2
3
package nl.lumc.sasc.biopet.core

import java.io.File
Peter van 't Hof's avatar
Peter van 't Hof committed
4
import java.io.PrintWriter
Peter van 't Hof's avatar
Peter van 't Hof committed
5
import nl.lumc.sasc.biopet.core.config.{ Config, Configurable }
Peter van 't Hof's avatar
Peter van 't Hof committed
6
import org.broadinstitute.gatk.utils.commandline.Argument
Peter van 't Hof's avatar
Peter van 't Hof committed
7
8
import org.broadinstitute.gatk.queue.QSettings
import org.broadinstitute.gatk.queue.function.QFunction
9
import org.broadinstitute.gatk.queue.function.scattergather.ScatterGatherableFunction
10
import org.broadinstitute.gatk.queue.util.{ Logging => GatkLogging }
11

12
trait BiopetQScript extends Configurable with GatkLogging {
13

14
  @Argument(doc = "JSON config file(s)", fullName = "config_file", shortName = "config", required = false)
15
  val configfiles: List[File] = Nil
bow's avatar
bow committed
16

17
  @Argument(doc = "Output directory", fullName = "output_directory", shortName = "outDir", required = true)
18
  var outputDir: String = _
bow's avatar
bow committed
19

20
21
  @Argument(doc = "Disable all scatters", shortName = "DSC", required = false)
  var disableScatterDefault: Boolean = false
22

bow's avatar
bow committed
23
24
  var outputFiles: Map[String, File] = Map()

Peter van 't Hof's avatar
Peter van 't Hof committed
25
  var qSettings: QSettings
bow's avatar
bow committed
26

27
28
  def init
  def biopetScript
bow's avatar
bow committed
29

30
  var functions: Seq[QFunction]
Peter van 't Hof's avatar
Peter van 't Hof committed
31

32
  final def script() {
Peter van 't Hof's avatar
Peter van 't Hof committed
33
    if (!outputDir.endsWith("/")) outputDir += "/"
34
35
    init
    biopetScript
36
37
38
39
40

    if (disableScatterDefault) for (function <- functions) function match {
      case f: ScatterGatherableFunction => f.scatterCount = 1
      case _                            =>
    }
41
    for (function <- functions) function match {
Peter van 't Hof's avatar
Peter van 't Hof committed
42
43
      case f: BiopetCommandLineFunctionTrait => f.afterGraph
      case _                                 =>
44
    }
Peter van 't Hof's avatar
Peter van 't Hof committed
45
    val configReport = Config.global.getReport
Peter van 't Hof's avatar
Peter van 't Hof committed
46
    val configReportFile = new File(outputDir + qSettings.runName + ".configreport.txt")
Peter van 't Hof's avatar
Peter van 't Hof committed
47
    configReportFile.getParentFile.mkdir
Peter van 't Hof's avatar
Peter van 't Hof committed
48
49
50
51
    val writer = new PrintWriter(configReportFile)
    writer.write(configReport)
    writer.close()
    for (line <- configReport.split("\n")) logger.debug(line)
52
  }
bow's avatar
bow committed
53

54
  def add(functions: QFunction*) // Gets implemeted at org.broadinstitute.sting.queue.QScript
bow's avatar
bow committed
55
  def add(function: QFunction, isIntermediate: Boolean = false) {
56
57
58
    function.isIntermediate = isIntermediate
    add(function)
  }
bow's avatar
bow committed
59

60
}