forked from BimberLab/DiscvrLabKeyModules
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVariantAnnotatorStep.java
More file actions
149 lines (129 loc) · 6.96 KB
/
VariantAnnotatorStep.java
File metadata and controls
149 lines (129 loc) · 6.96 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package org.labkey.sequenceanalysis.run.variant;
import htsjdk.samtools.util.Interval;
import org.jetbrains.annotations.Nullable;
import org.json.JSONObject;
import org.labkey.api.pipeline.PipelineJobException;
import org.labkey.api.sequenceanalysis.pipeline.AbstractVariantProcessingStepProvider;
import org.labkey.api.sequenceanalysis.pipeline.PedigreeToolParameterDescriptor;
import org.labkey.api.sequenceanalysis.pipeline.PipelineContext;
import org.labkey.api.sequenceanalysis.pipeline.PipelineStepProvider;
import org.labkey.api.sequenceanalysis.pipeline.ReferenceGenome;
import org.labkey.api.sequenceanalysis.pipeline.ToolParameterDescriptor;
import org.labkey.api.sequenceanalysis.pipeline.VariantProcessingStep;
import org.labkey.api.sequenceanalysis.pipeline.VariantProcessingStepOutputImpl;
import org.labkey.api.sequenceanalysis.run.AbstractCommandPipelineStep;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.sequenceanalysis.pipeline.ProcessVariantsHandler;
import org.labkey.sequenceanalysis.pipeline.SequenceTaskHelper;
import org.labkey.sequenceanalysis.run.util.VariantAnnotatorWrapper;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* User: bimber
* Date: 6/15/2014
* Time: 12:39 PM
*/
public class VariantAnnotatorStep extends AbstractCommandPipelineStep<VariantAnnotatorWrapper> implements VariantProcessingStep
{
public VariantAnnotatorStep(PipelineStepProvider<?> provider, PipelineContext ctx)
{
super(provider, ctx, new VariantAnnotatorWrapper(ctx.getLogger()));
}
public static class Provider extends AbstractVariantProcessingStepProvider<VariantAnnotatorStep> implements VariantProcessingStep.RequiresPedigree, VariantProcessingStep.SupportsScatterGather
{
public Provider()
{
super("VariantAnnotatorStep", "GATK VariantAnnotator", "GATK", "Annotate variants using GATK VariantAnnotator", Arrays.asList(
ToolParameterDescriptor.create("mv", "Mendelian Violations", "If selected, mendelian violations will be annotated at the site and genotype level. This requires records in the laboratory.subjects table matching the sample names of the VCF(s)", "checkbox", new JSONObject(){{
put("checked", false);
}}, null),
ToolParameterDescriptor.create("maf", "Minor Allele Frequency", "If selected, MAF will be annotated.", "checkbox", new JSONObject(){{
put("checked", true);
}}, null),
ToolParameterDescriptor.create("chromosomeCounts", "Chromosome Counts", "If selected, GATK ChromosomeCounts annotations, including AF and AC, will be annotated.", "checkbox", new JSONObject(){{
put("checked", false);
}}, null),
ToolParameterDescriptor.create("impact", "IMPACT", "If selected, the Impact annotation will run, which parses the SnpEff ANN field into multiple discrete INFO fields.", "checkbox", new JSONObject(){{
put("checked", false);
}}, null),
ToolParameterDescriptor.create("excessHet", "ExcessHet", "If selected, the ExcessHet annotation will run.", "checkbox", new JSONObject(){{
put("checked", false);
}}, null),
ToolParameterDescriptor.create("svtype", "SVType", "If selected, the SVType annotation will run.", "checkbox", new JSONObject(){{
put("checked", false);
}}, null),
new PedigreeToolParameterDescriptor()
), PageFlowUtil.set(PedigreeToolParameterDescriptor.getClientDependencyPath()), "");
}
@Override
public VariantAnnotatorStep create(PipelineContext ctx)
{
return new VariantAnnotatorStep(this, ctx);
}
}
@Override
public Output processVariants(File inputVCF, File outputDirectory, ReferenceGenome genome, @Nullable List<Interval> intervals) throws PipelineJobException
{
VariantProcessingStepOutputImpl output = new VariantProcessingStepOutputImpl();
List<String> options = new ArrayList<>();
File outputVcf = new File(outputDirectory, SequenceTaskHelper.getUnzippedBaseName(inputVCF) + ".annotated.vcf.gz");
if (getProvider().getParameterByName("mv").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Boolean.class, false))
{
options.add("-A");
options.add("MendelianViolationCount");
options.add("-A");
options.add("MendelianViolationBySample");
String demographicsProviderName = getProvider().getParameterByName(PedigreeToolParameterDescriptor.NAME).extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx());
File pedFile = ProcessVariantsHandler.getPedigreeFile(getPipelineCtx().getSourceDirectory(true), demographicsProviderName);
if (!pedFile.exists())
{
throw new PipelineJobException("Unable to find pedigree file: " + pedFile.getPath());
}
options.add("-ped");
options.add(pedFile.getPath());
options.add("-pedValidationType");
options.add("SILENT");
}
if (getProvider().getParameterByName("maf").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Boolean.class, false))
{
options.add("-A");
options.add("MinorAlleleFrequency");
}
if (getProvider().getParameterByName("chromosomeCounts").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Boolean.class, false))
{
options.add("-A");
options.add("ChromosomeCounts");
}
if (getProvider().getParameterByName("impact").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Boolean.class, false))
{
options.add("-A");
options.add("Impact");
}
if (getProvider().getParameterByName("excessHet").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Boolean.class, false))
{
options.add("-A");
options.add("ExcessHet");
}
if (getProvider().getParameterByName("svtype").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Boolean.class, false))
{
options.add("-A");
options.add("SVType");
}
if (intervals != null)
{
intervals.forEach(interval -> {
options.add("-L");
options.add(interval.getContig() + ":" + interval.getStart() + "-" + interval.getEnd());
});
}
getWrapper().execute(genome.getWorkingFastaFile(), inputVCF, outputVcf, options);
if (!outputVcf.exists())
{
throw new PipelineJobException("output not found: " + outputVcf);
}
output.setVcf(outputVcf);
return output;
}
}