From b5165b8d30b166c8dd2abfb85e2aee183e3f73e0 Mon Sep 17 00:00:00 2001 From: meganshand Date: Tue, 3 Nov 2015 17:35:47 -0500 Subject: [PATCH 1/2] Fix for out of date VCF version output --- .../walkers/variantutils/SelectVariantsIntegrationTest.java | 4 ++-- .../gatk/tools/walkers/variantutils/SelectVariants.java | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariantsIntegrationTest.java b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariantsIntegrationTest.java index 9af334ff7..c1293b872 100644 --- a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariantsIntegrationTest.java +++ b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariantsIntegrationTest.java @@ -619,9 +619,9 @@ public class SelectVariantsIntegrationTest extends WalkerTest { String idFile = privateTestDir + "complexExample1.vcf.id"; WalkerTestSpec spec = new WalkerTestSpec( - baseTestString(" -xlIDs " + idFile + " --variant " + testFile), + baseTestString(" -xlIDs " + idFile + " --variant " + testFile + " --forceValidOutput"), 1, - Arrays.asList("6c1e8591c134519bfc202b4ec7ef1f71") + Arrays.asList("45ad235b42bac75aa269e12bcd88a411") ); spec.disableShadowBCF(); executeTest("testExcludeSelectionID--" + testFile, spec); diff --git a/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariants.java b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariants.java index 7c32f3666..9559e066e 100644 --- a/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariants.java +++ b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariants.java @@ -574,6 +574,9 @@ public class SelectVariants extends RodWalker implements TreeR @Argument(fullName="ALLOW_NONOVERLAPPING_COMMAND_LINE_SAMPLES", required=false, doc="Allow samples other than those in the VCF to be specified on the command line. These samples will be ignored.") private boolean allowNonOverlappingCommandLineSamples = false; + @Argument(fullName="forceValidOutput", required=false, doc="Forces output VCF to be compliant to up to date version") + private boolean forceValidOutput = false; + public enum NumberAlleleRestriction { ALL, BIALLELIC, @@ -1008,7 +1011,7 @@ public class SelectVariants extends RodWalker implements TreeR */ private VariantContext subsetRecord(final VariantContext vc, final boolean preserveAlleles, final boolean removeUnusedAlternates) { //subContextFromSamples() always decodes the vc, which is a fairly expensive operation. Avoid if possible - if ( noSamplesSpecified && !removeUnusedAlternates ) + if ( noSamplesSpecified && !removeUnusedAlternates && !forceValidOutput ) return vc; // strip out the alternate alleles that aren't being used From e4627ed5c3d6a5229d03caf50ebdff2447fc61ab Mon Sep 17 00:00:00 2001 From: meganshand Date: Wed, 4 Nov 2015 11:00:01 -0500 Subject: [PATCH 2/2] Addressing comments --- .../variantutils/SelectVariantsIntegrationTest.java | 2 ++ .../gatk/tools/walkers/variantutils/SelectVariants.java | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariantsIntegrationTest.java b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariantsIntegrationTest.java index c1293b872..bfda18f16 100644 --- a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariantsIntegrationTest.java +++ b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariantsIntegrationTest.java @@ -612,6 +612,8 @@ public class SelectVariantsIntegrationTest extends WalkerTest { /** * Test excluding variants with IDs + * Also tests --forceValidOutput flag, which changes the GQ from floats to ints to match + * header spec. */ @Test public void testExcludeSelectionID() { diff --git a/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariants.java b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariants.java index 9559e066e..022ef2e37 100644 --- a/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariants.java +++ b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariants.java @@ -574,7 +574,13 @@ public class SelectVariants extends RodWalker implements TreeR @Argument(fullName="ALLOW_NONOVERLAPPING_COMMAND_LINE_SAMPLES", required=false, doc="Allow samples other than those in the VCF to be specified on the command line. These samples will be ignored.") private boolean allowNonOverlappingCommandLineSamples = false; - @Argument(fullName="forceValidOutput", required=false, doc="Forces output VCF to be compliant to up to date version") + /** + * If this argument is provided, the output will be compliant with the version in the header, however it will also + * cause the tool to run slower than without the argument. Without the argument the header will be compliant with + * the up-to-date version, but the output in the body may not be compliant. If an up-to-date input file is used, + * then the output will also be up-to-date regardless of this argument. + */ + @Argument(fullName="forceValidOutput", required=false, doc="Forces output VCF to be compliant to up-to-date version") private boolean forceValidOutput = false; public enum NumberAlleleRestriction {