From 8d814236252feed3c3486514f44e4d0eb4fbf44c Mon Sep 17 00:00:00 2001 From: orlicohen <107129422+orlicohen@users.noreply.github.com> Date: Thu, 4 Aug 2022 10:09:00 -0400 Subject: [PATCH] Cloud tests for CompareReferences and CheckReferenceCompatibility tools (#7973) * Comprehensive cloud tests for CompareReferences and CheckReferenceCompatibility tools. --- .../tools/reference/CompareReferences.java | 2 +- ...ReferenceCompatibilityIntegrationTest.java | 47 +++++++++++++++++++ .../CompareReferencesIntegrationTest.java | 43 +++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/broadinstitute/hellbender/tools/reference/CompareReferences.java b/src/main/java/org/broadinstitute/hellbender/tools/reference/CompareReferences.java index 882612a89ae..fc3d44f8322 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/reference/CompareReferences.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/reference/CompareReferences.java @@ -56,7 +56,7 @@ *
  * gatk CompareReferences \
  *   -R reference1.fasta \
- *   -refcomp reference2.fasta
+ *   -refcomp reference2.fasta \
  *   -O output.fasta \
  *   -md5-calculation-mode USE_DICT
  * 
diff --git a/src/test/java/org/broadinstitute/hellbender/tools/reference/CheckReferenceCompatibilityIntegrationTest.java b/src/test/java/org/broadinstitute/hellbender/tools/reference/CheckReferenceCompatibilityIntegrationTest.java index 885f99fee5d..7c9f6df6074 100644 --- a/src/test/java/org/broadinstitute/hellbender/tools/reference/CheckReferenceCompatibilityIntegrationTest.java +++ b/src/test/java/org/broadinstitute/hellbender/tools/reference/CheckReferenceCompatibilityIntegrationTest.java @@ -8,6 +8,9 @@ import java.io.File; import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; public class CheckReferenceCompatibilityIntegrationTest extends CommandLineProgramTest { @@ -209,4 +212,48 @@ public void testReferenceCompatibilityNoBAMOrVCF() throws IOException { final String[] args = new String[]{"-refcomp", ref1.getAbsolutePath()}; runCommandLine(args); } + + @DataProvider(name = "cloudInputData") + public Object[][] cloudInputData() { + String testBucket = getGCPTestInputPath() + "org/broadinstitute/hellbender/tools/reference/"; + return new Object[][]{ + // dict, list of refs, expected output, isBAM, isVCF + new Object[]{testBucket + "reads_data_source_test1_withmd5s.bam", + Arrays.asList(testBucket + "hg19mini.fasta"), + new File(getToolTestDataDir(), "expected.testReferenceCompatibilityBAMWithMD5s_exactmatch.table"), + true, false + }, + new Object[]{ testBucket + "example_variants_withSequenceDict_withmd5.vcf", + Arrays.asList(testBucket + "hg19mini.fasta"), + new File(getToolTestDataDir(), "expected.testReferenceCompatibilityVCFWithMD5s.table"), + false, true + }, + }; + } + + @Test(dataProvider = "cloudInputData", groups = "bucket") + public void testReferenceCompatibilityCloudInputs(String dict, List fastas, File expected, boolean isBAM, boolean isVCF) throws IOException{ + final File output = createTempFile("testCompareReferencesCloudInputs", ".table"); + + List arguments = new ArrayList<>(); + for(int i = 0; i < fastas.size(); i++){ + arguments.add("-refcomp"); + arguments.add(fastas.get(i)); + } + + if(isBAM){ + arguments.add("-I"); + } else if(isVCF){ + arguments.add("-V"); + } + + arguments.add(dict); + arguments.add("-O"); + arguments.add(output.getAbsolutePath()); + + final String[] args = arguments.toArray(new String[0]); + runCommandLine(args); + + IntegrationTestSpec.assertEqualTextFiles(output, expected); + } } \ No newline at end of file diff --git a/src/test/java/org/broadinstitute/hellbender/tools/reference/CompareReferencesIntegrationTest.java b/src/test/java/org/broadinstitute/hellbender/tools/reference/CompareReferencesIntegrationTest.java index 64ab4b7a9d3..6bf0b6ec380 100644 --- a/src/test/java/org/broadinstitute/hellbender/tools/reference/CompareReferencesIntegrationTest.java +++ b/src/test/java/org/broadinstitute/hellbender/tools/reference/CompareReferencesIntegrationTest.java @@ -8,6 +8,9 @@ import java.io.File; import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; public class CompareReferencesIntegrationTest extends CommandLineProgramTest { @@ -98,6 +101,46 @@ public void testCompareReferencesUseDictMD5MissingValue() throws IOException{ runCommandLine(args); } + @DataProvider(name = "cloudInputData") + public Object[][] cloudInputData() { + String testBucket = getGCPTestInputPath() + "org/broadinstitute/hellbender/tools/reference/"; + return new Object[][]{ + // list of refs, expected output + new Object[]{ Arrays.asList(testBucket + "hg19mini.fasta", + testBucket + "hg19mini_chr2snp.fasta"), + new File(getToolTestDataDir(), "expected.testCompareReferencesMissingValue.table") + }, + new Object[]{ Arrays.asList(testBucket + "hg19mini.fasta", + testBucket + "hg19mini_1renamed.fasta", + testBucket + "hg19mini_chr2snp.fasta"), + new File(getToolTestDataDir(), "expected.testCompareReferencesMultipleReferences.table") + }, + }; + } + + @Test(dataProvider = "cloudInputData", groups = "bucket") + public void testCompareReferencesCloudInputs(List fastas, File expected) throws IOException{ + final File output = createTempFile("testCompareReferencesCloudInputs", ".table"); + List arguments = new ArrayList<>(); + for(int i = 0; i < fastas.size(); i++){ + if(i == 0){ + arguments.add("-R"); + + } + else{ + arguments.add("-refcomp"); + } + arguments.add(fastas.get(i)); + } + arguments.add("-O"); + arguments.add(output.getAbsolutePath()); + + final String[] args = arguments.toArray(new String[0]); + runCommandLine(args); + + IntegrationTestSpec.assertEqualTextFiles(output, expected); + } + // no assertions made, testing tool runs successfully without -O argument @Test public void testCompareReferencesToStdOutput() throws IOException{