CollectGcBiasMetrics.scala 3.78 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.picard
17
18

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

20
import nl.lumc.sasc.biopet.core.Reference
Peter van 't Hof's avatar
Peter van 't Hof committed
21
import nl.lumc.sasc.biopet.utils.config.Configurable
22
import nl.lumc.sasc.biopet.core.summary.Summarizable
Peter van 't Hof's avatar
Peter van 't Hof committed
23
import org.broadinstitute.gatk.utils.commandline.{ Argument, Input, Output }
24

Peter van 't Hof's avatar
Peter van 't Hof committed
25
/** Extension for picard CollectGcBiasMetrics */
26
class CollectGcBiasMetrics(val root: Configurable) extends Picard with Summarizable with Reference {
27
  javaMainClass = new picard.analysis.CollectGcBiasMetrics().getClass.getName
28

bow's avatar
bow committed
29
  @Input(doc = "The input SAM or BAM files to analyze.  Must be coordinate sorted.", required = true)
30
31
  var input: Seq[File] = Nil

bow's avatar
bow committed
32
  @Output(doc = "The output file to write statistics to", required = true)
33
  var output: File = _
bow's avatar
bow committed
34
35

  @Output(doc = "Output chart", required = false)
36
  var outputChart: File = _
bow's avatar
bow committed
37

38
  @Output(doc = "Output summary", required = true)
39
40
  var outputSummary: File = _

41
42
  @Input(doc = "Reference file", required = false)
  var reference: File = null
bow's avatar
bow committed
43
44

  @Argument(doc = "Window size", required = false)
Peter van 't Hof's avatar
Peter van 't Hof committed
45
  var windowSize: Option[Int] = config("windowsize")
bow's avatar
bow committed
46
47

  @Argument(doc = "MINIMUM_GENOME_FRACTION", required = false)
Peter van 't Hof's avatar
Peter van 't Hof committed
48
  var minGenomeFraction: Option[Double] = config("mingenomefraction")
bow's avatar
bow committed
49
50
51
52
53

  @Argument(doc = "ASSUME_SORTED", required = false)
  var assumeSorted: Boolean = config("assumesorted", default = true)

  @Argument(doc = "IS_BISULFITE_SEQUENCED", required = false)
Peter van 't Hof's avatar
Peter van 't Hof committed
54
  var isBisulfiteSequinced: Option[Boolean] = config("isbisulfitesequinced")
bow's avatar
bow committed
55

Peter van 't Hof's avatar
Peter van 't Hof committed
56
  override def defaultCoreMemory = 8.0
Peter van 't Hof's avatar
Peter van 't Hof committed
57

Peter van 't Hof's avatar
Peter van 't Hof committed
58
59
  override def beforeGraph() {
    super.beforeGraph()
60
    if (outputChart == null) outputChart = new File(output + ".pdf")
61
    if (reference == null) reference = referenceFasta()
62
  }
bow's avatar
bow committed
63

Peter van 't Hof's avatar
Peter van 't Hof committed
64
  /** Returns command to execute */
65
  override def cmdLine = super.cmdLine +
bow's avatar
bow committed
66
67
68
69
    repeat("INPUT=", input, spaceSeparated = false) +
    required("OUTPUT=", output, spaceSeparated = false) +
    optional("CHART_OUTPUT=", outputChart, spaceSeparated = false) +
    required("REFERENCE_SEQUENCE=", reference, spaceSeparated = false) +
70
    required("SUMMARY_OUTPUT=", outputSummary, spaceSeparated = false) +
bow's avatar
bow committed
71
72
    optional("WINDOW_SIZE=", windowSize, spaceSeparated = false) +
    optional("MINIMUM_GENOME_FRACTION=", minGenomeFraction, spaceSeparated = false) +
73
    conditional(assumeSorted, "ASSUME_SORTED=TRUE") +
Peter van 't Hof's avatar
Peter van 't Hof committed
74
    conditional(isBisulfiteSequinced.getOrElse(false), "IS_BISULFITE_SEQUENCED=TRUE")
75
76
77
78
79

  /** Returns files for summary */
  def summaryFiles: Map[String, File] = Map()

  /** Returns stats for summary */
Peter van 't Hof's avatar
Peter van 't Hof committed
80
  def summaryStats = Picard.getHistogram(output, tag = "METRICS CLASS")
81
82
83
}

object CollectGcBiasMetrics {
Peter van 't Hof's avatar
Peter van 't Hof committed
84
  /** Returns default CollectGcBiasMetrics */
Peter van 't Hof's avatar
Peter van 't Hof committed
85
  def apply(root: Configurable, input: File, outputDir: File): CollectGcBiasMetrics = {
86
87
88
    val collectGcBiasMetrics = new CollectGcBiasMetrics(root)
    collectGcBiasMetrics.input :+= input
    collectGcBiasMetrics.output = new File(outputDir, input.getName.stripSuffix(".bam") + ".gcbiasmetrics")
89
    collectGcBiasMetrics.outputSummary = new File(outputDir, input.getName.stripSuffix(".bam") + ".gcbiasmetrics.summary")
Peter van 't Hof's avatar
Peter van 't Hof committed
90
    collectGcBiasMetrics
91
92
  }
}