@@ -3,11 +3,9 @@ package org.broadinstitute.gatk.queue.qscripts
3
3
import org .broadinstitute .gatk .queue .QScript
4
4
import org .broadinstitute .gatk .queue .extensions .gatk ._
5
5
6
- class VariantCaller extends QScript {
7
- // Create an alias 'qscript' to be able to access variables in the VariantCaller.
8
- // 'qscript' is now the same as 'VariantCaller.this'
9
- qscript =>
6
+ import org .broadinstitute .gatk .tools .walkers .haplotypecaller .ReferenceConfidenceMode
10
7
8
+ class VariantCaller extends QScript {
11
9
// Required arguments. All initialized to empty values.
12
10
@ Input (doc= " The reference file for the bam files." , shortName= " R" , required= true )
13
11
var referenceFile : File = _
@@ -16,7 +14,7 @@ class VariantCaller extends QScript {
16
14
var bamFiles : List [File ] = Nil
17
15
18
16
@ Input (doc= " Output core filename." , shortName= " O" , required= true )
19
- var out : File = _
17
+ var outputFilename : File = _
20
18
21
19
@ Argument (doc= " Maxmem." , shortName= " mem" , required= true )
22
20
var maxMem : Int = _
@@ -46,33 +44,175 @@ class VariantCaller extends QScript {
46
44
@ Argument (doc= " Ploidy (number of chromosomes) per sample" , shortName= " ploidy" , required= false )
47
45
var samplePloidy : Int = 2
48
46
47
+ @ Argument (doc= " " , shortName= " gvcf" , required= false )
48
+ var gvcf : Boolean = false
49
+
50
+ @ Argument (doc= " " , shortName= " sexAware" , required= false )
51
+ var sexAware : Boolean = false
52
+
53
+ @ Argument (doc= " " , shortName= " sex" , required= false )
54
+ var sexes : List [String ] = Nil
55
+
49
56
def script () {
50
- val haplotypeCaller = new HaplotypeCaller
57
+ // Define common settings for original HC, gvcf HC and sex aware gvcf HC.
58
+ trait HC_Arguments extends HaplotypeCaller {
59
+ this .reference_sequence = referenceFile
60
+
61
+ this .scatterCount = numScatters
62
+ this .memoryLimit = maxMem
63
+ this .num_cpu_threads_per_data_thread = numCPUThreads
51
64
52
- // All required input
53
- haplotypeCaller.input_file = bamFiles
54
- haplotypeCaller.reference_sequence = referenceFile
55
- haplotypeCaller.out = qscript.out + " .raw_variants.vcf"
65
+ this .stand_emit_conf = standEmitConf
66
+ this .stand_call_conf = standCallConf
67
+ }
56
68
57
- haplotypeCaller.scatterCount = numScatters
58
- haplotypeCaller.memoryLimit = maxMem
59
- haplotypeCaller.num_cpu_threads_per_data_thread = numCPUThreads
69
+ // original HC
70
+ if (gvcf == false && sexAware == false ) {
71
+ val haplotypeCaller = new HaplotypeCaller with HC_Arguments
60
72
61
- haplotypeCaller.stand_emit_conf = standEmitConf
62
- haplotypeCaller.stand_call_conf = standCallConf
73
+ // All required input
74
+ haplotypeCaller.input_file = bamFiles
75
+ haplotypeCaller.out = outputFilename + " .raw_variants.vcf"
63
76
64
- // Optional input
65
- if (dbsnpFile != null ) {
66
- haplotypeCaller.D = dbsnpFile
77
+ // Optional input
78
+ if (dbsnpFile != null ) {
79
+ haplotypeCaller.D = dbsnpFile
80
+ }
81
+
82
+ if (targetFile != null ) {
83
+ haplotypeCaller.L :+= targetFile
84
+ haplotypeCaller.ip = intervalPadding
85
+ }
86
+
87
+ haplotypeCaller.sample_ploidy = samplePloidy
88
+
89
+ // add function to queue
90
+ add(haplotypeCaller)
67
91
}
68
- if (targetFile != null ) {
69
- haplotypeCaller.L :+= targetFile
70
- haplotypeCaller.ip = intervalPadding
92
+
93
+ // GVCF HC
94
+ else if (gvcf == true && sexAware == false ) {
95
+ var gvcfFiles : List [File ] = Nil
96
+
97
+ // Make gvcf per bam file
98
+ for (bamFile <- bamFiles) {
99
+ val haplotypeCaller = new HaplotypeCaller with HC_Arguments
100
+
101
+ // All required input
102
+ haplotypeCaller.input_file :+= bamFile
103
+ haplotypeCaller.out = swapExt(bamFile, " bam" , " g.vcf.gz" )
104
+
105
+ // gVCF settings
106
+ haplotypeCaller.emitRefConfidence = ReferenceConfidenceMode .GVCF
107
+
108
+ // Optional input
109
+ if (targetFile != null ) {
110
+ haplotypeCaller.L :+= targetFile
111
+ haplotypeCaller.ip = intervalPadding
112
+ }
113
+
114
+ haplotypeCaller.sample_ploidy = samplePloidy
115
+
116
+ // add function to queue
117
+ gvcfFiles :+= haplotypeCaller.out
118
+ add(haplotypeCaller)
119
+ }
120
+
121
+ // Joint genotyping
122
+ val genotypeGVCFs = new GenotypeGVCFs
123
+ genotypeGVCFs.V = gvcfFiles
124
+ genotypeGVCFs.reference_sequence = referenceFile
125
+ genotypeGVCFs.scatterCount = numScatters
126
+ genotypeGVCFs.num_threads = numCPUThreads
127
+ genotypeGVCFs.out = outputFilename + " .raw_variants.vcf"
128
+
129
+ // Optional input
130
+ if (dbsnpFile != null ) {
131
+ genotypeGVCFs.D = dbsnpFile
132
+ }
133
+
134
+ if (targetFile != null ) {
135
+ genotypeGVCFs.L :+= targetFile
136
+ genotypeGVCFs.ip = intervalPadding
137
+ }
138
+ // Add function to queue
139
+ add(genotypeGVCFs)
71
140
}
72
-
73
- haplotypeCaller.sample_ploidy = samplePloidy
74
-
75
- // add function to queue
76
- add(haplotypeCaller)
141
+
142
+ // GVCF HC Sexaware HUMAN ONLY
143
+ else if (gvcf == true && sexAware == true ) {
144
+ var gvcfFiles : List [File ] = Nil
145
+
146
+ // Make gvcf per bam file
147
+ for ((bamFile, sex) <- (bamFiles,sexes).zipped){
148
+
149
+ // Set common settings
150
+ trait HC_Arguments extends HaplotypeCaller {
151
+ this .reference_sequence = referenceFile
152
+
153
+ this .scatterCount = numScatters
154
+ this .memoryLimit = maxMem
155
+ this .num_cpu_threads_per_data_thread = numCPUThreads
156
+
157
+ this .stand_emit_conf = standEmitConf
158
+ this .stand_call_conf = standCallConf
159
+
160
+ this .input_file :+= bamFile
161
+
162
+ this .emitRefConfidence = ReferenceConfidenceMode .GVCF
163
+ }
164
+
165
+ val haplotypeCallerAutosome = new HaplotypeCaller with HC_Arguments
166
+ val haplotypeCallerAllosome = new HaplotypeCaller with HC_Arguments
167
+
168
+ // HUMAN AUTOSOME
169
+ haplotypeCallerAutosome.sample_ploidy = 2
170
+ haplotypeCallerAutosome.intervalsString = List (" 1" ," 2" ," 3" ," 4" ," 5" ," 6" ," 7" ," 8" ," 9" ," 10" ," 11" ," 12" ," 13" ," 14" ," 15" ," 16" ," 17" ," 18" ," 19" ," 20" ," 21" ," 22" ," MT" )
171
+ haplotypeCallerAutosome.out = swapExt(bamFile, " bam" , " Autosome.g.vcf.gz" )
172
+
173
+ // HUMAN ALLOSOME
174
+ haplotypeCallerAllosome.out = swapExt(bamFile, " bam" , " Allosome.g.vcf.gz" )
175
+ // Sex aware
176
+ if ( sex == " male" ){
177
+ haplotypeCallerAllosome.intervalsString = List (" X" ," Y" )
178
+ haplotypeCallerAllosome.sample_ploidy = 1
179
+ } else if ( sex == " female" ){
180
+ haplotypeCallerAllosome.intervalsString = List (" X" )
181
+ haplotypeCallerAllosome.sample_ploidy = 2
182
+ }
183
+
184
+ // add functions to queue
185
+ add(haplotypeCallerAutosome,haplotypeCallerAllosome)
186
+
187
+ // Combine gvcfs -> probably can use CatVariants
188
+ val combineGVCF = new CatVariants
189
+ combineGVCF.reference = referenceFile
190
+ combineGVCF.V :+= haplotypeCallerAutosome.out
191
+ combineGVCF.V :+= haplotypeCallerAllosome.out
192
+ combineGVCF.out = swapExt(bamFile, " bam" , " g.vcf.gz" )
193
+ combineGVCF.assumeSorted = true
194
+ gvcfFiles :+= combineGVCF.out
195
+
196
+ // add function to queue
197
+ add(combineGVCF)
198
+ gvcfFiles :+= combineGVCF.out
199
+ }
200
+
201
+ // Joint genotyping
202
+ val genotypeGVCFs = new GenotypeGVCFs
203
+ genotypeGVCFs.V = gvcfFiles
204
+ genotypeGVCFs.reference_sequence = referenceFile
205
+ genotypeGVCFs.scatterCount = numScatters
206
+ genotypeGVCFs.num_threads = numCPUThreads
207
+ genotypeGVCFs.out = outputFilename + " .raw_variants.vcf"
208
+
209
+ // Optional input
210
+ if (dbsnpFile != null ) {
211
+ genotypeGVCFs.D = dbsnpFile
212
+ }
213
+
214
+ // Add function to queue
215
+ add(genotypeGVCFs)
216
+ }
77
217
}
78
- }
218
+ }
0 commit comments