BiopetQScript.scala 1.31 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._
Peter van 't Hof's avatar
Peter van 't Hof committed
6
7
8
import org.broadinstitute.gatk.utils.commandline._
import org.broadinstitute.gatk.queue.QSettings
import org.broadinstitute.gatk.queue.function.QFunction
9

10
trait BiopetQScript extends Configurable {
bow's avatar
bow committed
11
  @Argument(doc = "Config Json file", shortName = "config", required = false)
12
  val configfiles: List[File] = Nil
bow's avatar
bow committed
13
14

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

  var outputFiles: Map[String, File] = Map()

Peter van 't Hof's avatar
Peter van 't Hof committed
19
  var qSettings: QSettings
bow's avatar
bow committed
20

21
22
  def init
  def biopetScript
bow's avatar
bow committed
23

24
  final def script() {
Peter van 't Hof's avatar
Peter van 't Hof committed
25
26
    for (file <- configfiles) globalConfig.loadConfigFile(file)
    if (!outputDir.endsWith("/")) outputDir += "/"
27
28
    init
    biopetScript
Peter van 't Hof's avatar
Peter van 't Hof committed
29
30
31
32
33
34
    val configReport = globalConfig.getReport
    val configReportFile = new File(outputDir + qSettings.runName + ".configreport.txt")
    val writer = new PrintWriter(configReportFile)
    writer.write(configReport)
    writer.close()
    for (line <- configReport.split("\n")) logger.debug(line)
35
  }
bow's avatar
bow committed
36

37
  def add(functions: QFunction*) // Gets implemeted at org.broadinstitute.sting.queue.QScript
bow's avatar
bow committed
38
  def add(function: QFunction, isIntermediate: Boolean = false) {
39
40
41
    function.isIntermediate = isIntermediate
    add(function)
  }
bow's avatar
bow committed
42

43
}