Skip to content

Commit e776fd2

Browse files
committed
Support GATK SVAnnotateStep
1 parent 5587aec commit e776fd2

File tree

4 files changed

+108
-2
lines changed

4 files changed

+108
-2
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/SequenceAnalysisModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
import org.labkey.sequenceanalysis.run.util.FastqcRunner;
114114
import org.labkey.sequenceanalysis.run.util.GenomicsDBAppendHandler;
115115
import org.labkey.sequenceanalysis.run.util.GenomicsDBImportHandler;
116+
import org.labkey.sequenceanalysis.run.util.SVAnnotateStep;
116117
import org.labkey.sequenceanalysis.run.variant.*;
117118
import org.labkey.sequenceanalysis.util.Barcoder;
118119
import org.labkey.sequenceanalysis.util.ChainFileValidator;
@@ -300,6 +301,7 @@ public static void registerPipelineSteps()
300301
SequencePipelineService.get().registerPipelineStep(new MendelianViolationReportStep.Provider());
301302
SequencePipelineService.get().registerPipelineStep(new SummarizeGenotypeQualityStep.Provider());
302303
SequencePipelineService.get().registerPipelineStep(new BcftoolsFillTagsStep.Provider());
304+
SequencePipelineService.get().registerPipelineStep(new SVAnnotateStep.Provider());
303305

304306
//handlers
305307
SequenceAnalysisService.get().registerFileHandler(new LiftoverHandler());

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/alignment/StarWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public StarWrapper(@Nullable Logger logger)
5353

5454
public static class StarAlignmentStep extends AbstractAlignmentPipelineStep<StarWrapper> implements AlignmentStep
5555
{
56-
public StarAlignmentStep(AlignmentStepProvider provider, PipelineContext ctx)
56+
public StarAlignmentStep(AlignmentStepProvider<?> provider, PipelineContext ctx)
5757
{
5858
super(provider, ctx, new StarWrapper(ctx.getLogger()));
5959
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
package org.labkey.sequenceanalysis.run.util;
2+
3+
import htsjdk.samtools.util.Interval;
4+
import org.apache.logging.log4j.Logger;
5+
import org.json.JSONObject;
6+
import org.labkey.api.pipeline.PipelineJobException;
7+
import org.labkey.api.sequenceanalysis.pipeline.AbstractVariantProcessingStepProvider;
8+
import org.labkey.api.sequenceanalysis.pipeline.PipelineContext;
9+
import org.labkey.api.sequenceanalysis.pipeline.PipelineStepProvider;
10+
import org.labkey.api.sequenceanalysis.pipeline.ReferenceGenome;
11+
import org.labkey.api.sequenceanalysis.pipeline.ToolParameterDescriptor;
12+
import org.labkey.api.sequenceanalysis.pipeline.VariantProcessingStep;
13+
import org.labkey.api.sequenceanalysis.pipeline.VariantProcessingStepOutputImpl;
14+
import org.labkey.api.sequenceanalysis.run.AbstractCommandPipelineStep;
15+
import org.labkey.api.sequenceanalysis.run.AbstractGatk4Wrapper;
16+
import org.labkey.api.util.PageFlowUtil;
17+
import org.labkey.sequenceanalysis.pipeline.SequenceTaskHelper;
18+
19+
import javax.annotation.Nullable;
20+
import java.io.File;
21+
import java.util.ArrayList;
22+
import java.util.Arrays;
23+
import java.util.List;
24+
25+
public class SVAnnotateStep extends AbstractCommandPipelineStep<SVAnnotateStep.SNAnnotateWrapper> implements VariantProcessingStep
26+
{
27+
public static final String GENE_PARAM = "gene_file";
28+
29+
public SVAnnotateStep(PipelineStepProvider<?> provider, PipelineContext ctx)
30+
{
31+
super(provider, ctx, new SNAnnotateWrapper(ctx.getLogger()));
32+
}
33+
34+
public static class Provider extends AbstractVariantProcessingStepProvider<SVAnnotateStep>
35+
{
36+
public Provider()
37+
{
38+
super("SVAnnotateStep", "GATK SVAnnotate", "GATK", "This will run GATK's SVAnnotate to classify SVs by impact", Arrays.asList(
39+
ToolParameterDescriptor.createExpDataParam(GENE_PARAM, "Gene File", "This is the ID of a GTF or GFF3 file containing genes from this genome.", "sequenceanalysis-genomefileselectorfield", new JSONObject()
40+
{{
41+
put("extensions", Arrays.asList("gtf"));
42+
put("width", 400);
43+
put("allowBlank", false);
44+
}}, null)
45+
), PageFlowUtil.set("sequenceanalysis/field/GenomeFileSelectorField.js"), "");
46+
47+
}
48+
49+
@Override
50+
public SVAnnotateStep create(PipelineContext ctx)
51+
{
52+
return new SVAnnotateStep(this, ctx);
53+
}
54+
}
55+
56+
@Override
57+
public Output processVariants(File inputVCF, File outputDirectory, ReferenceGenome genome, @Nullable List<Interval> intervals) throws PipelineJobException
58+
{
59+
VariantProcessingStepOutputImpl output = new VariantProcessingStepOutputImpl();
60+
61+
output.addInput(inputVCF, "Input VCF");
62+
output.addInput(genome.getWorkingFastaFile(), "Reference Genome");
63+
64+
List<String> args = new ArrayList<>(getWrapper().getBaseArgs("SVAnnotate"));
65+
args.add("-V");
66+
args.add(inputVCF.getPath());
67+
68+
if (intervals != null)
69+
{
70+
intervals.forEach(interval -> {
71+
args.add("-L");
72+
args.add(interval.getContig() + ":" + interval.getStart() + "-" + interval.getEnd());
73+
});
74+
}
75+
76+
Integer geneFileId = getProvider().getParameterByName(GENE_PARAM).extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Integer.class);
77+
File geneFile = getPipelineCtx().getSequenceSupport().getCachedData(geneFileId);
78+
if (!geneFile.exists())
79+
{
80+
throw new PipelineJobException("Unable to find file: " + geneFile.getPath());
81+
}
82+
args.add("--protein-coding-gtf");
83+
args.add(geneFile.getPath());
84+
85+
File outputVcf = new File(outputDirectory, SequenceTaskHelper.getUnzippedBaseName(inputVCF) + ".svannotate.vcf.gz");
86+
getWrapper().execute(args);
87+
if (!outputVcf.exists())
88+
{
89+
throw new PipelineJobException("output not found: " + outputVcf);
90+
}
91+
92+
output.setVcf(outputVcf);
93+
94+
return output;
95+
}
96+
97+
public static class SNAnnotateWrapper extends AbstractGatk4Wrapper
98+
{
99+
public SNAnnotateWrapper(@Nullable Logger logger)
100+
{
101+
super(logger);
102+
}
103+
}
104+
}

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/variant/SelectSNVsStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class SelectSNVsStep extends AbstractCommandPipelineStep<SelectVariantsWr
3333
public static String SELECT_TYPE_TO_INCLUDE = "selectType";
3434
public static String SELECT_TYPE_TO_EXCLUDE = "selectTypeToExclude";
3535

36-
public SelectSNVsStep(PipelineStepProvider provider, PipelineContext ctx)
36+
public SelectSNVsStep(PipelineStepProvider<?> provider, PipelineContext ctx)
3737
{
3838
super(provider, ctx, new SelectVariantsWrapper(ctx.getLogger()));
3939
}

0 commit comments

Comments
 (0)