BiopetJavaCommandLineFunction.scala 2.53 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
/**
 * 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
 *
11
 * A dual licensing mode is applied. The source code within this project is freely available for non-commercial use under an AGPL
12
13
14
 * license; For commercial users or users who do not want to follow the AGPL
 * license, please contact us to obtain a separate license.
 */
15
16
package nl.lumc.sasc.biopet.core

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

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

Peter van 't Hof's avatar
Peter van 't Hof committed
23
24
25
  javaGCThreads = config("java_gc_threads", default = 4)
  javaGCHeapFreeLimit = config("java_gc_heap_freelimit", default = 10)
  javaGCTimeLimit = config("java_gc_timelimit", default = 50)
26

27
  override def defaultResidentFactor: Double = 1.5
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
  override def beforeGraph(): Unit = {
Peter van 't Hof's avatar
Peter van 't Hof committed
35
    setResources()
36
37
38
39
40
41
42
    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
43
  /** Creates command to execute extension */
44
  def cmdLine: String = {
45
    preCmdInternal()
46
47
48
    required(executable) +
      javaOpts +
      javaExecutable
49
  }
50

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

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

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