Skip to content

Commit

Permalink
VariantsToTable: setting default to include all fields
Browse files Browse the repository at this point in the history
Fixes #7677
  • Loading branch information
orlicohen committed Jun 17, 2022
1 parent d22b752 commit f20763f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,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;
Expand All @@ -30,6 +29,7 @@
import java.util.function.Function;

import static org.broadinstitute.hellbender.utils.Utils.split;
import static org.broadinstitute.hellbender.utils.Utils.stream;

/**
* Extract fields from a VCF file to a tab-delimited table
Expand Down Expand Up @@ -135,6 +135,10 @@ public final class VariantsToTable extends VariantWalker {
shortName="F",
doc="The name of a standard VCF field or an INFO field to include in the output table", optional=true)
protected List<String> fieldsToTake = new ArrayList<>();
//protected List<String> fieldsToTake = VCFHeader.HEADER_FIELDS.name();




/**
* Any annotation name in the FORMAT field (e.g., GQ, PL) to include in the output table.
Expand Down Expand Up @@ -238,6 +242,14 @@ public void onTraversalStart() {
outputStream.println("RecordID\tSample\tVariable\tValue");
} else {
final List<String> fields = new ArrayList<>();

// if no fields specified, default to all mandatory fields
if(fieldsToTake.isEmpty()){
for(VCFHeader.HEADER_FIELDS header : VCFHeader.HEADER_FIELDS.values()){
fieldsToTake.add(header.name());
}
}

fields.addAll(fieldsToTake);
fields.addAll(asFieldsToTake);
fields.addAll(createGenotypeFields());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.broadinstitute.hellbender.testutils.IntegrationTestSpec;
import org.testng.annotations.Test;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;

Expand Down Expand Up @@ -236,4 +237,16 @@ public void testMoltenOutputWithMultipleAlleles() throws IOException {
spec.setTrimWhiteSpace(false);
spec.executeTest("testMoltenOutputWithMultipleAlleles", this);
}

@Test
public void testNoFieldsSpecified() throws IOException {
final File inputFile = new File(getToolTestDataDir(), "multiallelic.vcf");
final File outputFile = new File(getToolTestDataDir(), "noFieldsOutput.vcf");
//createTempFile("noFieldsOutput", ".table");

final String[] args = new String[] {"--variant", inputFile.getAbsolutePath(),
"-O", outputFile.getAbsolutePath()};
runCommandLine(args);
}

}

0 comments on commit f20763f

Please sign in to comment.