From ee5ed3c8f87f708bd4541c8795264d4787ce6791 Mon Sep 17 00:00:00 2001
From: Peter van 't Hof <p.j.van_t_hof@lumc.nl>
Date: Tue, 30 Jun 2015 15:47:35 +0200
Subject: [PATCH] Adding more information for each executable to summary

---
 .../core/BiopetCommandLineFunctionTrait.scala       | 12 +++++++++---
 .../biopet/core/BiopetJavaCommandLineFunction.scala | 13 +++++++++++++
 .../sasc/biopet/core/summary/WriteSummary.scala     |  6 ++++--
 3 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunctionTrait.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunctionTrait.scala
index f6de8b3e4..614aed759 100644
--- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunctionTrait.scala
+++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunctionTrait.scala
@@ -156,7 +156,13 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
   protected val versionExitcode = List(0)
 
   /** Executes the version command */
-  private def getVersionInternal: Option[String] = {
+  private[core] def getVersionInternal(): Option[String] = {
+    if (versionCommand == null || versionRegex == null) None
+    else getVersionInternal(versionCommand, versionRegex)
+  }
+
+  /** Executes the version command */
+  private[core] def getVersionInternal(versionCommand: String, versionRegex: Regex): Option[String] = {
     if (versionCommand == null || versionRegex == null) return None
     val exe = new File(versionCommand.trim.split(" ")(0))
     if (!exe.exists()) return None
@@ -221,7 +227,7 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
 /** stores global caches */
 object BiopetCommandLineFunctionTrait {
   import scala.collection.mutable.Map
-  private val versionCache: Map[String, String] = Map()
+  private[core] val versionCache: Map[String, String] = Map()
   private[core] val executableMd5Cache: Map[String, String] = Map()
-  private val executableCache: Map[String, String] = Map()
+  private[core] val executableCache: Map[String, String] = Map()
 }
diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetJavaCommandLineFunction.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetJavaCommandLineFunction.scala
index cd26c269d..d0d4496e9 100644
--- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetJavaCommandLineFunction.scala
+++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetJavaCommandLineFunction.scala
@@ -37,6 +37,19 @@ trait BiopetJavaCommandLineFunction extends JavaCommandLineFunction with BiopetC
     return cmd
   }
 
+  def javaVersionCommand: String = executable + " -version"
+
+  def getJavaVersion: Option[String] = {
+    if (!BiopetCommandLineFunctionTrait.executableCache.contains(executable))
+      preProcesExecutable
+    if (!BiopetCommandLineFunctionTrait.versionCache.contains(javaVersionCommand))
+      getVersionInternal(javaVersionCommand, """java version "(.*)"""".r) match {
+        case Some(version) => BiopetCommandLineFunctionTrait.versionCache += javaVersionCommand -> version
+        case _             =>
+      }
+    BiopetCommandLineFunctionTrait.versionCache.get(javaVersionCommand)
+  }
+
   override def setupRetry(): Unit = {
     super.setupRetry()
     javaMemoryLimit = memoryLimit
diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/WriteSummary.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/WriteSummary.scala
index f28b4db04..5498c6139 100644
--- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/WriteSummary.scala
+++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/WriteSummary.scala
@@ -74,11 +74,13 @@ class WriteSummary(val root: Configurable) extends InProcessFunction with Config
             case f: BiopetJavaCommandLineFunction => {
               f.configName -> Map("version" -> f.getVersion.getOrElse(None),
                 "java_md5" -> BiopetCommandLineFunctionTrait.executableMd5Cache.getOrElse(f.executable, None),
-                "jar_md5" -> SummaryQScript.md5sumCache.getOrElse(f.jarFile, None))
+                "java_version" -> f.getJavaVersion,
+                "jar_path" -> f.jarFile)
             }
             case f: BiopetCommandLineFunction => {
               f.configName -> Map("version" -> f.getVersion.getOrElse(None),
-                "md5" -> BiopetCommandLineFunctionTrait.executableMd5Cache.getOrElse(f.executable, None))
+                "md5" -> BiopetCommandLineFunctionTrait.executableMd5Cache.getOrElse(f.executable, None),
+                "path" -> f.executable)
             }
             case _ => throw new IllegalStateException("This should not be possible")
           }
-- 
GitLab