Delly.scala 3.17 KB
Newer Older
Peter van 't Hof's avatar
Peter van 't Hof committed
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
Peter van 't Hof's avatar
Peter van 't Hof committed
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.
 */
Peter van 't Hof's avatar
Peter van 't Hof committed
15
16
package nl.lumc.sasc.biopet.pipelines.shiva.svcallers

Peter van 't Hof's avatar
Peter van 't Hof committed
17
import nl.lumc.sasc.biopet.extensions.delly.DellyCaller
Peter van 't Hof's avatar
Peter van 't Hof committed
18
import nl.lumc.sasc.biopet.extensions.gatk.CatVariants
19
import nl.lumc.sasc.biopet.extensions.picard.SortVcf
Peter van 't Hof's avatar
Peter van 't Hof committed
20
import nl.lumc.sasc.biopet.utils.Logging
Peter van 't Hof's avatar
Peter van 't Hof committed
21
22
import nl.lumc.sasc.biopet.utils.config.Configurable

23
/** Script for sv caller delly */
Peter van 't Hof's avatar
Peter van 't Hof committed
24
class Delly(val parent: Configurable) extends SvCaller {
Peter van 't Hof's avatar
Peter van 't Hof committed
25
26
  def name = "delly"

Peter van 't Hof's avatar
Peter van 't Hof committed
27
28
29
30
31
  val del: Boolean = config("DEL", default = true)
  val dup: Boolean = config("DUP", default = true)
  val inv: Boolean = config("INV", default = true)
  val tra: Boolean = config("TRA", default = true)

Peter van 't Hof's avatar
Peter van 't Hof committed
32
33
34
  def biopetScript() {
    for ((sample, bamFile) <- inputBams) {
      val dellyDir = new File(outputDir, sample)
Peter van 't Hof's avatar
Peter van 't Hof committed
35
36

      val catVariants = new CatVariants(this)
Peter van 't Hof's avatar
Peter van 't Hof committed
37
      catVariants.outputFile = new File(dellyDir, sample + ".delly.vcf")
Peter van 't Hof's avatar
Peter van 't Hof committed
38
      catVariants.isIntermediate = true
39
      catVariants.writeHeaderToEmptyOutput = true
Peter van 't Hof's avatar
Peter van 't Hof committed
40
41
42
43
44

      if (del) {
        val delly = new DellyCaller(this)
        delly.input = bamFile
        delly.analysistype = "DEL"
Peter van 't Hof's avatar
Peter van 't Hof committed
45
        delly.isIntermediate = true
Peter van 't Hof's avatar
Peter van 't Hof committed
46
47
        delly.outputvcf = new File(dellyDir, sample + ".delly.del.vcf")
        add(delly)
48

Peter van 't Hof's avatar
Peter van 't Hof committed
49
        catVariants.variant :+= delly.outputvcf
Peter van 't Hof's avatar
Peter van 't Hof committed
50
51
52
53
54
      }
      if (dup) {
        val delly = new DellyCaller(this)
        delly.input = bamFile
        delly.analysistype = "DUP"
Peter van 't Hof's avatar
Peter van 't Hof committed
55
        delly.isIntermediate = true
Peter van 't Hof's avatar
Peter van 't Hof committed
56
57
        delly.outputvcf = new File(dellyDir, sample + ".delly.dup.vcf")
        add(delly)
58

Peter van 't Hof's avatar
Peter van 't Hof committed
59
        catVariants.variant :+= delly.outputvcf
Peter van 't Hof's avatar
Peter van 't Hof committed
60
61
62
63
64
      }
      if (inv) {
        val delly = new DellyCaller(this)
        delly.input = bamFile
        delly.analysistype = "INV"
Peter van 't Hof's avatar
Peter van 't Hof committed
65
        delly.isIntermediate = true
Peter van 't Hof's avatar
Peter van 't Hof committed
66
67
        delly.outputvcf = new File(dellyDir, sample + ".delly.inv.vcf")
        add(delly)
68

Peter van 't Hof's avatar
Peter van 't Hof committed
69
        catVariants.variant :+= delly.outputvcf
Peter van 't Hof's avatar
Peter van 't Hof committed
70
71
72
73
74
      }
      if (tra) {
        val delly = new DellyCaller(this)
        delly.input = bamFile
        delly.analysistype = "TRA"
Peter van 't Hof's avatar
Peter van 't Hof committed
75
        delly.isIntermediate = true
Peter van 't Hof's avatar
Peter van 't Hof committed
76
77
        delly.outputvcf = new File(dellyDir, sample + ".delly.tra.vcf")
        add(delly)
78

Peter van 't Hof's avatar
Peter van 't Hof committed
79
        catVariants.variant :+= delly.outputvcf
Peter van 't Hof's avatar
Peter van 't Hof committed
80
81
      }

Peter van 't Hof's avatar
Peter van 't Hof committed
82
      if (catVariants.variant.isEmpty) Logging.addError("At least 1 SV-type should be selected for Delly")
83

Peter van 't Hof's avatar
Peter van 't Hof committed
84
      add(catVariants)
Peter van 't Hof's avatar
Peter van 't Hof committed
85
86
87

      val compressedVCF = new SortVcf(this)
      compressedVCF.input = catVariants.outputFile
Peter van 't Hof's avatar
Peter van 't Hof committed
88
      compressedVCF.output = catVariants.outputFile + ".gz"
Peter van 't Hof's avatar
Peter van 't Hof committed
89
90
91
      add(compressedVCF)

      addVCF(sample, compressedVCF.output)
Peter van 't Hof's avatar
Peter van 't Hof committed
92
93
94
    }
  }
}