From ada8c9931f532fa568809e7a966df5a93ba0c57d Mon Sep 17 00:00:00 2001 From: ebanks Date: Thu, 8 Jul 2010 05:24:27 +0000 Subject: [PATCH] We were never clipping the VCF-provided ref base off the left end of the alleles for insertions, so the reference allele was never null (and downstream walkers would fail). Didn't this get tested with insertions at some point? git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3738 348d0f76-0448-11de-a6fe-93d51630548a --- .../gatk/refdata/features/vcf4/VCF4Codec.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/features/vcf4/VCF4Codec.java b/java/src/org/broadinstitute/sting/gatk/refdata/features/vcf4/VCF4Codec.java index 9dba4601d..1d30b64df 100644 --- a/java/src/org/broadinstitute/sting/gatk/refdata/features/vcf4/VCF4Codec.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/features/vcf4/VCF4Codec.java @@ -387,11 +387,11 @@ public class VCF4Codec implements FeatureCodec, NameAwareCodec { // find out our current location, and clip the alleles down to their minimum length Pair> locAndAlleles; - if (ref.length() > 1) { - attributes.put(ORIGINAL_ALLELE_LIST,alleles); - locAndAlleles = clipAlleles(contig, pos, ref, alleles); + if ( hasIndel(alleles) ) { + attributes.put(ORIGINAL_ALLELE_LIST,alleles); + locAndAlleles = clipAlleles(contig, pos, ref, alleles); } else { - locAndAlleles = new Pair>(GenomeLocParser.createGenomeLoc(contig, pos), alleles); + locAndAlleles = new Pair>(GenomeLocParser.createGenomeLoc(contig, pos), alleles); } // a map to store our genotypes @@ -405,6 +405,15 @@ public class VCF4Codec implements FeatureCodec, NameAwareCodec { return new VariantContext(name, locAndAlleles.first, locAndAlleles.second, genotypes, qual, filters, attributes); } + private boolean hasIndel(List alleles) { + int lengthOfFirstEntry = alleles.get(0).length(); + for ( int i = 1; i < alleles.size(); i++ ) { + if ( alleles.get(i).length() != lengthOfFirstEntry ) + return true; + } + return false; + } + class VCFParserException extends StingException { public VCFParserException(String msg) { super("Line " + lineNo + " generated parser exception " + msg);