Breakdancer.scala 2.73 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.breakdancer
17
18
19

import java.io.File

20
import nl.lumc.sasc.biopet.core.config.Configurable
Peter van 't Hof's avatar
Peter van 't Hof committed
21
import nl.lumc.sasc.biopet.core.{ Reference, BiopetQScript, PipelineCommand }
22
import org.broadinstitute.gatk.queue.QScript
23
24

/// Breakdancer is actually a mini pipeline executing binaries from the breakdancer package
Peter van 't Hof's avatar
Peter van 't Hof committed
25
class Breakdancer(val root: Configurable) extends QScript with BiopetQScript with Reference {
26
  def this() = this(null)
Wai Yi Leung's avatar
Wai Yi Leung committed
27

28
29
30
31
  @Input(doc = "Input file (bam)")
  var input: File = _

  @Argument(doc = "Work directory")
Peter van 't Hof's avatar
Peter van 't Hof committed
32
  var workDir: File = _
Wai Yi Leung's avatar
Wai Yi Leung committed
33
34
35

  var deps: List[File] = Nil

36
37
  @Output(doc = "Breakdancer config")
  lazy val configfile: File = {
Peter van 't Hof's avatar
Peter van 't Hof committed
38
    new File(workDir, input.getName.substring(0, input.getName.lastIndexOf(".bam")) + ".breakdancer.cfg")
39
  }
40
41
  @Output(doc = "Breakdancer raw output")
  lazy val outputraw: File = {
Peter van 't Hof's avatar
Peter van 't Hof committed
42
    new File(workDir, input.getName.substring(0, input.getName.lastIndexOf(".bam")) + ".breakdancer.tsv")
43
  }
Wai Yi Leung's avatar
Wai Yi Leung committed
44
45
  @Output(doc = "Breakdancer VCF output")
  lazy val outputvcf: File = {
Peter van 't Hof's avatar
Peter van 't Hof committed
46
    new File(workDir, input.getName.substring(0, input.getName.lastIndexOf(".bam")) + ".breakdancer.vcf")
Wai Yi Leung's avatar
Wai Yi Leung committed
47
48
  }

Peter van 't Hof's avatar
Peter van 't Hof committed
49
  override def init(): Unit = {
50
51
52
53
  }

  def biopetScript() {
    // read config and set all parameters for the pipeline
54
    logger.info("Starting Breakdancer configuration")
Wai Yi Leung's avatar
Wai Yi Leung committed
55

56
    val bdcfg = BreakdancerConfig(this, input, this.configfile)
57
    bdcfg.deps = this.deps
Wai Yi Leung's avatar
Wai Yi Leung committed
58
59
60
61
62
63
64
65
66
67
    outputFiles += ("cfg" -> bdcfg.output)
    add(bdcfg)

    val breakdancer = BreakdancerCaller(this, bdcfg.output, this.outputraw)
    add(breakdancer)
    outputFiles += ("tsv" -> breakdancer.output)

    val bdvcf = BreakdancerVCF(this, breakdancer.output, this.outputvcf)
    add(bdvcf)
    outputFiles += ("vcf" -> bdvcf.output)
68
69
70
  }
}

71
object Breakdancer extends PipelineCommand {
Peter van 't Hof's avatar
Peter van 't Hof committed
72
  def apply(root: Configurable, input: File, runDir: File): Breakdancer = {
73
74
    val breakdancer = new Breakdancer(root)
    breakdancer.input = input
Peter van 't Hof's avatar
Peter van 't Hof committed
75
    breakdancer.workDir = runDir
Peter van 't Hof's avatar
Peter van 't Hof committed
76
77
78
    breakdancer.init()
    breakdancer.biopetScript()
    breakdancer
79
80
  }
}