1 package org.broadinstitute.hellbender.tools.spark.pipelines; 2 3 import com.google.common.collect.Lists; 4 import org.broadinstitute.hellbender.CommandLineProgramTest; 5 import org.broadinstitute.hellbender.testutils.ArgumentsBuilder; 6 import org.broadinstitute.hellbender.testutils.IntegrationTestSpec; 7 import org.testng.Assert; 8 import org.testng.annotations.Test; 9 10 import java.io.File; 11 import java.io.IOException; 12 13 public final class FlagStatSparkIntegrationTest extends CommandLineProgramTest { 14 15 @Override getTestedClassName()16 public String getTestedClassName() { 17 return FlagStatSpark.class.getSimpleName(); 18 } 19 20 @Test(groups = "spark") flagStatSparkLocalNoInterval()21 public void flagStatSparkLocalNoInterval() throws IOException { 22 File outputFile = createTempFile("flagStatTest", ".txt"); 23 24 ArgumentsBuilder args = new ArgumentsBuilder(); 25 args.addInput(getTestFile("flag_stat.bam")); 26 args.addOutput(outputFile); 27 28 this.runCommandLine(args.getArgsArray()); 29 30 Assert.assertTrue(outputFile.exists()); 31 //the expected output was created using stand-alone hellbender 32 IntegrationTestSpec.assertMatchingFiles(Lists.newArrayList(outputFile), Lists.newArrayList(getToolTestDataDir() +"/"+ "expectedStats.txt"), false, null); 33 } 34 @Test(groups = "spark") flagStatSparkLocalWithBigInterval()35 public void flagStatSparkLocalWithBigInterval() throws IOException { 36 ArgumentsBuilder args = new ArgumentsBuilder(); 37 38 args.addInput(getTestFile("flag_stat.bam")); 39 args.addRaw("-L"); args.addRaw("chr1"); 40 args.addRaw("-L"); args.addRaw("chr2"); 41 args.addRaw("-L"); args.addRaw("chr3"); 42 args.addRaw("-L"); args.addRaw("chr4"); 43 args.addRaw("-L"); args.addRaw("chr5"); 44 args.addRaw("-L"); args.addRaw("chr6"); 45 args.addRaw("-L"); args.addRaw("chr7"); 46 args.addRaw("-L"); args.addRaw("chr8"); 47 File outputFile = createTempFile("flagStatTest", ".txt"); 48 args.addOutput(outputFile); 49 50 this.runCommandLine(args.getArgsArray()); 51 52 Assert.assertTrue(outputFile.exists()); 53 //the expected output was created using stand-alone hellbender 54 IntegrationTestSpec.assertMatchingFiles(Lists.newArrayList(outputFile), Lists.newArrayList(getToolTestDataDir() +"/"+ "expectedStats.chr1-chr8.txt"), false, null); 55 } 56 57 @Test(groups = "spark") flagStatSparkLocalWithSmallInterval()58 public void flagStatSparkLocalWithSmallInterval() throws IOException { 59 ArgumentsBuilder args = new ArgumentsBuilder(); 60 61 args.addInput(getTestFile("flag_stat.bam")); 62 args.addRaw("-L chr7:1-100 -XL chr7:2-100"); 63 File outputFile = createTempFile("flagStatTest.chr1_1", ".txt"); 64 args.addOutput(outputFile); 65 66 this.runCommandLine(args.getArgsArray()); 67 68 Assert.assertTrue(outputFile.exists()); 69 //the expected output was created using stand-alone hellbender 70 IntegrationTestSpec.assertMatchingFiles(Lists.newArrayList(outputFile), Lists.newArrayList(getToolTestDataDir() +"/"+ "expectedStats.chr1_1.txt"), false, null); 71 } 72 73 @Test(groups = "spark") testNoNPRWhenOutputIsUnspecified()74 public void testNoNPRWhenOutputIsUnspecified(){ 75 ArgumentsBuilder args = new ArgumentsBuilder(); 76 args.addInput(getTestFile("flag_stat.bam")); 77 this.runCommandLine(args.getArgsArray()); 78 } 79 } 80