diff --git a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala index 4cbcfdb6881834575150db1befcc67731ebe5df8..9bc18a938701e9cc34f1402e9e2dd578ad910748 100644 --- a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala +++ b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala @@ -102,6 +102,8 @@ trait BiopetQScript extends Configurable with GatkLogging { case _ => reportClass.foreach(add(_)) } + if (logger.isDebugEnabled) WriteDependencies.writeDependencies(functions, new File(outputDir, s".log/${qSettings.runName}.deps.json")) + Logging.checkErrors() } diff --git a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/WriteDependencies.scala b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/WriteDependencies.scala new file mode 100644 index 0000000000000000000000000000000000000000..a14477be6ab37c161ad97ff1bd47f1633867a11e --- /dev/null +++ b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/WriteDependencies.scala @@ -0,0 +1,39 @@ +package nl.lumc.sasc.biopet.core + +import java.io.{File, PrintWriter} + +import nl.lumc.sasc.biopet.utils.ConfigUtils +import org.broadinstitute.gatk.queue.function.{CommandLineFunction, QFunction} +import scala.collection.mutable + +/** + * Created by pjvanthof on 06/11/15. + */ +object WriteDependencies { + val functionNames: mutable.Map[QFunction, String] = mutable.Map() + + def createFunctionNames(functions: Seq[QFunction]): Unit = { + val cache: mutable.Map[String, Int] = mutable.Map() + for (function <- functions) { + val baseName = function match { + case f: BiopetCommandLineFunction => f.configName + case f => f.getClass.getSimpleName + } + cache += baseName -> (cache.getOrElse(baseName, 0) + 1) + functionNames += function -> (s"$baseName-${cache(baseName)}") + } + } + + def writeDependencies(functions: Seq[QFunction], outputFile: File): Unit = { + createFunctionNames(functions) + val writer = new PrintWriter(outputFile) + val jobs = functionNames.map { case (f, name) => name -> Map("command" -> (f match { + case cmd: CommandLineFunction => cmd.commandLine + case _ => None + }), "intermediate" -> f.isIntermediate) } + + writer.println(ConfigUtils.mapToJson(jobs.toMap).spaces2) + writer.close() + } + +}