VarscanCnsSingleSample.scala 2.61 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.
 */
15
16
17
18
package nl.lumc.sasc.biopet.pipelines.shiva.variantcallers

import java.io.PrintWriter

Peter van 't Hof's avatar
Peter van 't Hof committed
19
import nl.lumc.sasc.biopet.extensions.gatk.CombineVariants
20
import nl.lumc.sasc.biopet.extensions.samtools.SamtoolsMpileup
21
import nl.lumc.sasc.biopet.extensions.varscan.{ FixMpileup, VarscanMpileup2cns }
Peter van 't Hof's avatar
Peter van 't Hof committed
22
import nl.lumc.sasc.biopet.extensions.{ Bgzip, Tabix }
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import nl.lumc.sasc.biopet.utils.config.Configurable

/**
 * Created by sajvanderzeeuw on 15-1-16.
 */
class VarscanCnsSingleSample(val root: Configurable) extends Variantcaller {
  val name = "varscan_cns_singlesample"
  protected def defaultPrio = 25

  override def defaults = Map(
    "samtoolsmpileup" -> Map(
      "disable_baq" -> true,
      "depth" -> 1000000
    ),
37
38
    "varscanmpileup2cns" -> Map("strand_filter" -> 0),
    "combinevariants" -> Map("scattercount" -> 20)
39
40
41
42
  )

  override def fixedValues = Map(
    "samtoolsmpileup" -> Map("output_mapping_quality" -> true),
43
    "varscanmpileup2cns" -> Map("output_vcf" -> 1)
44
45
46
47
48
49
50
51
52
53
  )

  def biopetScript: Unit = {
    val sampleVcfs = for ((sample, inputBam) <- inputBams.toList) yield {
      val mpileup = new SamtoolsMpileup(this)
      mpileup.input = List(inputBam)

      val sampleVcf = new File(outputDir, s"${name}_$sample.vcf.gz")

      val sampleFile = new File(outputDir, s"$sample.name.txt")
54
      sampleFile.getParentFile.mkdirs()
55
      sampleFile.deleteOnExit()
56
57
58
59
60
      val writer = new PrintWriter(sampleFile)
      writer.println(sample)
      writer.close()

      val varscan = new VarscanMpileup2cns(this)
61
      varscan.vcfSampleList = Some(sampleFile)
62

Peter van 't Hof's avatar
Peter van 't Hof committed
63
64
65
      val variantcallingJob = mpileup | new FixMpileup(this) | varscan | new Bgzip(this) > sampleVcf
      variantcallingJob.threadsCorrection = -2
      add(variantcallingJob)
66
67
68
69
70
      add(Tabix(this, sampleVcf))

      sampleVcf
    }

71
    val cv = new CombineVariants(this)
72
73
74
    cv.variant = sampleVcfs
    cv.out = outputFile
    cv.setKey = Some("null")
75
76
    cv.excludeNonVariants = true
    add(cv)
77
78
  }
}