From e929409612b358ec9b05af33ab1b345ac0cd170e Mon Sep 17 00:00:00 2001 From: orlicohen <107129422+orlicohen@users.noreply.github.com> Date: Thu, 30 Jun 2022 15:52:19 -0400 Subject: [PATCH] VariantsToTable: Include all fields when none are specified (#7911) VariantsToTable now outputs all fields declared in the VCF header when no fields are selected. Added integration tests to cover this new functionality Fixes #7677 --- .../walkers/variantutils/VariantsToTable.java | 47 ++++++- .../VariantsToTableIntegrationTest.java | 41 ++++++ .../VCFWithGenotypes_1000G.phase3.snippet.vcf | 48 +++++++ ...typesWithFormatField_dbsnp_138.snippet.vcf | 118 ++++++++++++++++++ .../VCFWithoutGenotypes_dbsnp_138.snippet.vcf | 117 +++++++++++++++++ .../expected.noFieldsSpecifiedNoSamples.table | 4 + ...xpected.noFieldsSpecifiedWithSamples.table | 4 + 7 files changed, 373 insertions(+), 6 deletions(-) create mode 100644 src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/VariantsToTable/VCFWithGenotypes_1000G.phase3.snippet.vcf create mode 100644 src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/VariantsToTable/VCFWithoutGenotypesWithFormatField_dbsnp_138.snippet.vcf create mode 100644 src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/VariantsToTable/VCFWithoutGenotypes_dbsnp_138.snippet.vcf create mode 100644 src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/VariantsToTable/expected.noFieldsSpecifiedNoSamples.table create mode 100644 src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/VariantsToTable/expected.noFieldsSpecifiedWithSamples.table diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/variantutils/VariantsToTable.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/variantutils/VariantsToTable.java index c8ae76086a4..db5d4e2e63c 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/variantutils/VariantsToTable.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/variantutils/VariantsToTable.java @@ -2,9 +2,7 @@ import htsjdk.variant.variantcontext.Allele; import htsjdk.variant.variantcontext.VariantContext; -import htsjdk.variant.vcf.VCFConstants; -import htsjdk.variant.vcf.VCFHeader; -import htsjdk.variant.vcf.VCFHeaderLineCount; +import htsjdk.variant.vcf.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.broadinstitute.barclay.argparser.Advanced; @@ -12,7 +10,6 @@ import org.broadinstitute.barclay.argparser.CommandLineProgramProperties; import org.broadinstitute.barclay.help.DocumentedFeature; import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions; -import org.broadinstitute.hellbender.utils.variant.GATKVCFConstants; import picard.cmdline.programgroups.VariantEvaluationProgramGroup; import org.broadinstitute.hellbender.engine.FeatureContext; import org.broadinstitute.hellbender.engine.ReadsContext; @@ -38,7 +35,8 @@ * This tool extracts specified fields for each variant in a VCF file to a tab-delimited table, which may be easier * to work with than a VCF. By default, the tool only extracts PASS or . (unfiltered) variants in the VCF file. Filtered variants may be * included in the output by adding the --show-filtered flag. The tool can extract both INFO (i.e. site-level) fields and - * FORMAT (i.e. sample-level) fields. + * FORMAT (i.e. sample-level) fields. If the tool is run without specifying any fields, it defaults to include all fields + * declared in the VCF header. *

* *

INFO/site-level fields

@@ -100,6 +98,12 @@ * 1 65068538 SNP 49,0 35,4 * 1 111146235 SNP 69,1 77,4 * + *
+ *     gatk VariantsToTable \
+ *     -V input.vcf \
+ *     -O output.table
+ * 
+ *

would produce a file that includes all fields declared in the VCF header.

* *

Notes

*