SambambaMerge.scala 1.93 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.extensions.sambamba

Peter van 't Hof's avatar
Peter van 't Hof committed
17 18
import java.io.File

Peter van 't Hof's avatar
Peter van 't Hof committed
19
import nl.lumc.sasc.biopet.utils.config.Configurable
20 21
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }

Peter van 't Hof's avatar
Peter van 't Hof committed
22
/** Extension for sambemba merge  */
Peter van 't Hof's avatar
Peter van 't Hof committed
23
class SambambaMerge(val parent: Configurable) extends Sambamba {
24 25 26 27 28 29 30 31

  @Input(doc = "Bam File[s]")
  var input: List[File] = Nil

  @Output(doc = "Output merged bam PATH")
  var output: File = _

  // @doc: compression_level 6 is average, 0 = no compression, 9 = best
Peter van 't Hof's avatar
Peter van 't Hof committed
32 33 34 35 36 37 38
  val compressionLevel: Option[Int] = config("compression_level")
  val header: Boolean = config("header", default = false)
  val showProgress: Boolean = config("show-progress", default = true)
  val filter: Option[String] = config("filter")

  override def defaultThreads = 4
  override def defaultCoreMemory = 4.0
Peter van 't Hof's avatar
Peter van 't Hof committed
39

Peter van 't Hof's avatar
Peter van 't Hof committed
40 41 42 43 44 45 46
  @Output
  private var indexOutput: File = _

  override def beforeGraph(): Unit = {
    indexOutput = new File(output + ".bai")
  }

Peter van 't Hof's avatar
Peter van 't Hof committed
47
  /** Returns command to execute */
48
  def cmdLine: String = required(executable) +
Peter van 't Hof's avatar
Peter van 't Hof committed
49 50
    required("merge") +
    optional("-t", nCoresRequest) +
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
51
    optional("-l", compressionLevel) +
Peter van 't Hof's avatar
Peter van 't Hof committed
52 53 54
    optional("-F", filter) +
    conditional(header, "--header") +
    conditional(showProgress, "--show-progress") +
Peter van 't Hof's avatar
Peter van 't Hof committed
55
    required(output) +
56
    repeat(input)
57
}