Skip to content

Commit

Permalink
Cloud tests for CompareReferences and CheckReferenceCompatibility too…
Browse files Browse the repository at this point in the history
…ls (#7973)

* Comprehensive cloud tests for CompareReferences and CheckReferenceCompatibility tools.
  • Loading branch information
orlicohen authored Aug 4, 2022
1 parent c22972a commit 8d81423
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
* <pre>
* gatk CompareReferences \
* -R reference1.fasta \
* -refcomp reference2.fasta
* -refcomp reference2.fasta \
* -O output.fasta \
* -md5-calculation-mode USE_DICT
* </pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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<String> fastas, File expected, boolean isBAM, boolean isVCF) throws IOException{
final File output = createTempFile("testCompareReferencesCloudInputs", ".table");

List<String> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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<String> fastas, File expected) throws IOException{
final File output = createTempFile("testCompareReferencesCloudInputs", ".table");
List<String> 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{
Expand Down

0 comments on commit 8d81423

Please # to comment.