CollectGcBiasMetrics.scala 3.51 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
19

import java.io.File
import nl.lumc.sasc.biopet.core.config.Configurable
20
import nl.lumc.sasc.biopet.core.summary.Summarizable
bow's avatar
bow committed
21
import org.broadinstitute.gatk.utils.commandline.{ Input, Output, Argument }
22

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

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

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

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

  @Output(doc = "Output summary", required = false)
37
38
  var outputSummary: File = _

bow's avatar
bow committed
39
  @Argument(doc = "Reference file", required = false)
40
  var reference: File = config("reference")
bow's avatar
bow committed
41
42

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

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

  @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
52
  var isBisulfiteSequinced: Option[Boolean] = config("isbisulfitesequinced")
bow's avatar
bow committed
53

54
  override def beforeGraph {
55
56
    if (outputChart == null) outputChart = new File(output + ".pdf")
  }
bow's avatar
bow committed
57

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

  /** 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
74
  def summaryStats = Picard.getHistogram(output, tag = "METRICS CLASS")
75
76
77
}

object CollectGcBiasMetrics {
Peter van 't Hof's avatar
Peter van 't Hof committed
78
  /** Returns default CollectGcBiasMetrics */
Peter van 't Hof's avatar
Peter van 't Hof committed
79
  def apply(root: Configurable, input: File, outputDir: File): CollectGcBiasMetrics = {
80
81
82
83
84
85
    val collectGcBiasMetrics = new CollectGcBiasMetrics(root)
    collectGcBiasMetrics.input :+= input
    collectGcBiasMetrics.output = new File(outputDir, input.getName.stripSuffix(".bam") + ".gcbiasmetrics")
    return collectGcBiasMetrics
  }
}