BiopetJavaCommandLineFunction.scala 2.54 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
 * Biopet is built on top of GATK Queue for building bioinformatic
 * pipelines. It is mainly intended to support LUMC SHARK cluster which is running
 * SGE. But other types of HPC that are supported by GATK Queue (such as PBS)
 * should also be able to execute Biopet tools and pipelines.
 *
 * Copyright 2014 Sequencing Analysis Support Core - Leiden University Medical Center
 *
 * Contact us at: sasc@lumc.nl
 *
 * A dual licensing mode is applied. The source code within this project that are
 * not part of GATK Queue is freely available for non-commercial use under an AGPL
 * license; For commercial users or users who do not want to follow the AGPL
 * license, please contact us to obtain a separate license.
 */
16
17
package nl.lumc.sasc.biopet.core

Peter van 't Hof's avatar
Peter van 't Hof committed
18
import org.broadinstitute.gatk.queue.function.JavaCommandLineFunction
19

Peter van 't Hof's avatar
Peter van 't Hof committed
20
/** Biopet commandline class for java based programs */
21
trait BiopetJavaCommandLineFunction extends JavaCommandLineFunction with BiopetCommandLineFunction {
Peter van 't Hof's avatar
Peter van 't Hof committed
22
  executable = config("java", default = "java", submodule = "java", freeVar = false)
bow's avatar
bow committed
23

24
25
26
27
  javaGCThreads = config("java_gc_threads")
  javaGCHeapFreeLimit = config("java_gc_heap_freelimit")
  javaGCTimeLimit = config("java_gc_timelimit")

Peter van 't Hof's avatar
Peter van 't Hof committed
28
  override def defaultVmemFactor: Double = 2.0
29

Peter van 't Hof's avatar
Peter van 't Hof committed
30
  /** Constructs java opts, this adds scala threads */
Peter van 't Hof's avatar
Peter van 't Hof committed
31
  override def javaOpts = super.javaOpts +
Peter van 't Hof's avatar
Peter van 't Hof committed
32
    optional("-Dscala.concurrent.context.numThreads=", threads, spaceSeparated = false)
33

34
35
36
37
38
39
40
  override def beforeGraph(): Unit = {
    if (javaMemoryLimit.isEmpty && memoryLimit.isDefined)
      javaMemoryLimit = memoryLimit

    if (javaMainClass != null && javaClasspath.isEmpty)
      javaClasspath = JavaCommandLineFunction.currentClasspath

Peter van 't Hof's avatar
Peter van 't Hof committed
41
    //threads = getThreads(defaultThreads)
42
43
  }

Peter van 't Hof's avatar
Peter van 't Hof committed
44
  /** Creates command to execute extension */
45
  def cmdLine: String = {
46
    preCmdInternal()
47
48
49
    required(executable) +
      javaOpts +
      javaExecutable
50
  }
51

52
53
54
  def javaVersionCommand: String = executable + " -version"

  def getJavaVersion: Option[String] = {
55
    if (!BiopetCommandLineFunction.executableCache.contains(executable))
56
      preProcessExecutable()
57
    if (!BiopetCommandLineFunction.versionCache.contains(javaVersionCommand))
58
      getVersionInternal(javaVersionCommand, """java version "(.*)"""".r) match {
59
        case Some(version) => BiopetCommandLineFunction.versionCache += javaVersionCommand -> version
60
61
        case _             =>
      }
62
    BiopetCommandLineFunction.versionCache.get(javaVersionCommand)
63
64
  }

65
66
67
68
  override def setupRetry(): Unit = {
    super.setupRetry()
    javaMemoryLimit = memoryLimit
  }
69
}