From b938c1b8e3dbcecdf97f65a9a7591d58a56e3404 Mon Sep 17 00:00:00 2001 From: Peter van 't Hof <p.j.van_t_hof@lumc.nl> Date: Fri, 6 Nov 2015 21:08:37 +0100 Subject: [PATCH] Added init version of dependency debug mode --- .../lumc/sasc/biopet/core/BiopetQScript.scala | 2 + .../sasc/biopet/core/WriteDependencies.scala | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/WriteDependencies.scala 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 4cbcfdb68..9bc18a938 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 000000000..a14477be6 --- /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() + } + +} -- GitLab