|
| 1 | +package org.labkey.sequenceanalysis.run.variant; |
| 2 | + |
| 3 | +import htsjdk.samtools.util.Interval; |
| 4 | +import org.json.JSONObject; |
| 5 | +import org.labkey.api.pipeline.PipelineJobException; |
| 6 | +import org.labkey.api.sequenceanalysis.pipeline.AbstractPipelineStep; |
| 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.SequencePipelineService; |
| 12 | +import org.labkey.api.sequenceanalysis.pipeline.ToolParameterDescriptor; |
| 13 | +import org.labkey.api.sequenceanalysis.pipeline.VariantProcessingStep; |
| 14 | +import org.labkey.api.sequenceanalysis.pipeline.VariantProcessingStepOutputImpl; |
| 15 | +import org.labkey.api.sequenceanalysis.run.DISCVRSeqRunner; |
| 16 | + |
| 17 | +import javax.annotation.Nullable; |
| 18 | +import java.io.File; |
| 19 | +import java.util.ArrayList; |
| 20 | +import java.util.Arrays; |
| 21 | +import java.util.List; |
| 22 | + |
| 23 | +/** |
| 24 | + * User: bimber |
| 25 | + * Date: 6/15/2014 |
| 26 | + * Time: 12:39 PM |
| 27 | + */ |
| 28 | +public class SummarizeGenotypeQualityStep extends AbstractPipelineStep implements VariantProcessingStep |
| 29 | +{ |
| 30 | + public SummarizeGenotypeQualityStep(PipelineStepProvider<?> provider, PipelineContext ctx) |
| 31 | + { |
| 32 | + super(provider, ctx); |
| 33 | + } |
| 34 | + |
| 35 | + public static class Provider extends AbstractVariantProcessingStepProvider<SummarizeGenotypeQualityStep> implements RequiresPedigree |
| 36 | + { |
| 37 | + public Provider() |
| 38 | + { |
| 39 | + super("SummarizeGenotypeQuality", "Summarize Genotype Quality", "DISCVRseq", "This produces a TSV report summarizing genotype qualities by Genotype Type", Arrays.asList( |
| 40 | + ToolParameterDescriptor.create("excludeFiltered", "Exclude Filtered", "If selected, filtered sites will be ignored.", "checkbox", new JSONObject(){{ |
| 41 | + put("checked", false); |
| 42 | + }}, null) |
| 43 | + ), null, ""); |
| 44 | + } |
| 45 | + |
| 46 | + public SummarizeGenotypeQualityStep create(PipelineContext ctx) |
| 47 | + { |
| 48 | + return new SummarizeGenotypeQualityStep(this, ctx); |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + @Override |
| 53 | + public Output processVariants(File inputVCF, File outputDirectory, ReferenceGenome genome, @Nullable List<Interval> intervals) throws PipelineJobException |
| 54 | + { |
| 55 | + VariantProcessingStepOutputImpl output = new VariantProcessingStepOutputImpl(); |
| 56 | + |
| 57 | + DISCVRSeqRunner wrapper = new DISCVRSeqRunner(getPipelineCtx().getLogger()); |
| 58 | + List<String> args = new ArrayList<>(wrapper.getBaseArgs("SummarizeGenotypeQuality")); |
| 59 | + |
| 60 | + if (getProvider().getParameterByName("excludeFiltered").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Boolean.class, false)) |
| 61 | + { |
| 62 | + args.add("--excludeFiltered"); |
| 63 | + } |
| 64 | + |
| 65 | + if (intervals != null) |
| 66 | + { |
| 67 | + intervals.forEach(interval -> { |
| 68 | + args.add("-L"); |
| 69 | + args.add(interval.getContig() + ":" + interval.getStart() + "-" + interval.getEnd()); |
| 70 | + }); |
| 71 | + } |
| 72 | + |
| 73 | + args.add("-V"); |
| 74 | + args.add(inputVCF.getPath()); |
| 75 | + |
| 76 | + File outputTable = new File(outputDirectory, SequencePipelineService.get().getUnzippedBaseName(inputVCF.getName()) + ".gq.txt"); |
| 77 | + args.add("-O"); |
| 78 | + args.add(outputTable.getPath()); |
| 79 | + |
| 80 | + wrapper.execute(args); |
| 81 | + |
| 82 | + output.addInput(inputVCF, "Input VCF"); |
| 83 | + output.addOutput(outputTable, "Genotype Quality Summary"); |
| 84 | + |
| 85 | + output.addSequenceOutput(outputTable, "Genotype Quality Summary for: " + inputVCF.getName(), "Genotype Quality Summary", null, null, genome.getGenomeId(), null); |
| 86 | + |
| 87 | + return output; |
| 88 | + } |
| 89 | +} |
0 commit comments