diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java index 3be87da80..722326018 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java @@ -132,6 +132,13 @@ public class VariantAnnotator extends RodWalker implements Ann @Argument(fullName="annotation", shortName="A", doc="One or more specific annotations to apply to variant calls", required=false) protected List annotationsToUse = new ArrayList(); + /** + * Note that this argument has higher priority than the -A or -G arguments, + * so annotations will be excluded even if they are explicitly included with the other options. + */ + @Argument(fullName="excludeAnnotation", shortName="XA", doc="One or more specific annotations to exclude", required=false) + protected List annotationsToExclude = new ArrayList(); + /** * See the -list argument to view available groups. */ @@ -148,6 +155,9 @@ public class VariantAnnotator extends RodWalker implements Ann @Argument(fullName="expression", shortName="E", doc="One or more specific expressions to apply to variant calls; see documentation for more details", required=false) protected List expressionsToUse = new ArrayList(); + /** + * Note that the -XL argument can be used along with this one to exclude annotations. + */ @Argument(fullName="useAllAnnotations", shortName="all", doc="Use all possible annotations (not for the faint of heart)", required=false) protected Boolean USE_ALL_ANNOTATIONS = false; @@ -209,9 +219,9 @@ public class VariantAnnotator extends RodWalker implements Ann } if ( USE_ALL_ANNOTATIONS ) - engine = new VariantAnnotatorEngine(this, getToolkit()); + engine = new VariantAnnotatorEngine(annotationsToExclude, this, getToolkit()); else - engine = new VariantAnnotatorEngine(annotationGroupsToUse, annotationsToUse, this, getToolkit()); + engine = new VariantAnnotatorEngine(annotationGroupsToUse, annotationsToUse, annotationsToExclude, this, getToolkit()); engine.initializeExpressions(expressionsToUse); // setup the header fields diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java index e5effe6d8..e4bc0d5d5 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java @@ -73,19 +73,20 @@ public class VariantAnnotatorEngine { } // use this constructor if you want all possible annotations - public VariantAnnotatorEngine(AnnotatorCompatibleWalker walker, GenomeAnalysisEngine toolkit) { + public VariantAnnotatorEngine(List annotationsToExclude, AnnotatorCompatibleWalker walker, GenomeAnalysisEngine toolkit) { this.walker = walker; this.toolkit = toolkit; requestedInfoAnnotations = AnnotationInterfaceManager.createAllInfoFieldAnnotations(); requestedGenotypeAnnotations = AnnotationInterfaceManager.createAllGenotypeAnnotations(); + excludeAnnotations(annotationsToExclude); initializeDBs(); } // use this constructor if you want to select specific annotations (and/or interfaces) - public VariantAnnotatorEngine(List annotationGroupsToUse, List annotationsToUse, AnnotatorCompatibleWalker walker, GenomeAnalysisEngine toolkit) { + public VariantAnnotatorEngine(List annotationGroupsToUse, List annotationsToUse, List annotationsToExclude, AnnotatorCompatibleWalker walker, GenomeAnalysisEngine toolkit) { this.walker = walker; this.toolkit = toolkit; - initializeAnnotations(annotationGroupsToUse, annotationsToUse); + initializeAnnotations(annotationGroupsToUse, annotationsToUse, annotationsToExclude); initializeDBs(); } @@ -96,10 +97,30 @@ public class VariantAnnotatorEngine { requestedExpressions.add(new VAExpression(expression, walker.getResourceRodBindings())); } - private void initializeAnnotations(List annotationGroupsToUse, List annotationsToUse) { + private void initializeAnnotations(List annotationGroupsToUse, List annotationsToUse, List annotationsToExclude) { AnnotationInterfaceManager.validateAnnotations(annotationGroupsToUse, annotationsToUse); requestedInfoAnnotations = AnnotationInterfaceManager.createInfoFieldAnnotations(annotationGroupsToUse, annotationsToUse); requestedGenotypeAnnotations = AnnotationInterfaceManager.createGenotypeAnnotations(annotationGroupsToUse, annotationsToUse); + excludeAnnotations(annotationsToExclude); + } + + private void excludeAnnotations(List annotationsToExclude) { + if ( annotationsToExclude.size() == 0 ) + return; + + List tempRequestedInfoAnnotations = new ArrayList(requestedInfoAnnotations.size()); + for ( InfoFieldAnnotation annotation : requestedInfoAnnotations ) { + if ( !annotationsToExclude.contains(annotation.getClass().getSimpleName()) ) + tempRequestedInfoAnnotations.add(annotation); + } + requestedInfoAnnotations = tempRequestedInfoAnnotations; + + List tempRequestedGenotypeAnnotations = new ArrayList(requestedGenotypeAnnotations.size()); + for ( GenotypeAnnotation annotation : requestedGenotypeAnnotations ) { + if ( !annotationsToExclude.contains(annotation.getClass().getSimpleName()) ) + tempRequestedGenotypeAnnotations.add(annotation); + } + requestedGenotypeAnnotations = tempRequestedGenotypeAnnotations; } private void initializeDBs() { diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java index 9fdf65015..72dc217e1 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java @@ -149,6 +149,13 @@ public class UnifiedGenotyper extends LocusWalker annotationsToUse = new ArrayList(); + /** + * Which annotations to exclude from output in the VCF file. Note that this argument has higher priority than the -A or -G arguments, + * so annotations will be excluded even if they are explicitly included with the other options. + */ + @Argument(fullName="excludeAnnotation", shortName="XA", doc="One or more specific annotations to exclude", required=false) + protected List annotationsToExclude = new ArrayList(); + /** * Which groups of annotations to add to the output VCF file. See the VariantAnnotator -list argument to view available groups. */ @@ -210,7 +217,7 @@ public class UnifiedGenotyper extends LocusWalker