DepthOfCoverage.scala 5.72 KB
Newer Older
Sander Bollen's avatar
Sander Bollen committed
1
2
3
4
5
package nl.lumc.sasc.biopet.extensions.gatk

import java.io.File

import nl.lumc.sasc.biopet.utils.config.Configurable
Sander Bollen's avatar
Sander Bollen committed
6
import org.broadinstitute.gatk.utils.commandline.{ Argument, Output }
Sander Bollen's avatar
Sander Bollen committed
7
8

/**
Sander Bollen's avatar
Sander Bollen committed
9
10
 * Created by Sander Bollen on 23-11-16.
 */
Sander Bollen's avatar
Sander Bollen committed
11
12
13
14
15
16
17
18
class DepthOfCoverage(val root: Configurable) extends CommandLineGATK {

  def analysis_type = "DepthOfCoverage"

  /*
  This tool creates several files with `out` as the root
   */
  @Output(fullName = "out", shortName = "o", doc = "File name base to which coverage metric should be written")
Sander Bollen's avatar
Sander Bollen committed
19
  var out: File = _
Sander Bollen's avatar
Sander Bollen committed
20

21
22
  private var _summaryFile: File = _
  private var _statisticsFile: File = _
Sander Bollen's avatar
Sander Bollen committed
23
  private var _intervalSummaryFile: File = _
24
25
26
  private var _intervalStatisticsFile: File = _
  private var _geneSummaryFile: File = _
  private var _geneStatisticsFile: File = _
Sander Bollen's avatar
Sander Bollen committed
27
  private var _cumulativeCoverageCountsFile: File = _
28
  private var _cumulativeCoverageProportionsFile: File = _
Sander Bollen's avatar
Sander Bollen committed
29

Sander Bollen's avatar
Sander Bollen committed
30
  @Output
31
  var summaryFile = _summaryFile
Sander Bollen's avatar
Sander Bollen committed
32
  @Output
33
  var statisticsFile = _statisticsFile
Sander Bollen's avatar
Sander Bollen committed
34
  @Output
35
  var intervalSummaryFile = _intervalSummaryFile
Sander Bollen's avatar
Sander Bollen committed
36
  @Output
37
  var intervalStatisticsFile = _intervalStatisticsFile
Sander Bollen's avatar
Sander Bollen committed
38
  @Output
39
  var geneSummaryFile = _geneSummaryFile
Sander Bollen's avatar
Sander Bollen committed
40
  @Output
41
  var geneStatisticsFile = _geneStatisticsFile
Sander Bollen's avatar
Sander Bollen committed
42
  @Output
43
44
45
  var culumativeCoverageCountsFile = _cumulativeCoverageCountsFile
  @Output
  var cumulativeCoverageProportionsFile = _cumulativeCoverageProportionsFile
Sander Bollen's avatar
Sander Bollen committed
46

47
  var calculateCoverageOverGenes: Option[File] = config("calculate_coverage_over_genes", namespace = "depth_of_coverage", default = None)
Sander Bollen's avatar
Sander Bollen committed
48

49
  var countType: Option[String] = config("count_type", namespace = "depth_of_coverage", default = None)
Sander Bollen's avatar
Sander Bollen committed
50

51
  var maxBaseQuality: Option[Int] = config("max_base_quality", namespace = "depth_of_coverage", default = None)
Sander Bollen's avatar
Sander Bollen committed
52

53
  var maxMappingQuality: Option[Int] = config("max_mapping_quality", namespace = "depth_of_coverage", default = None)
Sander Bollen's avatar
Sander Bollen committed
54

55
  var minBaseQuality: Option[Int] = config("min_base_quality", namespace = "depth_of_coverage", default = None)
Sander Bollen's avatar
Sander Bollen committed
56

57
  var minMappingQuality: Option[Int] = config("min_mapping_quality", namespace = "depth_of_coverage", default = None)
Sander Bollen's avatar
Sander Bollen committed
58

59
  var outputFormat: Option[String] = config("output_format", namespace = "depth_of_coverage", default = None)
Sander Bollen's avatar
Sander Bollen committed
60

61
  var partitionType: Option[String] = config("partition_type", namespace = "depth_of_coverage", default = None)
Sander Bollen's avatar
Sander Bollen committed
62

63
  var omitDepthOutputAtEachBase: Boolean = config("omit_depth_output_at_each_base", namespace = "depth_of_coverage", default = false)
Sander Bollen's avatar
Sander Bollen committed
64

65
  var omitIntervalStatistics: Boolean = config("omit_interval_statistics", namespace = "depth_of_coverage", default = false)
Sander Bollen's avatar
Sander Bollen committed
66

67
  var omitLocusTable: Boolean = config("omit_locus_table", namespace = "depth_of_coverage", default = false)
Sander Bollen's avatar
Sander Bollen committed
68

69
  var omitPerSampleStats: Boolean = config("omit_per_sample_stats", namespace = "depth_of_coverage", default = false)
Sander Bollen's avatar
Sander Bollen committed
70

71
  var printBaseCounts: Boolean = config("print_base_counts", namespace = "depth_of_coverage", default = false)
Sander Bollen's avatar
Sander Bollen committed
72

73
  var nBins: Option[Int] = config("n_bins", namespace = "depth_of_coverage", default = None)
Sander Bollen's avatar
Sander Bollen committed
74

75
  var start: Option[Int] = config("start", namespace = "depth_of_coverage", default = None)
Sander Bollen's avatar
Sander Bollen committed
76

77
  var stop: Option[Int] = config("stop", namespace = "depth_of_coverage", default = None)
Sander Bollen's avatar
Sander Bollen committed
78

79
  var summaryCoverageThreshold: Option[Int] = config("summary_coverage_threshold", namespace = "depth_of_coverage", default = None)
Sander Bollen's avatar
Sander Bollen committed
80

81
  var ignoreDeletionSites: Boolean = config("ignore_deletion_sites", namespace = "depth_of_coverage", default = false)
Sander Bollen's avatar
Sander Bollen committed
82

83
  var includeDeletions: Boolean = config("include_deletions", namespace = "depth_of_coverage", default = false)
Sander Bollen's avatar
Sander Bollen committed
84

Sander Bollen's avatar
Sander Bollen committed
85
  var includeRefNSites: Boolean = config("include_ref_n_sites", namespace = "depth_of_coverage", default = false)
Sander Bollen's avatar
Sander Bollen committed
86

Sander Bollen's avatar
Sander Bollen committed
87
  var printBinEndpointsAndExit: Boolean = config("print_bin_endpoint_and_exit", namespace = "depth_of_coverage", default = false)
Sander Bollen's avatar
Sander Bollen committed
88

89
90
91
92
93
94
95
  override def beforeGraph() = {
    super.beforeGraph()
    if (out == null) {
      throw new IllegalStateException("You must set the <out> variable")
    }
    _summaryFile = new File(out + ".sample_summary")
    _statisticsFile = new File(out + ".sample_statistics")
Sander Bollen's avatar
Sander Bollen committed
96
    _intervalSummaryFile = new File(out + ".sample_interval_summary")
97
98
99
    _intervalStatisticsFile = new File(out + ".sample_interval_statistics")
    _geneSummaryFile = new File(out + ".sample_gene_summary")
    _geneStatisticsFile = new File(out + ".sample_gene_statistics")
Sander Bollen's avatar
Sander Bollen committed
100
    _cumulativeCoverageCountsFile = new File(out + ".sample_cumulative_coverage_counts")
101
102
103
    _cumulativeCoverageProportionsFile = new File(out + ".sample_cumulative_coverage_proportions")
  }

Sander Bollen's avatar
Sander Bollen committed
104
105
  override def cmdLine = {
    super.cmdLine + required("--out", out) +
106
      optional("--calculateCoverageOverGenes", calculateCoverageOverGenes) +
Sander Bollen's avatar
Sander Bollen committed
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
      optional("--countType", countType) +
      optional("--maxBaseQuality", maxBaseQuality) +
      optional("--maxMappingQuality", maxMappingQuality) +
      optional("--minBaseQuality", minBaseQuality) +
      optional("--minMappingQuality", minMappingQuality) +
      optional("--outputFormat", outputFormat) +
      optional("--partitionType", partitionType) +
      conditional(omitDepthOutputAtEachBase, "--omitDepthOutputAtEachBase") +
      conditional(omitIntervalStatistics, "--omitIntervalStatistics") +
      conditional(omitLocusTable, "--omitLocusTable") +
      conditional(omitPerSampleStats, "--omitPerSampleStats") +
      conditional(printBaseCounts, "--printBaseCounts") +
      optional("--nBins", nBins) +
      optional("--start", start) +
      optional("--stop", stop) +
      optional("--summaryCoverageThreshold", summaryCoverageThreshold) +
      conditional(ignoreDeletionSites, "--ignoreDeletionSites") +
      conditional(includeDeletions, "--includeDeletions") +
      conditional(includeRefNSites, "--includeRefNSites") +
      conditional(printBinEndpointsAndExit, "--printBinEndPointsAndExit")
  }
}