diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java index 208de044e..458f16092 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java @@ -479,7 +479,7 @@ public class SelectVariants extends RodWalker implements TreeR return 0; //Collection vcs = tracker.getValues(variantCollection.variants, context.getLocation()); - Collection vcs = getMongoVariants(context.getLocation()); + Collection vcs = getMongoVariants(ref, context.getLocation()); if ( vcs == null || vcs.size() == 0) { return 0; @@ -552,7 +552,7 @@ public class SelectVariants extends RodWalker implements TreeR return 1; } - private Collection getMongoVariants(GenomeLoc location) { + private Collection getMongoVariants(ReferenceContext ref, GenomeLoc location) { String contig = location.getContig(); long start = location.getStart(); long stop = location.getStop(); @@ -639,6 +639,13 @@ public class SelectVariants extends RodWalker implements TreeR builder.attributes(attributes); builder.filters(filters); + long index = start - ref.getWindow().getStart() - 1; + if ( index >= 0 ) { + // we were given enough reference context to create the VariantContext + builder.referenceBaseForIndel(ref.getBases()[(int)index]); + } + + builder.referenceBaseForIndel(ref.getBases()[0]); vcs.add(builder.make()); }