Kraken.scala 2.54 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
 * 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.
 */

package nl.lumc.sasc.biopet.extensions.kraken

import java.io.File

Peter van 't Hof's avatar
Peter van 't Hof committed
21
import nl.lumc.sasc.biopet.core.{ BiopetCommandLineFunction, Version }
Peter van 't Hof's avatar
Peter van 't Hof committed
22
import nl.lumc.sasc.biopet.utils.config.Configurable
Peter van 't Hof's avatar
Peter van 't Hof committed
23
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
24
25

/** Extension for Kraken */
Wai Yi Leung's avatar
Wai Yi Leung committed
26
class Kraken(val root: Configurable) extends BiopetCommandLineFunction with Version {
27
28
29
30

  @Input(doc = "Input: FastQ or FastA")
  var input: List[File] = _

Peter van 't Hof's avatar
Peter van 't Hof committed
31
32
33
34
35
36
37
38
39
  @Output(doc = "Unidentified reads", required = false)
  var unclassified_out: Option[File] = None

  @Output(doc = "Identified reads", required = false)
  var classified_out: Option[File] = None

  @Output(doc = "Output with hits per sequence")
  var output: File = _

40
41
42
  var db: File = config("db")

  var quick: Boolean = false
Peter van 't Hof's avatar
Peter van 't Hof committed
43
  var minHits: Option[Int] = config("min_hits")
44

Peter van 't Hof's avatar
Peter van 't Hof committed
45
  var preLoad: Boolean = config("preload", default = true)
46
47
  var paired: Boolean = config("paired", default = false)

48
  executable = config("exe", default = "kraken")
Wai Yi Leung's avatar
Wai Yi Leung committed
49

Wai Yi Leung's avatar
Wai Yi Leung committed
50
  def versionRegex = """^Kraken version ([\d\w\-\.]+)""".r
Wai Yi Leung's avatar
Wai Yi Leung committed
51

Peter van 't Hof's avatar
Peter van 't Hof committed
52
  override def versionExitcode = List(0, 1)
Wai Yi Leung's avatar
Wai Yi Leung committed
53

Wai Yi Leung's avatar
Wai Yi Leung committed
54
  def versionCommand = executable + " --version"
55

Peter van 't Hof's avatar
Peter van 't Hof committed
56
  override def defaultCoreMemory = 15.0
Wai Yi Leung's avatar
Wai Yi Leung committed
57

Peter van 't Hof's avatar
Peter van 't Hof committed
58
  override def defaultThreads = 4
59
60

  /** Sets readgroup when not set yet */
Peter van 't Hof's avatar
Peter van 't Hof committed
61
62
  override def beforeGraph(): Unit = {
    super.beforeGraph()
Peter van 't Hof's avatar
Peter van 't Hof committed
63
    //FIXME: This does not do anything
64
65
66
  }

  /** Returns command to execute */
Peter van 't Hof's avatar
Peter van 't Hof committed
67
  def cmdLine = required(executable) +
68
    required("--db", db) +
Peter van 't Hof's avatar
Peter van 't Hof committed
69
70
71
    optional("--threads", nCoresRequest) +
    conditional(quick, "--quick") +
    optional("--min_hits", minHits) +
Peter van 't Hof's avatar
Peter van 't Hof committed
72
73
    optional("--unclassified-out ", unclassified_out) +
    optional("--classified-out ", classified_out) +
74
    required("--output", output) +
Peter van 't Hof's avatar
Peter van 't Hof committed
75
76
    conditional(preLoad, "--preload") +
    conditional(paired, "--paired") +
77
    conditional(paired, "--check-names") +
Peter van 't Hof's avatar
Peter van 't Hof committed
78
    repeat(input)
79
}