Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HaplotypeCallerIntegrationTest: add a boolean toggle to update the expected outputs for all exact-match-based tests #5324

Merged
merged 1 commit into from
Oct 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,22 @@
@Test(groups = {"variantcalling"})
public class HaplotypeCallerIntegrationTest extends CommandLineProgramTest {

// If true, update the expected outputs in tests that assert an exact match vs. prior output,
// instead of actually running the tests. Can be used with "./gradlew test -Dtest.single=HaplotypeCallerIntegrationTest"
// to update all of the exact-match tests at once. After you do this, you should look at the
// diffs in the new expected outputs in git to confirm that they are consistent with expectations.
public static final boolean UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS = false;

public static final String TEST_FILES_DIR = toolsTestDir + "haplotypecaller/";

/*
* Make sure that someone didn't leave the UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS toggle turned on
*/
@Test
public void assertThatExpectedOutputUpdateToggleIsDisabled() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So elegantly simple.

Assert.assertFalse(UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS, "The toggle to update expected outputs should not be left enabled");
}

@DataProvider(name="HaplotypeCallerTestInputs")
public Object[][] getHaplotypCallerTestInputs() {
return new Object[][] {
Expand All @@ -61,19 +75,23 @@ public void testVCFModeIsConsistentWithPastResults(final String inputFileName, f
final File output = createTempFile("testVCFModeIsConsistentWithPastResults", ".vcf");
final File expected = new File(TEST_FILES_DIR, "expected.testVCFMode.gatk4.vcf");

final String outputPath = UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS ? expected.getAbsolutePath() : output.getAbsolutePath();

final String[] args = {
"-I", inputFileName,
"-R", referenceFileName,
"-L", "20:10000000-10100000",
"-O", output.getAbsolutePath(),
"-O", outputPath,
"-pairHMM", "AVX_LOGLESS_CACHING",
"--" + StandardArgumentDefinitions.ADD_OUTPUT_VCF_COMMANDLINE, "false"
};

runCommandLine(args);

// Test for an exact match against past results
IntegrationTestSpec.assertEqualTextFiles(output, expected);
if ( ! UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS ) {
IntegrationTestSpec.assertEqualTextFiles(output, expected);
}
}

/*
Expand All @@ -90,11 +108,13 @@ public void testVCFModeIsConsistentWithPastResults_AlleleSpecificAnnotations(fin
final File output = createTempFile("testVCFModeIsConsistentWithPastResults", ".vcf");
final File expected = new File(TEST_FILES_DIR + "expected.testVCFMode.gatk4.alleleSpecific.vcf");

final String outputPath = UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS ? expected.getAbsolutePath() : output.getAbsolutePath();

final String[] args = {
"-I", inputFileName,
"-R", referenceFileName,
"-L", "20:10000000-10100000",
"-O", output.getAbsolutePath(),
"-O", outputPath,
"-G", "StandardAnnotation",
"-G", "StandardHCAnnotation",
"-G", "AS_StandardAnnotation",
Expand All @@ -105,7 +125,9 @@ public void testVCFModeIsConsistentWithPastResults_AlleleSpecificAnnotations(fin
runCommandLine(args);

// Test for an exact match against past results
IntegrationTestSpec.assertEqualTextFiles(output, expected);
if ( ! UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS ) {
IntegrationTestSpec.assertEqualTextFiles(output, expected);
}
}

/*
Expand Down Expand Up @@ -186,11 +208,13 @@ public void testGVCFModeIsConsistentWithPastResults(final String inputFileName,
final File output = createTempFile("testGVCFModeIsConsistentWithPastResults", ".g.vcf");
final File expected = new File(TEST_FILES_DIR, "expected.testGVCFMode.gatk4.g.vcf");

final String outputPath = UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS ? expected.getAbsolutePath() : output.getAbsolutePath();

final String[] args = {
"-I", inputFileName,
"-R", referenceFileName,
"-L", "20:10000000-10100000",
"-O", output.getAbsolutePath(),
"-O", outputPath,
"-ERC", "GVCF",
"-pairHMM", "AVX_LOGLESS_CACHING",
"--" + StandardArgumentDefinitions.ADD_OUTPUT_VCF_COMMANDLINE, "false"
Expand All @@ -199,7 +223,9 @@ public void testGVCFModeIsConsistentWithPastResults(final String inputFileName,
runCommandLine(args);

// Test for an exact match against past results
IntegrationTestSpec.assertEqualTextFiles(output, expected);
if ( ! UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS ) {
IntegrationTestSpec.assertEqualTextFiles(output, expected);
}
}

/*
Expand All @@ -214,11 +240,13 @@ public void testGVCFModeIsConsistentWithPastResults_AlleleSpecificAnnotations(fi
final File output = createTempFile("testGVCFModeIsConsistentWithPastResults_AlleleSpecificAnnotations", ".g.vcf");
final File expected = new File(TEST_FILES_DIR + "expected.testGVCFMode.gatk4.alleleSpecific.g.vcf");

final String outputPath = UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS ? expected.getAbsolutePath() : output.getAbsolutePath();

final String[] args = {
"-I", inputFileName,
"-R", referenceFileName,
"-L", "20:10000000-10100000",
"-O", output.getAbsolutePath(),
"-O", outputPath,
"-G", "StandardAnnotation",
"-G", "StandardHCAnnotation",
"-G", "AS_StandardAnnotation",
Expand All @@ -230,7 +258,9 @@ public void testGVCFModeIsConsistentWithPastResults_AlleleSpecificAnnotations(fi
runCommandLine(args);

// Test for an exact match against past results
IntegrationTestSpec.assertEqualTextFiles(output, expected);
if ( ! UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS ) {
IntegrationTestSpec.assertEqualTextFiles(output, expected);
}
}

/*
Expand Down Expand Up @@ -342,11 +372,13 @@ public void testGenotypeGivenAllelesMode() throws IOException {
final File output = createTempFile("testGenotypeGivenAllelesMode", ".vcf");
final File expected = new File(TEST_FILES_DIR, "expected.testGenotypeGivenAllelesMode.gatk4.vcf");

final String outputPath = UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS ? expected.getAbsolutePath() : output.getAbsolutePath();

final String[] args = {
"-I", NA12878_20_21_WGS_bam,
"-R", b37_reference_20_21,
"-L", "20:10000000-10010000",
"-O", output.getAbsolutePath(),
"-O", outputPath,
"-pairHMM", "AVX_LOGLESS_CACHING",
"--" + StandardArgumentDefinitions.ADD_OUTPUT_VCF_COMMANDLINE, "false",
"--genotyping-mode", "GENOTYPE_GIVEN_ALLELES",
Expand All @@ -356,7 +388,9 @@ public void testGenotypeGivenAllelesMode() throws IOException {
runCommandLine(args);

// Test for an exact match against past results
IntegrationTestSpec.assertEqualTextFiles(output, expected);
if ( ! UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS ) {
IntegrationTestSpec.assertEqualTextFiles(output, expected);
}
}

@Test(expectedExceptions = CommandLineException.BadArgumentValue.class)
Expand Down Expand Up @@ -522,18 +556,22 @@ public void testHaplotypeCallerRemoveAltAlleleBasedOnHaptypeScores() throws IOEx
final File output = createTempFile("testHaplotypeCallerRemoveAltAlleleBasedOnHaptypeScoresResults", ".vcf");
final File expected = new File(TEST_FILES_DIR, "expected.testHaplotypeCallerRemoveAltAlleleBasedOnHaptypeScores.gatk4.vcf");

final String outputPath = UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS ? expected.getAbsolutePath() : output.getAbsolutePath();

final String[] args = {
"-I", testBAM.getAbsolutePath(),
"-R", b37_reference_20_21,
"-L", "20:11363580-11363600",
"-O", output.getAbsolutePath(),
"-O", outputPath,
"-ploidy", "4",
"--max-genotype-count", "15",
"--" + StandardArgumentDefinitions.ADD_OUTPUT_VCF_COMMANDLINE, "false"
};
runCommandLine(args);

IntegrationTestSpec.assertEqualTextFiles(output, expected);
if ( ! UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS ) {
IntegrationTestSpec.assertEqualTextFiles(output, expected);
}
}

// test that ReadFilterLibrary.NON_ZERO_REFERENCE_LENGTH_ALIGNMENT removes reads that consume zero reference bases
Expand Down