diff --git a/protected/java/test/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationIntegrationTest.java b/protected/java/test/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationIntegrationTest.java index 9de190f5f..6a29ff255 100644 --- a/protected/java/test/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationIntegrationTest.java +++ b/protected/java/test/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationIntegrationTest.java @@ -47,6 +47,7 @@ package org.broadinstitute.sting.gatk.walkers.filters; import org.broadinstitute.sting.WalkerTest; +import org.broadinstitute.sting.utils.exceptions.UserException; import org.testng.annotations.Test; import java.util.Arrays; @@ -106,6 +107,13 @@ public class VariantFiltrationIntegrationTest extends WalkerTest { executeTest("test filter sites not in mask", spec3); } + @Test + public void testIllegalFilterName() { + WalkerTestSpec spec = new WalkerTestSpec( + baseTestString() + " -filter 'DoC < 20 || FisherStrand > 20.0' -filterName 'foo < foo' --variant " + privateTestDir + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1, + UserException.class); + executeTest("test illegal filter name", spec); + } @Test public void testFilter1() { diff --git a/protected/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariantsIntegrationTest.java b/protected/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariantsIntegrationTest.java index c97f0bf02..303a2871a 100644 --- a/protected/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariantsIntegrationTest.java +++ b/protected/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariantsIntegrationTest.java @@ -242,6 +242,32 @@ public class SelectVariantsIntegrationTest extends WalkerTest { executeTest("testRemoveMLE--" + testFile, spec); } + @Test + public void testKeepOriginalAC() { + String testFile = privateTestDir + "vcfexample.loseAlleleInSelection.vcf"; + + WalkerTestSpec spec = new WalkerTestSpec( + "-T SelectVariants --keepOriginalAC -R " + b36KGReference + " -sn NA12892 --variant " + testFile + " -o %s --no_cmdline_in_header", + 1, + Arrays.asList("ad7e8b25e431a3229a78cec063876559") + ); + + executeTest("testKeepOriginalAC--" + testFile, spec); + } + + @Test + public void testKeepOriginalACAndENV() { + String testFile = privateTestDir + "vcfexample.loseAlleleInSelection.vcf"; + + WalkerTestSpec spec = new WalkerTestSpec( + "-T SelectVariants --keepOriginalAC -env -R " + b36KGReference + " -sn NA12892 --variant " + testFile + " -o %s --no_cmdline_in_header", + 1, + Arrays.asList("e9b8292212545684cdb163423329ee7e") + ); + + executeTest("testKeepOriginalACAndENV--" + testFile, spec); + } + @Test public void testMultipleRecordsAtOnePosition() { String testFile = privateTestDir + "selectVariants.onePosition.vcf"; diff --git a/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatch.java b/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatch.java index 828f10fcb..e354601da 100644 --- a/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatch.java +++ b/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatch.java @@ -276,10 +276,10 @@ public class ArgumentMatch implements Iterable { * @return A collection of the string representation of these value. */ public List values() { - List values = new ArrayList(); - for( ArgumentMatchSite site: sites.keySet() ) { - if( sites.get(site) != null ) - values.addAll(sites.get(site)); + final List values = new ArrayList(); + for ( final List siteValue : sites.values() ) { + if ( siteValue != null ) + values.addAll(siteValue); } return values; } diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltration.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltration.java index 362b49f68..83d4d81d0 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltration.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltration.java @@ -186,18 +186,22 @@ public class VariantFiltration extends RodWalker { if ( clusterWindow > 0 ) hInfo.add(new VCFFilterHeaderLine(CLUSTERED_SNP_FILTER_NAME, "SNPs found in clusters")); - for ( VariantContextUtils.JexlVCMatchExp exp : filterExps ) - hInfo.add(new VCFFilterHeaderLine(exp.name, exp.exp.toString())); - for ( VariantContextUtils.JexlVCMatchExp exp : genotypeFilterExps ) - hInfo.add(new VCFFilterHeaderLine(exp.name, exp.exp.toString())); - if ( genotypeFilterExps.size() > 0 ) hInfo.add(VCFStandardHeaderLines.getFormatLine(VCFConstants.GENOTYPE_FILTER_KEY)); - if ( mask.isBound() ) { - if (filterRecordsNotInMask) - hInfo.add(new VCFFilterHeaderLine(MASK_NAME, "Doesn't overlap a user-input mask")); - else hInfo.add(new VCFFilterHeaderLine(MASK_NAME, "Overlaps a user-input mask")); + try { + for ( VariantContextUtils.JexlVCMatchExp exp : filterExps ) + hInfo.add(new VCFFilterHeaderLine(exp.name, exp.exp.toString())); + for ( VariantContextUtils.JexlVCMatchExp exp : genotypeFilterExps ) + hInfo.add(new VCFFilterHeaderLine(exp.name, exp.exp.toString())); + + if ( mask.isBound() ) { + if (filterRecordsNotInMask) + hInfo.add(new VCFFilterHeaderLine(MASK_NAME, "Doesn't overlap a user-input mask")); + else hInfo.add(new VCFFilterHeaderLine(MASK_NAME, "Overlaps a user-input mask")); + } + } catch (IllegalArgumentException e) { + throw new UserException.BadInput(e.getMessage()); } writer.writeHeader(new VCFHeader(hInfo, SampleUtils.getUniqueSamplesFromRods(getToolkit(), inputNames))); 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 52c1acd2d..02c8ed8d8 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java @@ -406,8 +406,8 @@ public class SelectVariants extends RodWalker implements TreeR headerLines.add(new VCFHeaderLine("source", "SelectVariants")); if (KEEP_ORIGINAL_CHR_COUNTS) { - headerLines.add(new VCFInfoHeaderLine("AC_Orig", 1, VCFHeaderLineType.Integer, "Original AC")); - headerLines.add(new VCFInfoHeaderLine("AF_Orig", 1, VCFHeaderLineType.Float, "Original AF")); + headerLines.add(new VCFInfoHeaderLine("AC_Orig", VCFHeaderLineCount.A, VCFHeaderLineType.Integer, "Original AC")); + headerLines.add(new VCFInfoHeaderLine("AF_Orig", VCFHeaderLineCount.A, VCFHeaderLineType.Float, "Original AF")); headerLines.add(new VCFInfoHeaderLine("AN_Orig", 1, VCFHeaderLineType.Integer, "Original AN")); } headerLines.addAll(Arrays.asList(ChromosomeCountConstants.descriptions)); @@ -670,7 +670,8 @@ public class SelectVariants extends RodWalker implements TreeR GenotypesContext newGC = sub.getGenotypes(); // if we have fewer alternate alleles in the selected VC than in the original VC, we need to strip out the GL/PLs and AD (because they are no longer accurate) - if ( vc.getAlleles().size() != sub.getAlleles().size() ) + final boolean lostAllelesInSelection = vc.getAlleles().size() != sub.getAlleles().size(); + if ( lostAllelesInSelection ) newGC = GATKVariantContextUtils.stripPLsAndAD(sub.getGenotypes()); // if we have fewer samples in the selected VC than in the original VC, we need to strip out the MLE tags @@ -697,15 +698,22 @@ public class SelectVariants extends RodWalker implements TreeR builder.genotypes(newGC); - addAnnotations(builder, sub); + addAnnotations(builder, sub, lostAllelesInSelection); return builder.make(); } - private void addAnnotations(final VariantContextBuilder builder, final VariantContext originalVC) { + /* + * Add annotations to the new VC + * + * @param builder the new VC to annotate + * @param originalVC the original -- but post-selection -- VC + * @param lostAllelesInSelection true if the original (pre-selection) VC has more alleles than the new one + */ + private void addAnnotations(final VariantContextBuilder builder, final VariantContext originalVC, final boolean lostAllelesInSelection) { if ( fullyDecode ) return; // TODO -- annotations are broken with fully decoded data - if (KEEP_ORIGINAL_CHR_COUNTS) { + if ( KEEP_ORIGINAL_CHR_COUNTS && !lostAllelesInSelection ) { if ( originalVC.hasAttribute(VCFConstants.ALLELE_COUNT_KEY) ) builder.attribute("AC_Orig", originalVC.getAttribute(VCFConstants.ALLELE_COUNT_KEY)); if ( originalVC.hasAttribute(VCFConstants.ALLELE_FREQUENCY_KEY) ) diff --git a/settings/repository/org.broadinstitute/variant-1.85.1357.jar b/settings/repository/org.broadinstitute/variant-1.88.1401.jar similarity index 94% rename from settings/repository/org.broadinstitute/variant-1.85.1357.jar rename to settings/repository/org.broadinstitute/variant-1.88.1401.jar index d341e1cf5..688c6ae17 100644 Binary files a/settings/repository/org.broadinstitute/variant-1.85.1357.jar and b/settings/repository/org.broadinstitute/variant-1.88.1401.jar differ diff --git a/settings/repository/org.broadinstitute/variant-1.85.1357.xml b/settings/repository/org.broadinstitute/variant-1.88.1401.xml similarity index 71% rename from settings/repository/org.broadinstitute/variant-1.85.1357.xml rename to settings/repository/org.broadinstitute/variant-1.88.1401.xml index f6d7a2caa..5db78b1e4 100644 --- a/settings/repository/org.broadinstitute/variant-1.85.1357.xml +++ b/settings/repository/org.broadinstitute/variant-1.88.1401.xml @@ -1,3 +1,3 @@ - +