From 090d87b48b9113feb5ce8a4e081440ea332e9e6e Mon Sep 17 00:00:00 2001 From: Guillermo del Angel Date: Mon, 6 Feb 2012 10:33:12 -0500 Subject: [PATCH] Bug fix in ValidationSiteSelector: when input vcf had genotypes and was multiallelic, the parsing of the AF/AC fields was wrong. Better logic to unify parsing of field --- .../KeepAFSpectrumFrequencySelector.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/validation/validationsiteselector/KeepAFSpectrumFrequencySelector.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/validation/validationsiteselector/KeepAFSpectrumFrequencySelector.java index 15274d21c..4b68eed2e 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/validation/validationsiteselector/KeepAFSpectrumFrequencySelector.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/validation/validationsiteselector/KeepAFSpectrumFrequencySelector.java @@ -71,25 +71,24 @@ public class KeepAFSpectrumFrequencySelector extends FrequencyModeSelector { // recompute AF,AC,AN based on genotypes: // todo - - maybe too inefficient?? VariantContextUtils.calculateChromosomeCounts(vc, attributes, false); - afArray = new double[] {Double.valueOf((String)attributes.get(VCFConstants.ALLELE_FREQUENCY_KEY))}; - } else { - // sites-only vc or we explicitly tell to ignore genotypes; we trust the AF field if present - if ( vc.hasAttribute(VCFConstants.ALLELE_FREQUENCY_KEY) ) { - String afo = vc.getAttributeAsString(VCFConstants.ALLELE_FREQUENCY_KEY, null); + } - if (afo.contains(",")) { - String[] afs = afo.split(","); - afs[0] = afs[0].substring(1,afs[0].length()); - afs[afs.length-1] = afs[afs.length-1].substring(0,afs[afs.length-1].length()-1); + // sites-only vc or we explicitly tell to ignore genotypes; we trust the AF field if present + if ( vc.hasAttribute(VCFConstants.ALLELE_FREQUENCY_KEY) ) { + String afo = vc.getAttributeAsString(VCFConstants.ALLELE_FREQUENCY_KEY, null); - afArray = new double[afs.length]; + if (afo.contains(",")) { + String[] afs = afo.split(","); + afs[0] = afs[0].substring(1,afs[0].length()); + afs[afs.length-1] = afs[afs.length-1].substring(0,afs[afs.length-1].length()-1); - for (int k=0; k < afArray.length; k++) - afArray[k] = Double.valueOf(afs[k]); - } - else - afArray = new double[] {Double.valueOf(afo)}; + afArray = new double[afs.length]; + + for (int k=0; k < afArray.length; k++) + afArray[k] = Double.valueOf(afs[k]); } + else + afArray = new double[] {Double.valueOf(afo)}; }