From 9ec8ca4952552a6734a55c70cee8f06fa624cc45 Mon Sep 17 00:00:00 2001 From: Megan Shand Date: Fri, 19 Aug 2022 15:02:52 -0400 Subject: [PATCH 01/13] adding argument to GenotypeGVCFs to keep only RAW_GT_COUNT (not all raw annotations) --- .../tools/walkers/GenotypeGVCFs.java | 9 +++++++- .../annotator/VariantAnnotatorEngine.java | 23 ++++++++++++++++++- .../walkers/GenotypeGVCFsIntegrationTest.java | 4 +++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java index cd652a0d5b9..abc43cf02b8 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java @@ -98,6 +98,7 @@ public final class GenotypeGVCFs extends VariantLocusWalker { public static final String ALL_SITES_SHORT_NAME = "all-sites"; public static final String KEEP_COMBINED_LONG_NAME = "keep-combined-raw-annotations"; public static final String KEEP_COMBINED_SHORT_NAME = "keep-combined"; + public static final String KEEP_RAW_GT_COUNT_LONG_NAME = "keep-raw-gt-count-annotation"; public static final String FORCE_OUTPUT_INTERVALS_NAME = "force-output-intervals"; @Argument(fullName = StandardArgumentDefinitions.OUTPUT_LONG_NAME, shortName = StandardArgumentDefinitions.OUTPUT_SHORT_NAME, @@ -145,6 +146,12 @@ public final class GenotypeGVCFs extends VariantLocusWalker { @Argument(fullName=KEEP_COMBINED_LONG_NAME, shortName = KEEP_COMBINED_SHORT_NAME, doc = "If specified, keep the combined raw annotations") protected boolean keepCombined = false; + /** + * If specified, keep the RAW_GT_COUNT annotation, even if raw annotations in general are not kept. + */ + @Argument(fullName=KEEP_RAW_GT_COUNT_LONG_NAME, doc="If specified, keep the RAW_GT_COUNT annotation, even if raw annotations in general are not kept.") + protected boolean keepRawGtCount = false; + @ArgumentCollection private GenotypeCalculationArgumentCollection genotypeArgs = new GenotypeCalculationArgumentCollection(); @@ -262,7 +269,7 @@ public void onTraversalStart() { Collections.emptyList(); Collection variantAnnotations = makeVariantAnnotations(); - annotationEngine = new VariantAnnotatorEngine(variantAnnotations, dbsnp.dbsnp, Collections.emptyList(), false, keepCombined); + annotationEngine = new VariantAnnotatorEngine(variantAnnotations, dbsnp.dbsnp, Collections.emptyList(), false, keepCombined, keepRawGtCount); merger = new ReferenceConfidenceVariantContextMerger(annotationEngine, getHeaderForVariants(), somaticInput, false, true); diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java index 139a73cd19d..ff3960f1639 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java @@ -43,6 +43,7 @@ public final class VariantAnnotatorEngine { private boolean expressionAlleleConcordance; private final boolean useRawAnnotations; private final boolean keepRawCombinedAnnotations; + private final boolean keepRawGtCountAnnotation; private final static Logger logger = LogManager.getLogger(VariantAnnotatorEngine.class); private final static OneShotLogger jumboAnnotationsLogger = new OneShotLogger(VariantAnnotatorEngine.class); @@ -59,12 +60,14 @@ public final class VariantAnnotatorEngine { * @param useRaw When this is set to true, the annotation engine will call {@link ReducibleAnnotation#annotateRawData(ReferenceContext, VariantContext, AlleleLikelihoods)} * on annotations that extend {@link ReducibleAnnotation}, instead of {@link InfoFieldAnnotation#annotate(ReferenceContext, VariantContext, AlleleLikelihoods)}, * @param keepCombined If true, retain the combined raw annotation values instead of removing them after finalizing + * @param keepRawGtCount If true, retain the RAW_GT_COUNT annotation even if other raw annotations are removed */ public VariantAnnotatorEngine(final Collection annotationList, final FeatureInput dbSNPInput, final List> featureInputs, final boolean useRaw, - boolean keepCombined){ + boolean keepCombined, + boolean keepRawGtCount){ Utils.nonNull(featureInputs, "comparisonFeatureInputs is null"); infoAnnotations = new ArrayList<>(); genotypeAnnotations = new ArrayList<>(); @@ -87,6 +90,7 @@ public VariantAnnotatorEngine(final Collection annotationList, reducibleKeys = new LinkedHashSet<>(); useRawAnnotations = useRaw; keepRawCombinedAnnotations = keepCombined; + keepRawGtCountAnnotation = keepRawGtCount; for (InfoFieldAnnotation annot : infoAnnotations) { if (annot instanceof ReducibleAnnotation) { for (final String rawKey : ((ReducibleAnnotation) annot).getRawKeyNames()) { @@ -96,6 +100,14 @@ public VariantAnnotatorEngine(final Collection annotationList, } } + public VariantAnnotatorEngine(final Collection annotationList, + final FeatureInput dbSNPInput, + final List> featureInputs, + final boolean useRaw, + boolean keepCombined){ + this(annotationList, dbSNPInput, featureInputs, useRaw, keepCombined, false); + } + private VariantOverlapAnnotator initializeOverlapAnnotator(final FeatureInput dbSNPInput, final List> featureInputs) { final Map, String> overlaps = new LinkedHashMap<>(); for ( final FeatureInput fi : featureInputs) { @@ -253,6 +265,11 @@ public Map combineAnnotations(final List allelesList, Ma public VariantContext finalizeAnnotations(VariantContext vc, VariantContext originalVC) { final Map variantAnnotations = new LinkedHashMap<>(vc.getAttributes()); + // save RAW_GT_COUNT if it's requested to be kept + final Object rawGtCount = keepRawGtCountAnnotation && + variantAnnotations.containsKey(GATKVCFConstants.RAW_GENOTYPE_COUNT_KEY) ? + variantAnnotations.get(GATKVCFConstants.RAW_GENOTYPE_COUNT_KEY) : null; + // go through all the requested info annotationTypes for (final InfoFieldAnnotation annotationType : infoAnnotations) { if (annotationType instanceof ReducibleAnnotation) { @@ -280,6 +297,10 @@ public VariantContext finalizeAnnotations(VariantContext vc, VariantContext orig variantAnnotations.remove(GATKVCFConstants.VARIANT_DEPTH_KEY); variantAnnotations.remove(GATKVCFConstants.RAW_GENOTYPE_COUNT_KEY); } + //add back RAW_GT_COUNT if it is specifically requested + if (keepRawGtCountAnnotation && rawGtCount != null ) { + variantAnnotations.put(GATKVCFConstants.RAW_GENOTYPE_COUNT_KEY, rawGtCount); + } // generate a new annotated VC final VariantContextBuilder builder = new VariantContextBuilder(vc).attributes(variantAnnotations); diff --git a/src/test/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsIntegrationTest.java b/src/test/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsIntegrationTest.java index 21e20320bc3..9b0afece5e8 100644 --- a/src/test/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsIntegrationTest.java +++ b/src/test/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsIntegrationTest.java @@ -930,7 +930,8 @@ public void testRawGtCountAnnotation() { args.addReference(b37_reference_20_21) .addVCF(reblockedGVCF) .addOutput(output) - .add("keep-combined-raw-annotations", true) + .add(GenotypeGVCFs.KEEP_COMBINED_LONG_NAME, false) + .add(GenotypeGVCFs.KEEP_RAW_GT_COUNT_LONG_NAME, true) .add("A", "RawGtCount"); runCommandLine(args); @@ -942,6 +943,7 @@ public void testRawGtCountAnnotation() { Assert.assertEquals(rawGtCount.get(0), "."); Assert.assertEquals(rawGtCount.get(1), "2"); Assert.assertEquals(rawGtCount.get(2), "0"); + Assert.assertFalse(vc.getAttributes().containsKey(GATKVCFConstants.RAW_MAPPING_QUALITY_WITH_DEPTH_KEY)); } } From 4a8b3cf330fb4f41cde4bc27538044fa2e0cf7d2 Mon Sep 17 00:00:00 2001 From: Megan Shand Date: Wed, 24 Aug 2022 15:01:18 -0400 Subject: [PATCH 02/13] making the argument more general --- .../tools/walkers/GenotypeGVCFs.java | 14 ++++---- .../annotator/VariantAnnotatorEngine.java | 36 ++++++++++++------- .../walkers/GenotypeGVCFsIntegrationTest.java | 4 +-- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java index abc43cf02b8..620bf0f8441 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java @@ -98,7 +98,8 @@ public final class GenotypeGVCFs extends VariantLocusWalker { public static final String ALL_SITES_SHORT_NAME = "all-sites"; public static final String KEEP_COMBINED_LONG_NAME = "keep-combined-raw-annotations"; public static final String KEEP_COMBINED_SHORT_NAME = "keep-combined"; - public static final String KEEP_RAW_GT_COUNT_LONG_NAME = "keep-raw-gt-count-annotation"; + public static final String KEEP_SPECIFIED_RAW_ANNOTATION_LONG_NAME = "keep-specific-raw-annotation"; + public static final String KEEP_SPECIFIED_RAW_ANNOTATION_SHORT_NAME = "keep-raw"; public static final String FORCE_OUTPUT_INTERVALS_NAME = "force-output-intervals"; @Argument(fullName = StandardArgumentDefinitions.OUTPUT_LONG_NAME, shortName = StandardArgumentDefinitions.OUTPUT_SHORT_NAME, @@ -133,7 +134,6 @@ public final class GenotypeGVCFs extends VariantLocusWalker { doc = "LOD threshold to emit variant to VCF.") protected double tlodThreshold = 3.5; //allow for some lower quality variants - /** * Margin of error in allele fraction to consider a somatic variant homoplasmic, i.e. if there is less than a 0.1% reference allele fraction, those reads are likely errors */ @@ -141,16 +141,16 @@ public final class GenotypeGVCFs extends VariantLocusWalker { protected double afTolerance = 1e-3; //based on Q30 as a "good" base quality score /** - * If specified, keep the combined raw annotations (e.g. AS_SB_TABLE) after genotyping. This is applicable to Allele-Specific annotations + * If specified, keep all the combined raw annotations (e.g. AS_SB_TABLE) after genotyping. This is applicable to Allele-Specific annotations */ @Argument(fullName=KEEP_COMBINED_LONG_NAME, shortName = KEEP_COMBINED_SHORT_NAME, doc = "If specified, keep the combined raw annotations") protected boolean keepCombined = false; /** - * If specified, keep the RAW_GT_COUNT annotation, even if raw annotations in general are not kept. + * Keep only the specific combined raw annotations specified (removing the other raw annotations if keep-combined-raw-annotations is not set). */ - @Argument(fullName=KEEP_RAW_GT_COUNT_LONG_NAME, doc="If specified, keep the RAW_GT_COUNT annotation, even if raw annotations in general are not kept.") - protected boolean keepRawGtCount = false; + @Argument(fullName= KEEP_SPECIFIED_RAW_ANNOTATION_LONG_NAME, shortName = KEEP_SPECIFIED_RAW_ANNOTATION_SHORT_NAME, doc="Keep only the specific combined raw annotations specified (removing the other raw annotations).") + protected List keepSpecifiedRawAnnotations = new ArrayList<>(); @ArgumentCollection private GenotypeCalculationArgumentCollection genotypeArgs = new GenotypeCalculationArgumentCollection(); @@ -269,7 +269,7 @@ public void onTraversalStart() { Collections.emptyList(); Collection variantAnnotations = makeVariantAnnotations(); - annotationEngine = new VariantAnnotatorEngine(variantAnnotations, dbsnp.dbsnp, Collections.emptyList(), false, keepCombined, keepRawGtCount); + annotationEngine = new VariantAnnotatorEngine(variantAnnotations, dbsnp.dbsnp, Collections.emptyList(), false, keepCombined, keepSpecifiedRawAnnotations); merger = new ReferenceConfidenceVariantContextMerger(annotationEngine, getHeaderForVariants(), somaticInput, false, true); diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java index ff3960f1639..e5ef2f12a53 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java @@ -4,12 +4,14 @@ import htsjdk.variant.vcf.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions; import org.broadinstitute.hellbender.engine.FeatureContext; import org.broadinstitute.hellbender.engine.FeatureDataSource; import org.broadinstitute.hellbender.engine.FeatureInput; import org.broadinstitute.hellbender.engine.ReferenceContext; import org.broadinstitute.hellbender.exceptions.GATKException; import org.broadinstitute.hellbender.exceptions.UserException; +import org.broadinstitute.hellbender.tools.walkers.GenotypeGVCFs; import org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.ReducibleAnnotation; import org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.ReducibleAnnotationData; import org.broadinstitute.hellbender.utils.Utils; @@ -43,7 +45,7 @@ public final class VariantAnnotatorEngine { private boolean expressionAlleleConcordance; private final boolean useRawAnnotations; private final boolean keepRawCombinedAnnotations; - private final boolean keepRawGtCountAnnotation; + private final List rawAnnotationsToKeep; private final static Logger logger = LogManager.getLogger(VariantAnnotatorEngine.class); private final static OneShotLogger jumboAnnotationsLogger = new OneShotLogger(VariantAnnotatorEngine.class); @@ -60,19 +62,20 @@ public final class VariantAnnotatorEngine { * @param useRaw When this is set to true, the annotation engine will call {@link ReducibleAnnotation#annotateRawData(ReferenceContext, VariantContext, AlleleLikelihoods)} * on annotations that extend {@link ReducibleAnnotation}, instead of {@link InfoFieldAnnotation#annotate(ReferenceContext, VariantContext, AlleleLikelihoods)}, * @param keepCombined If true, retain the combined raw annotation values instead of removing them after finalizing - * @param keepRawGtCount If true, retain the RAW_GT_COUNT annotation even if other raw annotations are removed + * @param rawAnnotationsToKeep List of raw annotations to keep even when others are removed */ public VariantAnnotatorEngine(final Collection annotationList, final FeatureInput dbSNPInput, final List> featureInputs, final boolean useRaw, boolean keepCombined, - boolean keepRawGtCount){ + final List rawAnnotationsToKeep){ Utils.nonNull(featureInputs, "comparisonFeatureInputs is null"); infoAnnotations = new ArrayList<>(); genotypeAnnotations = new ArrayList<>(); jumboInfoAnnotations = new ArrayList<>(); jumboGenotypeAnnotations = new ArrayList<>(); + final List variantAnnotationKeys = new ArrayList<>(); for (Annotation annot : annotationList) { if (annot instanceof InfoFieldAnnotation) { infoAnnotations.add((InfoFieldAnnotation) annot); @@ -85,12 +88,18 @@ public VariantAnnotatorEngine(final Collection annotationList, } else { throw new GATKException.ShouldNeverReachHereException("Unexpected annotation type: " + annot.getClass().getName()); } + variantAnnotationKeys.addAll(((VariantAnnotation) annot).getKeyNames()); } variantOverlapAnnotator = initializeOverlapAnnotator(dbSNPInput, featureInputs); reducibleKeys = new LinkedHashSet<>(); useRawAnnotations = useRaw; keepRawCombinedAnnotations = keepCombined; - keepRawGtCountAnnotation = keepRawGtCount; + for (String rawAnnot : rawAnnotationsToKeep) { + if (!variantAnnotationKeys.contains(rawAnnot)) { + throw new UserException("Requested --" + GenotypeGVCFs.KEEP_SPECIFIED_RAW_ANNOTATION_LONG_NAME + ": " + rawAnnot + " is not available. Add requested annotation with --" + StandardArgumentDefinitions.ANNOTATION_LONG_NAME + "."); + } + } + this.rawAnnotationsToKeep = rawAnnotationsToKeep; for (InfoFieldAnnotation annot : infoAnnotations) { if (annot instanceof ReducibleAnnotation) { for (final String rawKey : ((ReducibleAnnotation) annot).getRawKeyNames()) { @@ -105,7 +114,7 @@ public VariantAnnotatorEngine(final Collection annotationList, final List> featureInputs, final boolean useRaw, boolean keepCombined){ - this(annotationList, dbSNPInput, featureInputs, useRaw, keepCombined, false); + this(annotationList, dbSNPInput, featureInputs, useRaw, keepCombined, Collections.emptyList()); } private VariantOverlapAnnotator initializeOverlapAnnotator(final FeatureInput dbSNPInput, final List> featureInputs) { @@ -265,10 +274,13 @@ public Map combineAnnotations(final List allelesList, Ma public VariantContext finalizeAnnotations(VariantContext vc, VariantContext originalVC) { final Map variantAnnotations = new LinkedHashMap<>(vc.getAttributes()); - // save RAW_GT_COUNT if it's requested to be kept - final Object rawGtCount = keepRawGtCountAnnotation && - variantAnnotations.containsKey(GATKVCFConstants.RAW_GENOTYPE_COUNT_KEY) ? - variantAnnotations.get(GATKVCFConstants.RAW_GENOTYPE_COUNT_KEY) : null; + //save annotations that have been requested to be kept + final Map savedRawAnnotations = new LinkedHashMap<>(); + for(String rawAnnot : rawAnnotationsToKeep) { + if (variantAnnotations.containsKey(rawAnnot)) { + savedRawAnnotations.put(rawAnnot, variantAnnotations.get(rawAnnot)); + } + } // go through all the requested info annotationTypes for (final InfoFieldAnnotation annotationType : infoAnnotations) { @@ -297,10 +309,8 @@ public VariantContext finalizeAnnotations(VariantContext vc, VariantContext orig variantAnnotations.remove(GATKVCFConstants.VARIANT_DEPTH_KEY); variantAnnotations.remove(GATKVCFConstants.RAW_GENOTYPE_COUNT_KEY); } - //add back RAW_GT_COUNT if it is specifically requested - if (keepRawGtCountAnnotation && rawGtCount != null ) { - variantAnnotations.put(GATKVCFConstants.RAW_GENOTYPE_COUNT_KEY, rawGtCount); - } + //add back raw annotations that have specifically been requested to keep + variantAnnotations.putAll(savedRawAnnotations); // generate a new annotated VC final VariantContextBuilder builder = new VariantContextBuilder(vc).attributes(variantAnnotations); diff --git a/src/test/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsIntegrationTest.java b/src/test/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsIntegrationTest.java index 9b0afece5e8..6df5498411c 100644 --- a/src/test/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsIntegrationTest.java +++ b/src/test/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsIntegrationTest.java @@ -43,8 +43,6 @@ import java.security.NoSuchAlgorithmException; import java.util.*; import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.function.IntUnaryOperator; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -931,7 +929,7 @@ public void testRawGtCountAnnotation() { .addVCF(reblockedGVCF) .addOutput(output) .add(GenotypeGVCFs.KEEP_COMBINED_LONG_NAME, false) - .add(GenotypeGVCFs.KEEP_RAW_GT_COUNT_LONG_NAME, true) + .add(GenotypeGVCFs.KEEP_SPECIFIED_RAW_ANNOTATION_LONG_NAME, GATKVCFConstants.RAW_GENOTYPE_COUNT_KEY) .add("A", "RawGtCount"); runCommandLine(args); From 522cd29ea5275f2e0e571c24fdd0548b262b0c88 Mon Sep 17 00:00:00 2001 From: Megan Shand Date: Wed, 24 Aug 2022 15:55:08 -0400 Subject: [PATCH 03/13] making arg optional --- .../broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java index 620bf0f8441..25b01b1204d 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java @@ -149,7 +149,8 @@ public final class GenotypeGVCFs extends VariantLocusWalker { /** * Keep only the specific combined raw annotations specified (removing the other raw annotations if keep-combined-raw-annotations is not set). */ - @Argument(fullName= KEEP_SPECIFIED_RAW_ANNOTATION_LONG_NAME, shortName = KEEP_SPECIFIED_RAW_ANNOTATION_SHORT_NAME, doc="Keep only the specific combined raw annotations specified (removing the other raw annotations).") + @Argument(fullName= KEEP_SPECIFIED_RAW_ANNOTATION_LONG_NAME, shortName = KEEP_SPECIFIED_RAW_ANNOTATION_SHORT_NAME, optional = true, + doc="Keep only the specific combined raw annotations specified (removing the other raw annotations).") protected List keepSpecifiedRawAnnotations = new ArrayList<>(); @ArgumentCollection From 470c858316dbad9a22f360799a3546c1cccef1e5 Mon Sep 17 00:00:00 2001 From: Megan Shand Date: Wed, 21 Sep 2022 14:02:32 -0400 Subject: [PATCH 04/13] WIP --- .../broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java | 2 +- .../walkers/annotator/allelespecific/ReducibleAnnotation.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java index 25b01b1204d..b1114c0f475 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java @@ -141,7 +141,7 @@ public final class GenotypeGVCFs extends VariantLocusWalker { protected double afTolerance = 1e-3; //based on Q30 as a "good" base quality score /** - * If specified, keep all the combined raw annotations (e.g. AS_SB_TABLE) after genotyping. This is applicable to Allele-Specific annotations + * If specified, keep all the combined raw annotations (e.g. AS_SB_TABLE) after genotyping. This is applicable to Allele-Specific annotations. See */ @Argument(fullName=KEEP_COMBINED_LONG_NAME, shortName = KEEP_COMBINED_SHORT_NAME, doc = "If specified, keep the combined raw annotations") protected boolean keepCombined = false; diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/allelespecific/ReducibleAnnotation.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/allelespecific/ReducibleAnnotation.java index 5b3c8d68988..4b2541bc84f 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/allelespecific/ReducibleAnnotation.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/allelespecific/ReducibleAnnotation.java @@ -18,6 +18,9 @@ /** * An interface for annotations that are calculated using raw data across samples, rather than the median (or median of median) of samples values + * The Raw annotation keeps some summary (one example might be a histogram of the raw values for each sample) of the individual sample (or allele) + * level annotation. As the annotations are combined across multiple samples the raw annotation continues to contain individual values while + * the final reduced annotation will typically be a summary statistic from these raw values. * */ public interface ReducibleAnnotation extends Annotation { From bf9fffce2f05d1efa8722955e93a3bf283cd0d5a Mon Sep 17 00:00:00 2001 From: Megan Shand Date: Mon, 26 Sep 2022 11:27:04 -0400 Subject: [PATCH 05/13] WIP - adding annotation list as argument --- .../tools/walkers/GenotypeGVCFs.java | 26 +++++----- ...typeGVCFsAnnotationArgumentCollection.java | 49 +++++++++++++++++++ .../annotator/VariantAnnotatorEngine.java | 13 +++-- .../walkers/GenotypeGVCFsIntegrationTest.java | 3 +- 4 files changed, 72 insertions(+), 19 deletions(-) create mode 100644 src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java index b1114c0f475..5dddbab0ff3 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java @@ -9,6 +9,7 @@ import htsjdk.variant.vcf.VCFHeaderLine; import org.broadinstitute.barclay.argparser.*; import org.broadinstitute.barclay.help.DocumentedFeature; +import org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKAnnotationPluginDescriptor; import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions; import org.broadinstitute.hellbender.cmdline.argumentcollections.DbsnpArgumentCollection; import org.broadinstitute.hellbender.cmdline.programgroups.ShortVariantDiscoveryProgramGroup; @@ -28,6 +29,7 @@ import org.broadinstitute.hellbender.tools.walkers.mutect.M2ArgumentCollection; import org.broadinstitute.hellbender.utils.*; import org.broadinstitute.hellbender.utils.variant.GATKVariantContextUtils; +import org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.ReducibleAnnotation; import java.util.*; import java.util.stream.Collectors; @@ -98,8 +100,6 @@ public final class GenotypeGVCFs extends VariantLocusWalker { public static final String ALL_SITES_SHORT_NAME = "all-sites"; public static final String KEEP_COMBINED_LONG_NAME = "keep-combined-raw-annotations"; public static final String KEEP_COMBINED_SHORT_NAME = "keep-combined"; - public static final String KEEP_SPECIFIED_RAW_ANNOTATION_LONG_NAME = "keep-specific-raw-annotation"; - public static final String KEEP_SPECIFIED_RAW_ANNOTATION_SHORT_NAME = "keep-raw"; public static final String FORCE_OUTPUT_INTERVALS_NAME = "force-output-intervals"; @Argument(fullName = StandardArgumentDefinitions.OUTPUT_LONG_NAME, shortName = StandardArgumentDefinitions.OUTPUT_SHORT_NAME, @@ -141,24 +141,21 @@ public final class GenotypeGVCFs extends VariantLocusWalker { protected double afTolerance = 1e-3; //based on Q30 as a "good" base quality score /** - * If specified, keep all the combined raw annotations (e.g. AS_SB_TABLE) after genotyping. This is applicable to Allele-Specific annotations. See + * If specified, keep all the combined raw annotations (e.g. AS_SB_TABLE) after genotyping. This is applicable to Allele-Specific annotations. See {@link ReducibleAnnotation} */ - @Argument(fullName=KEEP_COMBINED_LONG_NAME, shortName = KEEP_COMBINED_SHORT_NAME, doc = "If specified, keep the combined raw annotations") + @Argument(fullName=KEEP_COMBINED_LONG_NAME, shortName = KEEP_COMBINED_SHORT_NAME, doc = "If specified, keep the combined raw annotations", + mutex = {GenotypeGVCFsAnnotationArgumentCollection.KEEP_SPECIFIED_RAW_COMBINED_ANNOTATION_LONG_NAME}) protected boolean keepCombined = false; - /** - * Keep only the specific combined raw annotations specified (removing the other raw annotations if keep-combined-raw-annotations is not set). - */ - @Argument(fullName= KEEP_SPECIFIED_RAW_ANNOTATION_LONG_NAME, shortName = KEEP_SPECIFIED_RAW_ANNOTATION_SHORT_NAME, optional = true, - doc="Keep only the specific combined raw annotations specified (removing the other raw annotations).") - protected List keepSpecifiedRawAnnotations = new ArrayList<>(); - @ArgumentCollection private GenotypeCalculationArgumentCollection genotypeArgs = new GenotypeCalculationArgumentCollection(); @ArgumentCollection private GenomicsDBArgumentCollection genomicsdbArgs = new GenomicsDBArgumentCollection(); + @ArgumentCollection + private GenotypeGVCFsAnnotationArgumentCollection annotationArgs = new GenotypeGVCFsAnnotationArgumentCollection(); + /** * This option can only be activated if intervals are specified. */ @@ -270,7 +267,12 @@ public void onTraversalStart() { Collections.emptyList(); Collection variantAnnotations = makeVariantAnnotations(); - annotationEngine = new VariantAnnotatorEngine(variantAnnotations, dbsnp.dbsnp, Collections.emptyList(), false, keepCombined, keepSpecifiedRawAnnotations); + + //TODO: this isn't right. I need to intialize the annoationArgs somehow, but I don't think this does it. + final GATKAnnotationPluginDescriptor annotationPlugin = + new GATKAnnotationPluginDescriptor(annotationArgs, Collections.emptyList(), Collections.emptyList()); + Collection rawCombinedAnnotationsToKeep = annotationPlugin.getResolvedInstances(); + annotationEngine = new VariantAnnotatorEngine(variantAnnotations, dbsnp.dbsnp, Collections.emptyList(), false, keepCombined, rawCombinedAnnotationsToKeep); merger = new ReferenceConfidenceVariantContextMerger(annotationEngine, getHeaderForVariants(), somaticInput, false, true); diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java new file mode 100644 index 00000000000..2cc2d8d8754 --- /dev/null +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java @@ -0,0 +1,49 @@ +package org.broadinstitute.hellbender.tools.walkers; + +import org.broadinstitute.barclay.argparser.Argument; +import org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKAnnotationArgumentCollection; +import org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.ReducibleAnnotation; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class GenotypeGVCFsAnnotationArgumentCollection extends GATKAnnotationArgumentCollection { + private static final long serialVersionUID = 1L; + + public static final String KEEP_SPECIFIED_RAW_COMBINED_ANNOTATION_LONG_NAME = "keep-specific-combined-raw-annotation"; + public static final String KEEP_SPECIFIED_RAW_COMBINED_ANNOTATION_SHORT_NAME = "keep-specific-combined"; + + /** + * Keep only the specific combined raw annotations specified (removing the other raw annotations if keep-combined-raw-annotations is not set). See {@link ReducibleAnnotation} + */ + @Argument(fullName= KEEP_SPECIFIED_RAW_COMBINED_ANNOTATION_LONG_NAME, shortName = KEEP_SPECIFIED_RAW_COMBINED_ANNOTATION_SHORT_NAME, optional = true, + mutex = {GenotypeGVCFs.KEEP_COMBINED_LONG_NAME}, + doc="Keep only the specific combined raw annotations specified (removing the other raw annotations). Duplicate values will be ignored.") + protected List keepSpecifiedCombined = new ArrayList<>(); + + @Override + public List getUserEnabledAnnotationNames() { + return Collections.unmodifiableList(keepSpecifiedCombined); + } + + @Override + public List getUserEnabledAnnotationGroups() { + return Collections.emptyList(); + } + + @Override + public List getUserDisabledAnnotationNames() { + return Collections.emptyList(); + } + + @Override + public boolean getDisableToolDefaultAnnotations() { + return false; + } + + @Override + public boolean getEnableAllAnnotations() { + return false; + } +} diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java index e5ef2f12a53..98cffa47dcc 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java @@ -12,6 +12,7 @@ import org.broadinstitute.hellbender.exceptions.GATKException; import org.broadinstitute.hellbender.exceptions.UserException; import org.broadinstitute.hellbender.tools.walkers.GenotypeGVCFs; +import org.broadinstitute.hellbender.tools.walkers.GenotypeGVCFsAnnotationArgumentCollection; import org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.ReducibleAnnotation; import org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.ReducibleAnnotationData; import org.broadinstitute.hellbender.utils.Utils; @@ -68,14 +69,15 @@ public VariantAnnotatorEngine(final Collection annotationList, final FeatureInput dbSNPInput, final List> featureInputs, final boolean useRaw, - boolean keepCombined, - final List rawAnnotationsToKeep){ + final boolean keepCombined, + final Collection rawAnnotationsToKeep){ Utils.nonNull(featureInputs, "comparisonFeatureInputs is null"); infoAnnotations = new ArrayList<>(); genotypeAnnotations = new ArrayList<>(); jumboInfoAnnotations = new ArrayList<>(); jumboGenotypeAnnotations = new ArrayList<>(); final List variantAnnotationKeys = new ArrayList<>(); + final List rawVariantAnnotationKeysToKeep = new ArrayList<>(); for (Annotation annot : annotationList) { if (annot instanceof InfoFieldAnnotation) { infoAnnotations.add((InfoFieldAnnotation) annot); @@ -94,12 +96,13 @@ public VariantAnnotatorEngine(final Collection annotationList, reducibleKeys = new LinkedHashSet<>(); useRawAnnotations = useRaw; keepRawCombinedAnnotations = keepCombined; - for (String rawAnnot : rawAnnotationsToKeep) { + for (final Annotation rawAnnot : rawAnnotationsToKeep) { if (!variantAnnotationKeys.contains(rawAnnot)) { - throw new UserException("Requested --" + GenotypeGVCFs.KEEP_SPECIFIED_RAW_ANNOTATION_LONG_NAME + ": " + rawAnnot + " is not available. Add requested annotation with --" + StandardArgumentDefinitions.ANNOTATION_LONG_NAME + "."); + throw new UserException("Requested --" + GenotypeGVCFsAnnotationArgumentCollection.KEEP_SPECIFIED_RAW_COMBINED_ANNOTATION_LONG_NAME + ": " + rawAnnot + " is not available. Add requested annotation with --" + StandardArgumentDefinitions.ANNOTATION_LONG_NAME + "."); } + rawVariantAnnotationKeysToKeep.addAll(((VariantAnnotation) rawAnnot).getKeyNames()); } - this.rawAnnotationsToKeep = rawAnnotationsToKeep; + this.rawAnnotationsToKeep = rawVariantAnnotationKeysToKeep; for (InfoFieldAnnotation annot : infoAnnotations) { if (annot instanceof ReducibleAnnotation) { for (final String rawKey : ((ReducibleAnnotation) annot).getRawKeyNames()) { diff --git a/src/test/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsIntegrationTest.java b/src/test/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsIntegrationTest.java index 6df5498411c..ae6310f30f2 100644 --- a/src/test/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsIntegrationTest.java +++ b/src/test/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsIntegrationTest.java @@ -928,8 +928,7 @@ public void testRawGtCountAnnotation() { args.addReference(b37_reference_20_21) .addVCF(reblockedGVCF) .addOutput(output) - .add(GenotypeGVCFs.KEEP_COMBINED_LONG_NAME, false) - .add(GenotypeGVCFs.KEEP_SPECIFIED_RAW_ANNOTATION_LONG_NAME, GATKVCFConstants.RAW_GENOTYPE_COUNT_KEY) + .add(GenotypeGVCFsAnnotationArgumentCollection.KEEP_SPECIFIED_RAW_COMBINED_ANNOTATION_LONG_NAME, "RawGtCount") .add("A", "RawGtCount"); runCommandLine(args); From 263d2d8ac7609e6e3e73dce618910d5f020b667f Mon Sep 17 00:00:00 2001 From: Chris Norman Date: Mon, 26 Sep 2022 15:49:15 -0400 Subject: [PATCH 06/13] Integrate GenotypeGVCFsAnnotationArgumentCollection. --- .../tools/walkers/GenotypeGVCFs.java | 23 +++++++++++-------- ...typeGVCFsAnnotationArgumentCollection.java | 4 ++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java index 5dddbab0ff3..0e51cac5120 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java @@ -10,6 +10,7 @@ import org.broadinstitute.barclay.argparser.*; import org.broadinstitute.barclay.help.DocumentedFeature; import org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKAnnotationPluginDescriptor; +import org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor; import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions; import org.broadinstitute.hellbender.cmdline.argumentcollections.DbsnpArgumentCollection; import org.broadinstitute.hellbender.cmdline.programgroups.ShortVariantDiscoveryProgramGroup; @@ -153,9 +154,6 @@ public final class GenotypeGVCFs extends VariantLocusWalker { @ArgumentCollection private GenomicsDBArgumentCollection genomicsdbArgs = new GenomicsDBArgumentCollection(); - @ArgumentCollection - private GenotypeGVCFsAnnotationArgumentCollection annotationArgs = new GenotypeGVCFsAnnotationArgumentCollection(); - /** * This option can only be activated if intervals are specified. */ @@ -226,6 +224,16 @@ protected GenomicsDBOptions getGenomicsDBOptions() { @Override public boolean useVariantAnnotations() { return true;} + @Override + public List> getPluginDescriptors() { + GATKReadFilterPluginDescriptor readFilterDescriptor = new GATKReadFilterPluginDescriptor(getDefaultReadFilters()); + return useVariantAnnotations()? + Arrays.asList(readFilterDescriptor, new GATKAnnotationPluginDescriptor( + new GenotypeGVCFsAnnotationArgumentCollection(), + getDefaultVariantAnnotations(), getDefaultVariantAnnotationGroups())): + Collections.singletonList(readFilterDescriptor); + } + @Override public List> getDefaultVariantAnnotationGroups() { return Arrays.asList(StandardAnnotation.class); @@ -266,12 +274,9 @@ public void onTraversalStart() { intervals = hasUserSuppliedIntervals() ? intervalArgumentCollection.getIntervals(getBestAvailableSequenceDictionary()) : Collections.emptyList(); - Collection variantAnnotations = makeVariantAnnotations(); - - //TODO: this isn't right. I need to intialize the annoationArgs somehow, but I don't think this does it. - final GATKAnnotationPluginDescriptor annotationPlugin = - new GATKAnnotationPluginDescriptor(annotationArgs, Collections.emptyList(), Collections.emptyList()); - Collection rawCombinedAnnotationsToKeep = annotationPlugin.getResolvedInstances(); + final Collection variantAnnotations = makeVariantAnnotations(); + final Collection rawCombinedAnnotationsToKeep = + getCommandLineParser().getPluginDescriptor(GATKAnnotationPluginDescriptor.class).getResolvedInstances(); annotationEngine = new VariantAnnotatorEngine(variantAnnotations, dbsnp.dbsnp, Collections.emptyList(), false, keepCombined, rawCombinedAnnotationsToKeep); merger = new ReferenceConfidenceVariantContextMerger(annotationEngine, getHeaderForVariants(), somaticInput, false, true); diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java index 2cc2d8d8754..fe6352021b8 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java @@ -1,14 +1,14 @@ package org.broadinstitute.hellbender.tools.walkers; import org.broadinstitute.barclay.argparser.Argument; -import org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKAnnotationArgumentCollection; +import org.broadinstitute.hellbender.cmdline.GATKPlugin.DefaultGATKVariantAnnotationArgumentCollection; import org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.ReducibleAnnotation; import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class GenotypeGVCFsAnnotationArgumentCollection extends GATKAnnotationArgumentCollection { +public class GenotypeGVCFsAnnotationArgumentCollection extends DefaultGATKVariantAnnotationArgumentCollection { private static final long serialVersionUID = 1L; public static final String KEEP_SPECIFIED_RAW_COMBINED_ANNOTATION_LONG_NAME = "keep-specific-combined-raw-annotation"; From 7462183ab6327076bed8c4065b51a3bd90625822 Mon Sep 17 00:00:00 2001 From: Megan Shand Date: Fri, 30 Sep 2022 12:00:01 -0400 Subject: [PATCH 07/13] trying to fix annotation argument --- ...TKVariantAnnotationArgumentCollection.java | 4 ++- .../GATKAnnotationArgumentCollection.java | 3 +++ .../GATKAnnotationPluginDescriptor.java | 9 ++++++- .../tools/walkers/GenotypeGVCFs.java | 8 +++--- ...typeGVCFsAnnotationArgumentCollection.java | 26 ++----------------- .../annotator/VariantAnnotatorEngine.java | 3 +-- .../allelespecific/ReducibleAnnotation.java | 3 --- 7 files changed, 22 insertions(+), 34 deletions(-) diff --git a/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/DefaultGATKVariantAnnotationArgumentCollection.java b/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/DefaultGATKVariantAnnotationArgumentCollection.java index 68beb4bdf26..70f1a6f0284 100644 --- a/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/DefaultGATKVariantAnnotationArgumentCollection.java +++ b/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/DefaultGATKVariantAnnotationArgumentCollection.java @@ -1,6 +1,5 @@ package org.broadinstitute.hellbender.cmdline.GATKPlugin; -import com.google.common.collect.Lists; import org.broadinstitute.barclay.argparser.Advanced; import org.broadinstitute.barclay.argparser.Argument; import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions; @@ -82,4 +81,7 @@ public boolean getDisableToolDefaultAnnotations() { public boolean getEnableAllAnnotations() { return enableAllAnnotations; } + + @Override + public List getKeepSpecifiedCombinedAnnotationNames() { return Collections.emptyList(); } } diff --git a/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationArgumentCollection.java b/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationArgumentCollection.java index fd8ef623b91..8d214783c35 100644 --- a/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationArgumentCollection.java +++ b/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationArgumentCollection.java @@ -37,4 +37,7 @@ public abstract class GATKAnnotationArgumentCollection implements Serializable { * Returns {@code true} if all annotations are enabled; {@code false} otherwise. */ public abstract boolean getEnableAllAnnotations(); + + + public abstract List getKeepSpecifiedCombinedAnnotationNames(); } \ No newline at end of file diff --git a/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationPluginDescriptor.java b/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationPluginDescriptor.java index c03be1fbc76..15d875a4fb4 100644 --- a/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationPluginDescriptor.java +++ b/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationPluginDescriptor.java @@ -16,7 +16,6 @@ import org.broadinstitute.hellbender.utils.config.ConfigFactory; import org.broadinstitute.hellbender.utils.config.GATKConfig; -import java.io.File; import java.lang.reflect.Modifier; import java.util.*; import java.util.stream.Collectors; @@ -497,4 +496,12 @@ public Class getClassForPluginHelp(final String pluginName) { return allDiscoveredAnnotations.containsKey(pluginName) ? allDiscoveredAnnotations.get(pluginName).getClass() : null; } + public Map getAllDiscoveredAnnotations() { + return this.allDiscoveredAnnotations; + } + + public GATKAnnotationArgumentCollection getUserArgs() { + return this.userArgs; + } + } diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java index 0e51cac5120..0a28400f6d2 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java @@ -275,9 +275,11 @@ public void onTraversalStart() { Collections.emptyList(); final Collection variantAnnotations = makeVariantAnnotations(); - final Collection rawCombinedAnnotationsToKeep = - getCommandLineParser().getPluginDescriptor(GATKAnnotationPluginDescriptor.class).getResolvedInstances(); - annotationEngine = new VariantAnnotatorEngine(variantAnnotations, dbsnp.dbsnp, Collections.emptyList(), false, keepCombined, rawCombinedAnnotationsToKeep); + final GATKAnnotationPluginDescriptor pluginDescriptor = getCommandLineParser().getPluginDescriptor(GATKAnnotationPluginDescriptor.class); + final List annotationStringsToKeep = pluginDescriptor.getUserArgs().getKeepSpecifiedCombinedAnnotationNames(); + final Map allDiscoveredAnnotations = pluginDescriptor.getAllDiscoveredAnnotations(); + final Collection annotationsToKeep = annotationStringsToKeep.stream().map(allDiscoveredAnnotations::get).collect(Collectors.toList()); + annotationEngine = new VariantAnnotatorEngine(variantAnnotations, dbsnp.dbsnp, Collections.emptyList(), false, keepCombined, annotationsToKeep); merger = new ReferenceConfidenceVariantContextMerger(annotationEngine, getHeaderForVariants(), somaticInput, false, true); diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java index fe6352021b8..8bd5a4250a1 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java @@ -10,7 +10,7 @@ public class GenotypeGVCFsAnnotationArgumentCollection extends DefaultGATKVariantAnnotationArgumentCollection { private static final long serialVersionUID = 1L; - + public static final String KEEP_SPECIFIED_RAW_COMBINED_ANNOTATION_LONG_NAME = "keep-specific-combined-raw-annotation"; public static final String KEEP_SPECIFIED_RAW_COMBINED_ANNOTATION_SHORT_NAME = "keep-specific-combined"; @@ -23,27 +23,5 @@ public class GenotypeGVCFsAnnotationArgumentCollection extends DefaultGATKVarian protected List keepSpecifiedCombined = new ArrayList<>(); @Override - public List getUserEnabledAnnotationNames() { - return Collections.unmodifiableList(keepSpecifiedCombined); - } - - @Override - public List getUserEnabledAnnotationGroups() { - return Collections.emptyList(); - } - - @Override - public List getUserDisabledAnnotationNames() { - return Collections.emptyList(); - } - - @Override - public boolean getDisableToolDefaultAnnotations() { - return false; - } - - @Override - public boolean getEnableAllAnnotations() { - return false; - } + public List getKeepSpecifiedCombinedAnnotationNames() {return Collections.unmodifiableList(keepSpecifiedCombined);} } diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java index 98cffa47dcc..ea05c9d5c49 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java @@ -11,7 +11,6 @@ import org.broadinstitute.hellbender.engine.ReferenceContext; import org.broadinstitute.hellbender.exceptions.GATKException; import org.broadinstitute.hellbender.exceptions.UserException; -import org.broadinstitute.hellbender.tools.walkers.GenotypeGVCFs; import org.broadinstitute.hellbender.tools.walkers.GenotypeGVCFsAnnotationArgumentCollection; import org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.ReducibleAnnotation; import org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.ReducibleAnnotationData; @@ -97,7 +96,7 @@ public VariantAnnotatorEngine(final Collection annotationList, useRawAnnotations = useRaw; keepRawCombinedAnnotations = keepCombined; for (final Annotation rawAnnot : rawAnnotationsToKeep) { - if (!variantAnnotationKeys.contains(rawAnnot)) { + if (!annotationList.contains(rawAnnot)) { throw new UserException("Requested --" + GenotypeGVCFsAnnotationArgumentCollection.KEEP_SPECIFIED_RAW_COMBINED_ANNOTATION_LONG_NAME + ": " + rawAnnot + " is not available. Add requested annotation with --" + StandardArgumentDefinitions.ANNOTATION_LONG_NAME + "."); } rawVariantAnnotationKeysToKeep.addAll(((VariantAnnotation) rawAnnot).getKeyNames()); diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/allelespecific/ReducibleAnnotation.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/allelespecific/ReducibleAnnotation.java index 4b2541bc84f..85c3b5e6463 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/allelespecific/ReducibleAnnotation.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/allelespecific/ReducibleAnnotation.java @@ -3,8 +3,6 @@ import htsjdk.variant.variantcontext.Allele; import htsjdk.variant.variantcontext.VariantContext; import htsjdk.variant.vcf.VCFCompoundHeaderLine; -import htsjdk.variant.vcf.VCFHeaderLine; -import htsjdk.variant.vcf.VCFInfoHeaderLine; import org.broadinstitute.hellbender.engine.ReferenceContext; import org.broadinstitute.hellbender.tools.walkers.annotator.Annotation; import org.broadinstitute.hellbender.utils.genotyper.AlleleLikelihoods; @@ -12,7 +10,6 @@ import org.broadinstitute.hellbender.utils.variant.GATKVCFHeaderLines; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Map; From aaad2965eff0fbac180f5626c32df50fac67e98d Mon Sep 17 00:00:00 2001 From: Megan Shand Date: Fri, 30 Sep 2022 13:06:33 -0400 Subject: [PATCH 08/13] addressing comments --- .../broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java | 2 +- .../walkers/GenotypeGVCFsAnnotationArgumentCollection.java | 3 ++- .../tools/walkers/annotator/VariantAnnotatorEngine.java | 2 +- .../hellbender/utils/variant/GATKVCFHeaderLines.java | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java index 0a28400f6d2..3343d849c76 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java @@ -278,7 +278,7 @@ public void onTraversalStart() { final GATKAnnotationPluginDescriptor pluginDescriptor = getCommandLineParser().getPluginDescriptor(GATKAnnotationPluginDescriptor.class); final List annotationStringsToKeep = pluginDescriptor.getUserArgs().getKeepSpecifiedCombinedAnnotationNames(); final Map allDiscoveredAnnotations = pluginDescriptor.getAllDiscoveredAnnotations(); - final Collection annotationsToKeep = annotationStringsToKeep.stream().map(allDiscoveredAnnotations::get).collect(Collectors.toList()); + final Set annotationsToKeep = annotationStringsToKeep.stream().map(allDiscoveredAnnotations::get).collect(Collectors.toSet()); annotationEngine = new VariantAnnotatorEngine(variantAnnotations, dbsnp.dbsnp, Collections.emptyList(), false, keepCombined, annotationsToKeep); merger = new ReferenceConfidenceVariantContextMerger(annotationEngine, getHeaderForVariants(), somaticInput, false, true); diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java index 8bd5a4250a1..5bd38907925 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java @@ -15,7 +15,8 @@ public class GenotypeGVCFsAnnotationArgumentCollection extends DefaultGATKVarian public static final String KEEP_SPECIFIED_RAW_COMBINED_ANNOTATION_SHORT_NAME = "keep-specific-combined"; /** - * Keep only the specific combined raw annotations specified (removing the other raw annotations if keep-combined-raw-annotations is not set). See {@link ReducibleAnnotation} + * Keep only the specific combined raw annotations specified. Cannot be used with --keep-combined-raw-annotations which saves all raw annotations. + * Duplicate values will be ignored. See {@link ReducibleAnnotation} for more information on raw annotations. */ @Argument(fullName= KEEP_SPECIFIED_RAW_COMBINED_ANNOTATION_LONG_NAME, shortName = KEEP_SPECIFIED_RAW_COMBINED_ANNOTATION_SHORT_NAME, optional = true, mutex = {GenotypeGVCFs.KEEP_COMBINED_LONG_NAME}, diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java index ea05c9d5c49..6ec8aa54cc9 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java @@ -278,7 +278,7 @@ public VariantContext finalizeAnnotations(VariantContext vc, VariantContext orig //save annotations that have been requested to be kept final Map savedRawAnnotations = new LinkedHashMap<>(); - for(String rawAnnot : rawAnnotationsToKeep) { + for(final String rawAnnot : rawAnnotationsToKeep) { if (variantAnnotations.containsKey(rawAnnot)) { savedRawAnnotations.put(rawAnnot, variantAnnotations.get(rawAnnot)); } diff --git a/src/main/java/org/broadinstitute/hellbender/utils/variant/GATKVCFHeaderLines.java b/src/main/java/org/broadinstitute/hellbender/utils/variant/GATKVCFHeaderLines.java index 7f792fd7720..eff287ceae9 100644 --- a/src/main/java/org/broadinstitute/hellbender/utils/variant/GATKVCFHeaderLines.java +++ b/src/main/java/org/broadinstitute/hellbender/utils/variant/GATKVCFHeaderLines.java @@ -159,7 +159,7 @@ public static VCFFormatHeaderLine getEquivalentFormatHeaderLine(final String inf addInfoLine(new VCFInfoHeaderLine(INBREEDING_COEFFICIENT_KEY, 1, VCFHeaderLineType.Float, "Inbreeding coefficient as estimated from the genotype likelihoods per-sample when compared against the Hardy-Weinberg expectation")); addInfoLine(new VCFInfoHeaderLine(AS_INBREEDING_COEFFICIENT_KEY, VCFHeaderLineCount.A, VCFHeaderLineType.Float, "Allele-specific inbreeding coefficient as estimated from the genotype likelihoods per-sample when compared against the Hardy-Weinberg expectation")); addInfoLine(new VCFInfoHeaderLine(EXCESS_HET_KEY, 1, VCFHeaderLineType.Float, "Phred-scaled p-value for exact test of excess heterozygosity")); - addInfoLine(new VCFInfoHeaderLine(RAW_GENOTYPE_COUNT_KEY, 3, VCFHeaderLineType.Integer, "Counts of genotypes w.r.t. the reference allele: 0/0, 0/*, */*, i.e. all alts lumped together; for use in calculating excess heterozygosity")); + addInfoLine(new VCFInfoHeaderLine(RAW_GENOTYPE_COUNT_KEY, 3, VCFHeaderLineType.Integer, "Counts of genotypes w.r.t. the reference allele in the following order: 0/0, 0/*, */*, i.e. all alts lumped together; for use in calculating excess heterozygosity")); addInfoLine(new VCFInfoHeaderLine(LIKELIHOOD_RANK_SUM_KEY, 1, VCFHeaderLineType.Float, "Z-score from Wilcoxon rank sum test of Alt Vs. Ref haplotype likelihoods")); addInfoLine(new VCFInfoHeaderLine(MAP_QUAL_RANK_SUM_KEY, 1, VCFHeaderLineType.Float, "Z-score From Wilcoxon rank sum test of Alt vs. Ref read mapping qualities")); addInfoLine(new VCFInfoHeaderLine(AS_MAP_QUAL_RANK_SUM_KEY, VCFHeaderLineCount.A, VCFHeaderLineType.Float, "allele specific Z-score From Wilcoxon rank sum test of each Alt vs. Ref read mapping qualities")); From 65e43095dd5f944e0465b8a41f3de1a534bb3bb5 Mon Sep 17 00:00:00 2001 From: Megan Shand Date: Fri, 30 Sep 2022 15:52:08 -0400 Subject: [PATCH 09/13] fixing ReblockGvcf tests --- ...ted.NA12878.AS.chr20snippet.reblocked.g.vcf | 2 +- ...NA12878.AS.chr20snippet.reblocked.g.vcf.idx | Bin 2169 -> 330 bytes ...12878.AS.chr20snippet.reblocked.hiRes.g.vcf | 2 +- ...8.AS.chr20snippet.reblocked.hiRes.g.vcf.idx | Bin 331 -> 336 bytes ...ted.NA12892.AS.chr20snippet.reblocked.g.vcf | 2 +- ...NA12892.AS.chr20snippet.reblocked.g.vcf.idx | Bin 2170 -> 330 bytes .../expected.aggressiveQualFiltering.g.vcf | 2 +- .../expected.overlappingDeletions.g.vcf | 2 +- .../prod.chr20snippet.withRawMQ.expected.g.vcf | 2 +- ...d.chr20snippet.withRawMQ.expected.g.vcf.idx | Bin 405 -> 399 bytes .../ReblockGVCF/prodWesOutput.g.vcf | 2 +- .../ReblockGVCF/prodWgsOutput.g.vcf | 2 +- .../testJustOneSample.expected.g.vcf | 2 +- .../testJustOneSample.expected.g.vcf.idx | Bin 232 -> 237 bytes .../testNonRefADCorrection.expected.g.vcf | 2 +- .../testNonRefADCorrection.expected.g.vcf.idx | Bin 245 -> 250 bytes .../testOneSampleAsForGnomAD.expected.g.vcf | 2 +- 17 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/expected.NA12878.AS.chr20snippet.reblocked.g.vcf b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/expected.NA12878.AS.chr20snippet.reblocked.g.vcf index 0662397f3ad..41e2ca3f78f 100644 --- a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/expected.NA12878.AS.chr20snippet.reblocked.g.vcf +++ b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/expected.NA12878.AS.chr20snippet.reblocked.g.vcf @@ -42,7 +42,7 @@ ##INFO= ##INFO= ##INFO= -##INFO= +##INFO= ##INFO= ##INFO= ##INFO= diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/expected.NA12878.AS.chr20snippet.reblocked.g.vcf.idx b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/expected.NA12878.AS.chr20snippet.reblocked.g.vcf.idx index d870523784907eabb64c287a71f93e1875666bcc..8f0ca1a9cd2aa4ac8dce65c411451944dc474f3a 100644 GIT binary patch literal 330 zcmb_XyH3ME5WI*kDd_nIbQ|0x(4Z)YC`}4pN_#$U?2|8d*6upc^8x$?&|7)wkQ5=hRG;oZe{NIWciO`AANWhLih^z`RB{C7wh%<;pBFG{>$Z0XSa9j2U~yo z@#5MpAKXrjFMig?n@79({rdFo^!o99f3@DNe?7UpxIeqQU)^8b>~BtPPp(!}q;Ssa zlCv1clCsvH!(Z2MgzNA9pa1+;9oOq4?xW+w-3ty9U5t`&2Lyn!yJqcx2KGV%lsXUr zFk6(II$(hdIh&-(A_dM26H2*T2$!-(w>U+|h?m5aq19xQf|FXzHigGI6lOO;6kVng zav>-iXIc-)NQ#%~6`_z6w1$WF3IvUX#h+qBs>Vvu(iHv&sA7`IX5Bu56S_Ycyxs*) zmb??bd__b;c?DugQ|KL(1Q2@D6y1b+MIFK~36z0KMlqHsQ$tf3c(pP>VTnsywTebm zW{Fbe)r8JlqOpdHLeF*Xk;TT4P|1ZYd$Y})r(#YCYh}pMN8XyT7PR4l0j=Cnqh%KC z-PU=uE!EcZs6&hmbs0q0ZtFUrB(ROdH0oO!BB8&Qk!iP0wv0@uMi!Z9u#L4AkzGgL zZtFT`QB{wE;ahr(RkNrXN8T2LnvA^7nGFl4Cy09Ou77SE&B8-;5atU2@0Dbl#HNqk6!+Hhco z$MNFEotWpX)48RJ#0h(D(3z_qjP4#AgPTjV_dMy7BF$ypO+z}|vdqG9sflo{H)jza zt?TFjwm9nA;b>(@o}0_;sK%gRlPY`iQSX*c!HQaPV-HrBIA45R8MU3bq+%oY45y)? zs3}-7_Us}OGc0S7-{Ss~+T;KB L{oFg>{0HD)OUb~_ diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/expected.NA12878.AS.chr20snippet.reblocked.hiRes.g.vcf b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/expected.NA12878.AS.chr20snippet.reblocked.hiRes.g.vcf index ec6f4a8059f..cd12cbb657a 100644 --- a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/expected.NA12878.AS.chr20snippet.reblocked.hiRes.g.vcf +++ b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/expected.NA12878.AS.chr20snippet.reblocked.hiRes.g.vcf @@ -47,7 +47,7 @@ ##INFO= ##INFO= ##INFO= -##INFO= +##INFO= ##INFO= ##INFO= ##INFO= diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/expected.NA12878.AS.chr20snippet.reblocked.hiRes.g.vcf.idx b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/expected.NA12878.AS.chr20snippet.reblocked.hiRes.g.vcf.idx index 09501a21f6b7b5bcf5b462ec7689ab15e36a2373..d00f180a12c0d34d1bfb8cac57cc6c0626db5426 100644 GIT binary patch delta 147 zcmX@jbb)Dth;V3eYEiL%ZgECpUW&eZW=TeA(nO`HydU!!z`)@9v;O9ZN0d{1fn0S9 Oh#<9Sc`Jx{Fv|dFB^MC@ delta 142 zcmcb>bed^`2wz5iZmND}PGzEgK~a9zMD?k>(+e5EAj?Lyxpd-5 ##INFO= ##INFO= -##INFO= +##INFO= ##INFO= ##INFO= ##INFO= diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/expected.NA12892.AS.chr20snippet.reblocked.g.vcf.idx b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/expected.NA12892.AS.chr20snippet.reblocked.g.vcf.idx index c5c764ff85145368dfb62a7de8df1e991d8093c9..69c4886d765719487394a6a9280ca597c835f2f6 100644 GIT binary patch literal 330 zcmb_WyG{c!5OhRIfy9S+lPge27bPO1Nx@5LZQth3I%A)9_Y!(OfM1~C*Qogg_K5Na zj5Ir=)o3(N_v_un7;~ZA$Ak+2cxEJqS8iRdVH2etJTy)^U+K%YwJHZQ9?z_%WQU~RX{Sv9|{?DElu zmZ~Y|*!L)wPGL F%P%9sQ6vBW literal 2170 zcmb_e%Wh*u5N*Vg1ri@(*P~yRT@;%k(u|P?&uC_WtPm0ec@QO02zAN*Y#kq;syba&o&D+N-Dl3Z&+)qa`TF8$yhb38aCdfpcC#W$oW--T zj}kOQRxMw7j9=kLEh{_}eYT%PxMZB9@2N9@F#1d7595CF<%nzRAx*fI%FYJdm8 z9K591fZ#Zjagf*<(Q#r>D5l0pj)Sr07`te8NK>PSZeth#7FNV=0Fz@4L4ERFgt;I@ zF>nve0z`A*Y@z=O*)qPjoN`ByE+zFAe9w-NFTo;K>%pOCq`{}q)8phavjssG&8F;9 zrj*1lvgS~cWXt_0LM|#~13uKBz)+uA>{D(iHL#Kov8VqIt^`RG7T?}O6TW{UyxKdC zAzBlB@sfyy(h9;7d+H682oQc#&#t3ZP=oQKfHF`?IE)cxs%XrUt`-G2EPmu_D5%HD zj3^adjl4M2a_}Wx9Q1O|9jyuxCpjpvRc_+c53_Mei$d}?)#gjZn$d=X0$RDEfyOG> z8W)o>adY8XntkxTq9&8++PJ0@N&>DYrrF=3;0gUTM$^WPVa!aZWagP@;`(wHm}H%G z8`pHMqPXq_!#76r#WSz!XWg2E2AOqhG>tZKwYFKv%LKQxz)FE`uvwQ%#hG;(mdeG_ z0BUH-`7|pkF^^7SpMc90k@8rElq4`@IQ^AWD(2>C3IC z?(6OG{>|&{;pKMsV*kzI)%JMja^zJWp7dYVcl*s@vwe#jg=|GwHsr|?R-CvZa9Bj& z9=|?4-kogGlVTRb3Kx*7<%nBp;hcQ?W`}K_UAckLx9-m`-52 ##INFO= ##INFO= -##INFO= +##INFO= ##INFO= ##INFO= ##INFO= diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/expected.overlappingDeletions.g.vcf b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/expected.overlappingDeletions.g.vcf index 09fb5e4a2f1..455577cbdd9 100644 --- a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/expected.overlappingDeletions.g.vcf +++ b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/expected.overlappingDeletions.g.vcf @@ -43,7 +43,7 @@ ##INFO= ##INFO= ##INFO= -##INFO= +##INFO= ##INFO= ##INFO= ##INFO= diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/prod.chr20snippet.withRawMQ.expected.g.vcf b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/prod.chr20snippet.withRawMQ.expected.g.vcf index e71559a6b5b..d87940f0e4a 100644 --- a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/prod.chr20snippet.withRawMQ.expected.g.vcf +++ b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/prod.chr20snippet.withRawMQ.expected.g.vcf @@ -39,7 +39,7 @@ ##INFO= ##INFO= ##INFO= -##INFO= +##INFO= ##INFO= ##INFO= ##INFO= diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/prod.chr20snippet.withRawMQ.expected.g.vcf.idx b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/prod.chr20snippet.withRawMQ.expected.g.vcf.idx index aadcb5450a63728e330e07d7fdd2ed45f6d0aa7d..83c0d73ee2b70707bda79529462cb7a417801244 100644 GIT binary patch literal 399 zcmd5%J8l9o5OqXDDk!)Cy(du8P=G)bDT0!S)@u*D)*5>?Gt1I*fLtNx%PHaoaR;6> znl~T4dGonjA6}GFgB(X6Z~*{cjKpx_%0vfSFI8JWX`}`w3xX^_$f+fZ42eo8C>iG? ziGpcQnw)MtBCW|@s<9EN{C*WUO8J-y%p;BZ}^w z)Em>Uzcl_vw1TCs^ug}c>Mg}hbw1(cFUP-E=KmH-9Y<=Crt$E$dr9y-yYWZG`&(B7 CpH5W( diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/prodWesOutput.g.vcf b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/prodWesOutput.g.vcf index 2fb9f15403d..766db5782b2 100644 --- a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/prodWesOutput.g.vcf +++ b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/prodWesOutput.g.vcf @@ -46,7 +46,7 @@ ##INFO= ##INFO= ##INFO= -##INFO= +##INFO= ##INFO= ##INFO= ##INFO= diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/prodWgsOutput.g.vcf b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/prodWgsOutput.g.vcf index a90e6b12ae1..8fbedd6ec99 100644 --- a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/prodWgsOutput.g.vcf +++ b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/prodWgsOutput.g.vcf @@ -41,7 +41,7 @@ ##INFO= ##INFO= ##INFO= -##INFO= +##INFO= ##INFO= ##INFO= ##INFO= diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/testJustOneSample.expected.g.vcf b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/testJustOneSample.expected.g.vcf index d26f05f1b85..265b1f96a3f 100644 --- a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/testJustOneSample.expected.g.vcf +++ b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/testJustOneSample.expected.g.vcf @@ -36,7 +36,7 @@ ##INFO= ##INFO= ##INFO= -##INFO= +##INFO= ##INFO= ##INFO= ##INFO= diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/testJustOneSample.expected.g.vcf.idx b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/testJustOneSample.expected.g.vcf.idx index faae0ec2f0f8266c5a378a430c25d66ce877b34e..81cf44a57561592d888e5d42202a3ead33cf2378 100644 GIT binary patch delta 63 zcmaFC_?B^kh;V3eYEiL%ZgECpUW&eZW=TeA(nO_tUI9@CFev!(y1#kiIxPWP5r_ax F0sxiP5S0J` delta 58 zcmaFM_=0hQ2wz5iZmND}PGzEgK~a9zMD=>!m7)w_(AvS)Tsm>HmcTU;hyY9i049+S AE&u=k diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/testNonRefADCorrection.expected.g.vcf b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/testNonRefADCorrection.expected.g.vcf index fc90a5b32f1..0964c2aaea5 100644 --- a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/testNonRefADCorrection.expected.g.vcf +++ b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/testNonRefADCorrection.expected.g.vcf @@ -41,7 +41,7 @@ ##INFO= ##INFO= ##INFO= -##INFO= +##INFO= ##INFO= ##INFO= ##INFO= diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/testNonRefADCorrection.expected.g.vcf.idx b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/testNonRefADCorrection.expected.g.vcf.idx index 2d6295450cb17ab304b888a6ed0450198d3b37dd..2f240c049ae45db0a605daaac204d4c97b3a1da2 100644 GIT binary patch delta 71 zcmey$_=|CZh;V3eYEiL%ZgECpUW&eZW=TeA(nO^e-dI}(FfjP|yuW$kW-SSE8;Agm HhA995G#nAN delta 66 zcmeyx_?2;j2wz5iZmND}PGzEgK~a9zMD-S4UpodcV45q|Tsm=wmc#}dhyaX+DF6VP C^$&yq diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/testOneSampleAsForGnomAD.expected.g.vcf b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/testOneSampleAsForGnomAD.expected.g.vcf index 36298de5e8a..c29ea24dbeb 100644 --- a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/testOneSampleAsForGnomAD.expected.g.vcf +++ b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF/testOneSampleAsForGnomAD.expected.g.vcf @@ -21,7 +21,7 @@ ##INFO= ##INFO= ##INFO= -##INFO= +##INFO= ##INFO= ##INFO= ##INFO= From 27b3994d29cb9a26f4ea3b797b4d64550ebf1730 Mon Sep 17 00:00:00 2001 From: Megan Shand Date: Thu, 6 Oct 2022 16:08:08 -0400 Subject: [PATCH 10/13] addressing argument collection comments --- ...TKVariantAnnotationArgumentCollection.java | 3 --- .../GATKAnnotationArgumentCollection.java | 3 --- .../GATKAnnotationPluginDescriptor.java | 24 ++++++++++++------- .../tools/walkers/GenotypeGVCFs.java | 17 +++++++++---- ...typeGVCFsAnnotationArgumentCollection.java | 1 - 5 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/DefaultGATKVariantAnnotationArgumentCollection.java b/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/DefaultGATKVariantAnnotationArgumentCollection.java index 70f1a6f0284..f6a11f45084 100644 --- a/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/DefaultGATKVariantAnnotationArgumentCollection.java +++ b/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/DefaultGATKVariantAnnotationArgumentCollection.java @@ -81,7 +81,4 @@ public boolean getDisableToolDefaultAnnotations() { public boolean getEnableAllAnnotations() { return enableAllAnnotations; } - - @Override - public List getKeepSpecifiedCombinedAnnotationNames() { return Collections.emptyList(); } } diff --git a/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationArgumentCollection.java b/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationArgumentCollection.java index 8d214783c35..fd8ef623b91 100644 --- a/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationArgumentCollection.java +++ b/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationArgumentCollection.java @@ -37,7 +37,4 @@ public abstract class GATKAnnotationArgumentCollection implements Serializable { * Returns {@code true} if all annotations are enabled; {@code false} otherwise. */ public abstract boolean getEnableAllAnnotations(); - - - public abstract List getKeepSpecifiedCombinedAnnotationNames(); } \ No newline at end of file diff --git a/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationPluginDescriptor.java b/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationPluginDescriptor.java index 15d875a4fb4..e518a3e17e7 100644 --- a/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationPluginDescriptor.java +++ b/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationPluginDescriptor.java @@ -484,6 +484,21 @@ public List getResolvedInstances() { return resolvedInstances; } + /** + * Returns a map of the String to Annotations only in the resolved instances. Should only be used if + * getResolvedInstances() is not sufficient. + * + * @return a Map of Strings to Annotations of resolved instances + */ + public Map getResolvedInstancesMap() { + if (resolvedInstances == null) { + getResolvedInstances(); + } + Map resolvedInstancesMap = new HashMap<>(); + allDiscoveredAnnotations.keySet().stream().filter(s -> resolvedInstances.contains(allDiscoveredAnnotations.get(s))). + forEach(s -> resolvedInstancesMap.put(s, allDiscoveredAnnotations.get(s))); + return(resolvedInstancesMap); + } /** * Return the class representing the instance of the plugin specified by {@code pluginName} @@ -495,13 +510,4 @@ public List getResolvedInstances() { public Class getClassForPluginHelp(final String pluginName) { return allDiscoveredAnnotations.containsKey(pluginName) ? allDiscoveredAnnotations.get(pluginName).getClass() : null; } - - public Map getAllDiscoveredAnnotations() { - return this.allDiscoveredAnnotations; - } - - public GATKAnnotationArgumentCollection getUserArgs() { - return this.userArgs; - } - } diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java index 3343d849c76..1807210fd00 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java @@ -175,6 +175,9 @@ public final class GenotypeGVCFs extends VariantLocusWalker { @ArgumentCollection private final DbsnpArgumentCollection dbsnp = new DbsnpArgumentCollection(); + // @ArgumentCollection deliberately omitted since this is passed to the annotation plugin + final GenotypeGVCFsAnnotationArgumentCollection genotypeGVCFsAnnotationArgs = new GenotypeGVCFsAnnotationArgumentCollection(); + // the annotation engine private VariantAnnotatorEngine annotationEngine; @@ -229,7 +232,7 @@ public List> getPluginDescriptors() { GATKReadFilterPluginDescriptor readFilterDescriptor = new GATKReadFilterPluginDescriptor(getDefaultReadFilters()); return useVariantAnnotations()? Arrays.asList(readFilterDescriptor, new GATKAnnotationPluginDescriptor( - new GenotypeGVCFsAnnotationArgumentCollection(), + genotypeGVCFsAnnotationArgs, getDefaultVariantAnnotations(), getDefaultVariantAnnotationGroups())): Collections.singletonList(readFilterDescriptor); } @@ -275,10 +278,7 @@ public void onTraversalStart() { Collections.emptyList(); final Collection variantAnnotations = makeVariantAnnotations(); - final GATKAnnotationPluginDescriptor pluginDescriptor = getCommandLineParser().getPluginDescriptor(GATKAnnotationPluginDescriptor.class); - final List annotationStringsToKeep = pluginDescriptor.getUserArgs().getKeepSpecifiedCombinedAnnotationNames(); - final Map allDiscoveredAnnotations = pluginDescriptor.getAllDiscoveredAnnotations(); - final Set annotationsToKeep = annotationStringsToKeep.stream().map(allDiscoveredAnnotations::get).collect(Collectors.toSet()); + final Set annotationsToKeep = getAnnotationsToKeep(); annotationEngine = new VariantAnnotatorEngine(variantAnnotations, dbsnp.dbsnp, Collections.emptyList(), false, keepCombined, annotationsToKeep); merger = new ReferenceConfidenceVariantContextMerger(annotationEngine, getHeaderForVariants(), somaticInput, false, true); @@ -296,6 +296,13 @@ public void onTraversalStart() { } + private Set getAnnotationsToKeep() { + final GATKAnnotationPluginDescriptor pluginDescriptor = getCommandLineParser().getPluginDescriptor(GATKAnnotationPluginDescriptor.class); + final List annotationStringsToKeep = genotypeGVCFsAnnotationArgs.getKeepSpecifiedCombinedAnnotationNames(); + final Map resolvedInstancesMap = pluginDescriptor.getResolvedInstancesMap(); + return annotationStringsToKeep.stream().map(resolvedInstancesMap::get).collect(Collectors.toSet()); + } + @Override public void apply(final Locatable loc, List variants, ReadsContext reads, ReferenceContext ref, FeatureContext features) { diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java index 5bd38907925..7b5d8db4da3 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsAnnotationArgumentCollection.java @@ -23,6 +23,5 @@ public class GenotypeGVCFsAnnotationArgumentCollection extends DefaultGATKVarian doc="Keep only the specific combined raw annotations specified (removing the other raw annotations). Duplicate values will be ignored.") protected List keepSpecifiedCombined = new ArrayList<>(); - @Override public List getKeepSpecifiedCombinedAnnotationNames() {return Collections.unmodifiableList(keepSpecifiedCombined);} } From fdccc7b56823f2b0b2c23bda263e7265a8485ecc Mon Sep 17 00:00:00 2001 From: meganshand Date: Thu, 13 Oct 2022 14:04:55 -0400 Subject: [PATCH 11/13] Update src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationPluginDescriptor.java Co-authored-by: Chris Norman --- .../GATKPlugin/GATKAnnotationPluginDescriptor.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationPluginDescriptor.java b/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationPluginDescriptor.java index e518a3e17e7..cb4e3802f38 100644 --- a/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationPluginDescriptor.java +++ b/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationPluginDescriptor.java @@ -491,13 +491,9 @@ public List getResolvedInstances() { * @return a Map of Strings to Annotations of resolved instances */ public Map getResolvedInstancesMap() { - if (resolvedInstances == null) { - getResolvedInstances(); - } - Map resolvedInstancesMap = new HashMap<>(); - allDiscoveredAnnotations.keySet().stream().filter(s -> resolvedInstances.contains(allDiscoveredAnnotations.get(s))). - forEach(s -> resolvedInstancesMap.put(s, allDiscoveredAnnotations.get(s))); - return(resolvedInstancesMap); + return allDiscoveredAnnotations.entrySet().stream() + .filter(e -> getResolvedInstances().contains(e.getValue())) + .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue())); } /** From 8d314f66c59f965adf892b042880bd1ba3e5e82f Mon Sep 17 00:00:00 2001 From: Megan Shand Date: Fri, 14 Oct 2022 09:25:12 -0400 Subject: [PATCH 12/13] addressing comments --- .../GATKPlugin/GATKAnnotationPluginDescriptor.java | 3 +-- .../hellbender/tools/walkers/GenotypeGVCFs.java | 7 ++++++- .../walkers/annotator/VariantAnnotatorEngine.java | 3 --- .../tools/walkers/GenotypeGVCFsIntegrationTest.java | 12 ++++++++++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationPluginDescriptor.java b/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationPluginDescriptor.java index cb4e3802f38..9cfd91e9d71 100644 --- a/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationPluginDescriptor.java +++ b/src/main/java/org/broadinstitute/hellbender/cmdline/GATKPlugin/GATKAnnotationPluginDescriptor.java @@ -485,8 +485,7 @@ public List getResolvedInstances() { } /** - * Returns a map of the String to Annotations only in the resolved instances. Should only be used if - * getResolvedInstances() is not sufficient. + * Returns a map of the String to Annotations only in the resolved instances. * * @return a Map of Strings to Annotations of resolved instances */ diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java index 1807210fd00..cec6dbec129 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java @@ -19,6 +19,7 @@ import org.broadinstitute.hellbender.engine.ReadsContext; import org.broadinstitute.hellbender.engine.ReferenceContext; import org.broadinstitute.hellbender.engine.VariantLocusWalker; +import org.broadinstitute.hellbender.exceptions.UserException; import org.broadinstitute.hellbender.tools.genomicsdb.GenomicsDBArgumentCollection; import org.broadinstitute.hellbender.tools.genomicsdb.GenomicsDBImport; import org.broadinstitute.hellbender.tools.genomicsdb.GenomicsDBOptions; @@ -300,7 +301,11 @@ private Set getAnnotationsToKeep() { final GATKAnnotationPluginDescriptor pluginDescriptor = getCommandLineParser().getPluginDescriptor(GATKAnnotationPluginDescriptor.class); final List annotationStringsToKeep = genotypeGVCFsAnnotationArgs.getKeepSpecifiedCombinedAnnotationNames(); final Map resolvedInstancesMap = pluginDescriptor.getResolvedInstancesMap(); - return annotationStringsToKeep.stream().map(resolvedInstancesMap::get).collect(Collectors.toSet()); + return annotationStringsToKeep.stream() + .peek(s -> {Annotation a = resolvedInstancesMap.get(s); if (a == null) + throw new UserException("Requested --" + GenotypeGVCFsAnnotationArgumentCollection.KEEP_SPECIFIED_RAW_COMBINED_ANNOTATION_LONG_NAME + ": " + s + " was not found in annotation list. Was it excluded with --" + StandardArgumentDefinitions.ANNOTATIONS_TO_EXCLUDE_LONG_NAME + " or not provided with --" + StandardArgumentDefinitions.ANNOTATION_LONG_NAME + "?"); }) + .map(resolvedInstancesMap::get) + .collect(Collectors.toSet()); } @Override diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java index 6ec8aa54cc9..e05ee68c526 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java @@ -96,9 +96,6 @@ public VariantAnnotatorEngine(final Collection annotationList, useRawAnnotations = useRaw; keepRawCombinedAnnotations = keepCombined; for (final Annotation rawAnnot : rawAnnotationsToKeep) { - if (!annotationList.contains(rawAnnot)) { - throw new UserException("Requested --" + GenotypeGVCFsAnnotationArgumentCollection.KEEP_SPECIFIED_RAW_COMBINED_ANNOTATION_LONG_NAME + ": " + rawAnnot + " is not available. Add requested annotation with --" + StandardArgumentDefinitions.ANNOTATION_LONG_NAME + "."); - } rawVariantAnnotationKeysToKeep.addAll(((VariantAnnotation) rawAnnot).getKeyNames()); } this.rawAnnotationsToKeep = rawVariantAnnotationKeysToKeep; diff --git a/src/test/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsIntegrationTest.java b/src/test/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsIntegrationTest.java index ae6310f30f2..698e99968da 100644 --- a/src/test/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsIntegrationTest.java +++ b/src/test/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsIntegrationTest.java @@ -946,5 +946,17 @@ public void testRawGtCountAnnotation() { } } + @Test(expectedExceptions = UserException.class) + public void testBadKeepAnnotationArg() { + final File reblockedGVCF = new File("src/test/resources/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs/twoReblocked.g.vcf"); + final File output = createTempFile("reblockedAndGenotyped", ".vcf"); + final ArgumentsBuilder args = new ArgumentsBuilder(); + args.addReference(b37_reference_20_21) + .addVCF(reblockedGVCF) + .addOutput(output) + .add(GenotypeGVCFsAnnotationArgumentCollection.KEEP_SPECIFIED_RAW_COMBINED_ANNOTATION_LONG_NAME, "RawGtCount"); + // This is expected to fail because RawGtCount was not provided as a tool level annotation (-A). + runCommandLine(args); + } } From f7b8aa91a2cf1c918d7be7f3ebc7d47ec41dbe67 Mon Sep 17 00:00:00 2001 From: Megan Shand Date: Tue, 18 Oct 2022 15:16:50 -0400 Subject: [PATCH 13/13] cleaning up --- .../tools/walkers/annotator/VariantAnnotatorEngine.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java index e05ee68c526..af65e3bb33b 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/VariantAnnotatorEngine.java @@ -75,8 +75,7 @@ public VariantAnnotatorEngine(final Collection annotationList, genotypeAnnotations = new ArrayList<>(); jumboInfoAnnotations = new ArrayList<>(); jumboGenotypeAnnotations = new ArrayList<>(); - final List variantAnnotationKeys = new ArrayList<>(); - final List rawVariantAnnotationKeysToKeep = new ArrayList<>(); + this.rawAnnotationsToKeep = new ArrayList<>(); for (Annotation annot : annotationList) { if (annot instanceof InfoFieldAnnotation) { infoAnnotations.add((InfoFieldAnnotation) annot); @@ -89,16 +88,14 @@ public VariantAnnotatorEngine(final Collection annotationList, } else { throw new GATKException.ShouldNeverReachHereException("Unexpected annotation type: " + annot.getClass().getName()); } - variantAnnotationKeys.addAll(((VariantAnnotation) annot).getKeyNames()); } variantOverlapAnnotator = initializeOverlapAnnotator(dbSNPInput, featureInputs); reducibleKeys = new LinkedHashSet<>(); useRawAnnotations = useRaw; keepRawCombinedAnnotations = keepCombined; for (final Annotation rawAnnot : rawAnnotationsToKeep) { - rawVariantAnnotationKeysToKeep.addAll(((VariantAnnotation) rawAnnot).getKeyNames()); + this.rawAnnotationsToKeep.addAll(((VariantAnnotation) rawAnnot).getKeyNames()); } - this.rawAnnotationsToKeep = rawVariantAnnotationKeysToKeep; for (InfoFieldAnnotation annot : infoAnnotations) { if (annot instanceof ReducibleAnnotation) { for (final String rawKey : ((ReducibleAnnotation) annot).getRawKeyNames()) {