Search in sources :

Example 31 with ArgumentsBuilder

use of org.broadinstitute.hellbender.utils.test.ArgumentsBuilder in project gatk by broadinstitute.

the class CountReadsSparkIntegrationTest method test.

@Test(groups = "spark")
public void test() throws Exception {
    final File unsortedBam = new File(getTestDataDir(), "count_reads.bam");
    final File outputTxt = createTempFile("count_reads", ".txt");
    ArgumentsBuilder args = new ArgumentsBuilder();
    args.addInput(unsortedBam);
    args.addOutput(outputTxt);
    this.runCommandLine(args.getArgsArray());
    final String readIn = FileUtils.readFileToString(outputTxt.getAbsoluteFile());
    Assert.assertEquals((int) Integer.valueOf(readIn), 8);
}
Also used : ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) File(java.io.File) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 32 with ArgumentsBuilder

use of org.broadinstitute.hellbender.utils.test.ArgumentsBuilder in project gatk by broadinstitute.

the class CountVariantsSparkIntegrationTest method test.

@Test(dataProvider = "filenames", groups = "spark")
public void test(final File fileIn, final long expected) throws Exception {
    final File outputTxt = createTempFile("count_variants", ".txt");
    ArgumentsBuilder args = new ArgumentsBuilder();
    args.addVCF(fileIn);
    args.addOutput(outputTxt);
    this.runCommandLine(args.getArgsArray());
    final String readIn = FileUtils.readFileToString(outputTxt.getAbsoluteFile());
    Assert.assertEquals((int) Integer.valueOf(readIn), expected);
}
Also used : ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) File(java.io.File) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 33 with ArgumentsBuilder

use of org.broadinstitute.hellbender.utils.test.ArgumentsBuilder in project gatk by broadinstitute.

the class CountVariantsSparkIntegrationTest method testNoNPRWhenOutputIsUnspecified.

@Test(groups = "spark")
public void testNoNPRWhenOutputIsUnspecified() {
    ArgumentsBuilder args = new ArgumentsBuilder();
    args.addVCF(COUNT_VARIANTS_VCF);
    this.runCommandLine(args.getArgsArray());
}
Also used : ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 34 with ArgumentsBuilder

use of org.broadinstitute.hellbender.utils.test.ArgumentsBuilder in project gatk by broadinstitute.

the class CountVariantsSparkIntegrationTest method testCountVariantsWithIntervals.

@Test(dataProvider = "intervals", groups = "spark")
public void testCountVariantsWithIntervals(final File fileIn, final String intervalArgs, final long expected) throws Exception {
    final File outputTxt = createTempFile("count_variants", ".txt");
    ArgumentsBuilder args = new ArgumentsBuilder();
    args.addVCF(fileIn);
    args.add(intervalArgs);
    args.addReference(new File(largeFileTestDir, "human_g1k_v37.20.21.fasta"));
    args.addOutput(outputTxt);
    this.runCommandLine(args.getArgsArray());
    final ByteArrayOutputStream baosErr = new ByteArrayOutputStream();
    final PrintStream err = System.err;
    try {
        System.setErr(new PrintStream(baosErr));
        this.runCommandLine(args.getArgsArray());
        final String readIn = FileUtils.readFileToString(outputTxt.getAbsoluteFile());
        Assert.assertEquals((int) Integer.valueOf(readIn), expected);
        String errString = baosErr.toString();
        Assert.assertFalse(errString.contains("Warning: using GzipCodec, which is not splittable,"), errString);
    } finally {
        //put this back in
        System.setErr(err);
    }
}
Also used : PrintStream(java.io.PrintStream) ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) ByteArrayOutputStream(java.io.ByteArrayOutputStream) File(java.io.File) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 35 with ArgumentsBuilder

use of org.broadinstitute.hellbender.utils.test.ArgumentsBuilder in project gatk by broadinstitute.

the class FlagStatSparkIntegrationTest method flagStatSparkLocalWithSmallInterval.

@Test(groups = "spark")
public void flagStatSparkLocalWithSmallInterval() throws IOException {
    ArgumentsBuilder args = new ArgumentsBuilder();
    args.addInput(getTestFile("flag_stat.bam"));
    args.add("-L chr7:1-100 -XL chr7:2-100");
    File outputFile = createTempFile("flagStatTest.chr1_1", ".txt");
    args.addOutput(outputFile);
    this.runCommandLine(args.getArgsArray());
    Assert.assertTrue(outputFile.exists());
    //the expected output was created using stand-alone hellbender
    IntegrationTestSpec.assertMatchingFiles(Lists.newArrayList(outputFile), Lists.newArrayList(getToolTestDataDir() + "/" + "expectedStats.chr1_1.txt"), false, null);
}
Also used : ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) File(java.io.File) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Aggregations

ArgumentsBuilder (org.broadinstitute.hellbender.utils.test.ArgumentsBuilder)139 Test (org.testng.annotations.Test)127 CommandLineProgramTest (org.broadinstitute.hellbender.CommandLineProgramTest)123 File (java.io.File)104 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)62 IntegrationTestSpec (org.broadinstitute.hellbender.utils.test.IntegrationTestSpec)14 MetricsFile (htsjdk.samtools.metrics.MetricsFile)10 Path (org.apache.hadoop.fs.Path)5 VariantContext (htsjdk.variant.variantcontext.VariantContext)4 AbstractMarkDuplicatesCommandLineProgramTest (org.broadinstitute.hellbender.utils.test.testers.AbstractMarkDuplicatesCommandLineProgramTest)4 FileReader (java.io.FileReader)3 Configuration (org.apache.hadoop.conf.Configuration)3 Main (org.broadinstitute.hellbender.Main)3 CommandLineProgram (org.broadinstitute.hellbender.cmdline.CommandLineProgram)3 SAMRecord (htsjdk.samtools.SAMRecord)2 SamReader (htsjdk.samtools.SamReader)2 SamReaderFactory (htsjdk.samtools.SamReaderFactory)2 List (java.util.List)2 org.apache.hadoop.fs (org.apache.hadoop.fs)2 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)2