Picard.scala 3.1 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
package nl.lumc.sasc.biopet.extensions.picard
17

18
19
import java.io.File

20
import nl.lumc.sasc.biopet.core.BiopetJavaCommandLineFunction
bow's avatar
bow committed
21
import org.broadinstitute.gatk.utils.commandline.{ Argument }
22

23
24
import scala.io.Source

25
26
27
abstract class Picard extends BiopetJavaCommandLineFunction {
  override def subPath = "picard" :: super.subPath

bow's avatar
bow committed
28
  @Argument(doc = "VERBOSITY", required = false)
Peter van 't Hof's avatar
Peter van 't Hof committed
29
  var verbosity: Option[String] = config("verbosity")
bow's avatar
bow committed
30
31

  @Argument(doc = "QUIET", required = false)
32
  var quiet: Boolean = config("quiet", default = false)
bow's avatar
bow committed
33
34

  @Argument(doc = "VALIDATION_STRINGENCY", required = false)
Peter van 't Hof's avatar
Peter van 't Hof committed
35
  var stringency: Option[String] = config("validationstringency")
bow's avatar
bow committed
36
37

  @Argument(doc = "COMPRESSION_LEVEL", required = false)
38
  var compression: Option[Int] = config("compressionlevel")
bow's avatar
bow committed
39
40

  @Argument(doc = "MAX_RECORDS_IN_RAM", required = false)
41
  var maxRecordsInRam: Option[Int] = config("maxrecordsinram")
bow's avatar
bow committed
42
43

  @Argument(doc = "CREATE_INDEX", required = false)
44
  var createIndex: Boolean = config("createindex", default = true)
bow's avatar
bow committed
45
46

  @Argument(doc = "CREATE_MD5_FILE", required = false)
47
  var createMd5: Boolean = config("createmd5", default = false)
bow's avatar
bow committed
48

49
  //FIXME: picard version
Peter van 't Hof's avatar
Peter van 't Hof committed
50
51
52
  //  override def versionCommand = executable + " " + javaOpts + " " + javaExecutable + " -h"
  //  override val versionRegex = """Version: (.*)""".r
  //  override val versionExitcode = List(0, 1)
bow's avatar
bow committed
53

54
  override val defaultVmem = "8G"
Peter van 't Hof's avatar
Peter van 't Hof committed
55
  memoryLimit = Option(3.0)
bow's avatar
bow committed
56

57
58
  override def commandLine = super.commandLine +
    required("TMP_DIR=" + jobTempDir) +
bow's avatar
bow committed
59
    optional("VERBOSITY=", verbosity, spaceSeparated = false) +
60
    conditional(quiet, "QUIET=TRUE") +
bow's avatar
bow committed
61
62
63
    optional("VALIDATION_STRINGENCY=", stringency, spaceSeparated = false) +
    optional("COMPRESSION_LEVEL=", compression, spaceSeparated = false) +
    optional("MAX_RECORDS_IN_RAM=", maxRecordsInRam, spaceSeparated = false) +
64
65
66
    conditional(createIndex, "CREATE_INDEX=TRUE") +
    conditional(createMd5, "CREATE_MD5_FILE=TRUE")
}
67
68

object Picard {
69
  def getMetrics(file: File): Option[(Array[String], List[Array[String]])] =
70

71
72
    if (file.exists) {
      val lines = Source.fromFile(file).getLines().toArray
73

74
75
76
77
78
79
80
81
82
83
      val start = lines.indexWhere(_.startsWith("## METRICS CLASS")) + 1
      val end = lines.indexOf("", start)

      val header = lines(start).split("\t")
      val content = (for (i <- (start + 1) until end) yield lines(i).split("\t")).toList

      Option((header, content))
    } else {
      None
    }
84
85

}