-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathHardFilter.scala
95 lines (73 loc) · 3.73 KB
/
HardFilter.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package org.broadinstitute.sting.queue.qscripts
import org.broadinstitute.sting.queue.QScript
import org.broadinstitute.sting.queue.extensions.gatk._
class HardFilter extends QScript {
// Create an alias 'qscript' to be able to access variables in the HardFilter.
// 'qscript' is now the same as 'HardFilter.this'
qscript =>
// Required arguments. All initialized to empty values.
@Input(doc="The reference file", shortName="R", required=true)
var referenceFile: File = _
@Input(doc="Raw vcf file", shortName="V")
var rawVCF: File =_
@Input(doc="Output core filename.", shortName="O", required=true)
var out: File = _
@Argument(doc="Maximum amount of memory", shortName="mem", required=true)
var maxMem: Int = _
@Argument(doc="Number of scatters", shortName="nsc", required=true)
var numScatters: Int = _
// filteroptions
@Argument(doc="Filter mode: BOTH, SNP or INDEL", shortName="mode", required=true)
var filterMode: String = _
@Argument(doc="A optional list of SNPfilter names.", shortName="snpFilterName", required=false)
var snpFilterNames: List[String] = _
@Argument(doc="An optional list of filter expressions.", shortName="snpFilterExpression", required=false)
var snpFilterExp: List[String] = _
@Argument(doc="An optional list of INDEL filter names.", shortName="indelFilterName", required=false)
var indelFilterNames: List[String] = _
@Argument(doc="An optional list of INDEL filter expressions.", shortName="indelFilterExpression", required=false)
var indelFilterExp: List[String] = _
@Argument(doc="The number of SNPs which make up a cluster.", shortName="cluster", required=false)
var clusterSize: Int = 0
@Argument(doc="The window size (in bases) in which to evaluate clustered SNPs.", shortName="window", required=false)
var clusterWindowSize: Int = 0
// This trait allows us set the variables below in one place and then reuse this trait on each CommandLineGATK function below.
trait HF_Arguments extends CommandLineGATK {
this.reference_sequence = referenceFile
this.memoryLimit = maxMem
}
def script() {
val selectSNP = new SelectVariants with HF_Arguments
selectSNP.V = rawVCF
selectSNP.selectType :+= org.broadinstitute.variant.variantcontext.VariantContext.Type.SNP
selectSNP.selectType :+= org.broadinstitute.variant.variantcontext.VariantContext.Type.NO_VARIATION
selectSNP.out = qscript.out + ".raw_snps.vcf"
val SNPfilter = new VariantFiltration with HF_Arguments
SNPfilter.scatterCount = numScatters
SNPfilter.V = rawVCF
SNPfilter.out = qscript.out + ".filtered_snps.vcf"
SNPfilter.filterExpression = snpFilterExp
SNPfilter.filterName = snpFilterNames
if( clusterSize != 0 && clusterWindowSize != 0 ){
SNPfilter.clusterSize = clusterSize
SNPfilter.clusterWindowSize = clusterWindowSize
}
val selectINDEL = new SelectVariants with HF_Arguments
selectINDEL.V = rawVCF
selectINDEL.selectType :+= org.broadinstitute.variant.variantcontext.VariantContext.Type.INDEL
selectINDEL.out = qscript.out + ".raw_indels.vcf"
val INDELfilter = new VariantFiltration with HF_Arguments
INDELfilter.scatterCount = numScatters
INDELfilter.V = rawVCF
INDELfilter.out = qscript.out + ".filtered_indels.vcf"
INDELfilter.filterExpression = indelFilterExp
INDELfilter.filterName = indelFilterNames
val CombineVars = new CombineVariants with HF_Arguments
CombineVars.V :+= SNPfilter.out
CombineVars.V :+= INDELfilter.out
CombineVars.out = qscript.out + ".filtered_variants.vcf"
if (filterMode == "SNP" || filterMode == "BOTH") { add(selectSNP, SNPfilter) }
if (filterMode == "INDEL" || filterMode == "BOTH") { add(selectINDEL, INDELfilter) }
if (filterMode == "BOTH") { add(CombineVars) }
}
}