From bc842ab3a5d60095aadff6bae4d271615d0ea294 Mon Sep 17 00:00:00 2001 From: Ryan Poplin Date: Sun, 18 Dec 2011 15:27:23 -0500 Subject: [PATCH] Adding option to VariantAnnotator to do strict allele matching when annotating with comp track concordance. --- .../gatk/walkers/annotator/VariantAnnotator.java | 4 ++++ .../walkers/annotator/VariantAnnotatorEngine.java | 14 ++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) 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 4fa6d0bbf..69560c7cb 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 @@ -170,6 +170,9 @@ public class VariantAnnotator extends RodWalker implements Ann @Argument(fullName="MendelViolationGenotypeQualityThreshold",shortName="mvq",required=false,doc="The genotype quality treshold in order to annotate mendelian violation ratio") public double minGenotypeQualityP = 0.0; + @Argument(fullName="requireStrictAlleleMatch", shortName="strict", doc="If provided only comp tracks that exactly match both reference and alternate alleles will be counted as concordant", required=false) + private boolean requireStrictAlleleMatch = false; + private VariantAnnotatorEngine engine; private Collection indelBufferContext; @@ -211,6 +214,7 @@ public class VariantAnnotator extends RodWalker implements Ann else engine = new VariantAnnotatorEngine(annotationGroupsToUse, annotationsToUse, annotationsToExclude, this, getToolkit()); engine.initializeExpressions(expressionsToUse); + engine.setRequireStrictAlleleMatch(requireStrictAlleleMatch); // setup the header fields // note that if any of the definitions conflict with our new ones, then we want to overwrite the old ones 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 d4442dc5d..98d2fe17b 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 @@ -47,9 +47,11 @@ public class VariantAnnotatorEngine { private List requestedGenotypeAnnotations; private List requestedExpressions = new ArrayList(); - private HashMap, String> dbAnnotations = new HashMap, String>(); - private AnnotatorCompatibleWalker walker; - private GenomeAnalysisEngine toolkit; + private final HashMap, String> dbAnnotations = new HashMap, String>(); + private final AnnotatorCompatibleWalker walker; + private final GenomeAnalysisEngine toolkit; + + private boolean requireStrictAlleleMatch = false; protected static class VAExpression { @@ -163,6 +165,10 @@ public class VariantAnnotatorEngine { return descriptions; } + public void setRequireStrictAlleleMatch( final boolean requireStrictAlleleMatch ) { + this.requireStrictAlleleMatch = requireStrictAlleleMatch; + } + public VariantContext annotateContext(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { Map infoAnnotations = new LinkedHashMap(vc.getAttributes()); @@ -197,7 +203,7 @@ public class VariantAnnotatorEngine { } else { boolean overlapsComp = false; for ( VariantContext comp : tracker.getValues(dbSet.getKey(), ref.getLocus()) ) { - if ( !comp.isFiltered() ) { + if ( !comp.isFiltered() && ( !requireStrictAlleleMatch || comp.getAlleles().equals(vc.getAlleles()) ) ) { overlapsComp = true; break; }