BiopetQScript.scala 1.43 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
6
import nl.lumc.sasc.biopet.core.config.Configurable
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

10
trait BiopetQScript extends Configurable {
11

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

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

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

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

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

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

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

45
}