1 package org.broadinstitute.hellbender.engine; 2 3 import org.broadinstitute.hellbender.CommandLineProgramTest; 4 import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions; 5 import org.broadinstitute.hellbender.tools.walkers.variantutils.SelectVariants; 6 import org.broadinstitute.hellbender.utils.SimpleInterval; 7 import org.broadinstitute.hellbender.testutils.IntegrationTestSpec; 8 import org.testng.annotations.DataProvider; 9 import org.testng.annotations.Test; 10 11 import java.io.IOException; 12 import java.util.Arrays; 13 import java.util.Collections; 14 import java.util.List; 15 16 /** 17 * Tests to prove that we can access and query inputs on Google Cloud Storage (GCS) in VariantWalkers. 18 */ 19 public class VariantWalkerGCSSupportIntegrationTest extends CommandLineProgramTest { 20 21 private static final String TEST_VCF_ON_GCS = "org/broadinstitute/hellbender/engine/dbsnp_138.b37.20.10000000-10010000.vcf"; 22 private static final String TEST_BGZIPPED_VCF_ON_GCS = "org/broadinstitute/hellbender/engine/dbsnp_138.b37.20.10000000-10010000.vcf.block.gz"; 23 private static final String EXPECTED_OUTPUT_DIR = publicTestDir + "org/broadinstitute/hellbender/engine/GCSTests/"; 24 25 @Override getTestedToolName()26 public String getTestedToolName() { 27 return SelectVariants.class.getSimpleName(); 28 } 29 30 @DataProvider(name = "GCSTestCases") getGCSTestCases()31 public Object[][] getGCSTestCases() { 32 final SimpleInterval singleInterval = new SimpleInterval("20", 10004000, 10006000); 33 final List<SimpleInterval> multipleIntervals = Arrays.asList(singleInterval, new SimpleInterval("20", 10008000, 10009000)); 34 35 final String EXPECTED_WHOLE_FILE_RESULTS = EXPECTED_OUTPUT_DIR + "expected_VariantWalkerGCSSupportIntegrationTest_vcf_wholefile.vcf"; 36 final String EXPECTED_SINGLE_INTERVAL_RESULTS = EXPECTED_OUTPUT_DIR + "expected_VariantWalkerGCSSupportIntegrationTest_vcf_single_interval.vcf"; 37 final String EXPECTED_MULTIPLE_INTERVALS_RESULTS = EXPECTED_OUTPUT_DIR + "expected_VariantWalkerGCSSupportIntegrationTest_vcf_multiple_intervals.vcf"; 38 39 return new Object[][] { 40 { TEST_VCF_ON_GCS, null, EXPECTED_WHOLE_FILE_RESULTS }, 41 { TEST_BGZIPPED_VCF_ON_GCS, null, EXPECTED_WHOLE_FILE_RESULTS }, 42 { TEST_VCF_ON_GCS, Collections.singletonList(singleInterval), EXPECTED_SINGLE_INTERVAL_RESULTS }, 43 { TEST_BGZIPPED_VCF_ON_GCS, Collections.singletonList(singleInterval), EXPECTED_SINGLE_INTERVAL_RESULTS }, 44 { TEST_VCF_ON_GCS, multipleIntervals, EXPECTED_MULTIPLE_INTERVALS_RESULTS }, 45 { TEST_BGZIPPED_VCF_ON_GCS, multipleIntervals, EXPECTED_MULTIPLE_INTERVALS_RESULTS } 46 }; 47 } 48 49 @Test(dataProvider = "GCSTestCases", groups = {"bucket"}) testReadVCFOnGCS( final String vcf, final List<SimpleInterval> intervals, final String expectedOutput )50 public void testReadVCFOnGCS( final String vcf, final List<SimpleInterval> intervals, final String expectedOutput ) throws IOException { 51 String intervalArg = ""; 52 if ( intervals != null ) { 53 final StringBuilder intervalArgBuilder = new StringBuilder(); 54 for ( final SimpleInterval interval : intervals ) { 55 intervalArgBuilder.append(" -L "); 56 intervalArgBuilder.append(interval.toString()); 57 } 58 intervalArg = intervalArgBuilder.toString(); 59 } 60 61 final IntegrationTestSpec testSpec = new IntegrationTestSpec( 62 " -V " + getGCPTestInputPath() + vcf + 63 intervalArg + 64 " -O %s "+ " --" + StandardArgumentDefinitions.ADD_OUTPUT_VCF_COMMANDLINE + " false", 65 Collections.singletonList(expectedOutput) 66 ); 67 testSpec.executeTest("testReadVCFOnGCS", this); 68 } 69 } 70