From 7fb3f2d3eb2990b9577182b155c898dac41f771f Mon Sep 17 00:00:00 2001 From: chartl Date: Fri, 21 May 2010 16:34:34 +0000 Subject: [PATCH] Annotator now buffers indel calls (prevents double-output from double-calls to map) git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3413 348d0f76-0448-11de-a6fe-93d51630548a --- .../walkers/annotator/VariantAnnotator.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java index e160df268..b97519a64 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java @@ -82,6 +82,8 @@ public class VariantAnnotator extends LocusWalker { private VariantAnnotatorEngine engine; + private Collection indelBufferContext; + private void listAnnotationsAndExit() { List> infoAnnotationClasses = PackageUtils.getClassesImplementingInterface(InfoFieldAnnotation.class); @@ -139,6 +141,10 @@ public class VariantAnnotator extends LocusWalker { vcfWriter = new VCFWriter(out); VCFHeader vcfHeader = new VCFHeader(hInfo, samples); vcfWriter.writeHeader(vcfHeader); + + if ( indelsOnly ) { + indelBufferContext = null; + } } /** @@ -199,9 +205,22 @@ public class VariantAnnotator extends LocusWalker { } } - if ( variant instanceof VCFRecord) { - for(VariantContext annotatedVC : annotatedVCs ) { + if ( ! indelsOnly ) { + + if ( variant instanceof VCFRecord ) { + for(VariantContext annotatedVC : annotatedVCs ) { vcfWriter.addRecord(VariantContextAdaptors.toVCF(annotatedVC, ref.getBase())); + } + } + } else { + // check to see if the buffered context is different (in location) this context + if ( indelBufferContext != null && ! indelBufferContext.iterator().next().getLocation().equals(annotatedVCs.iterator().next().getLocation()) ) { + for(VariantContext annotatedVC : indelBufferContext ) { + vcfWriter.addRecord(VariantContextAdaptors.toVCF(annotatedVC, ref.getBase())); + } + indelBufferContext = annotatedVCs; + } else { + indelBufferContext = annotatedVCs; } }