Search in sources :

Example 16 with ArgumentsBuilder

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

the class CountBasesIntegrationTest method testCountBases.

@Test(dataProvider = "filenames")
public void testCountBases(final String fileIn, final String referenceName) throws Exception {
    final File ORIG_BAM = new File(getTestDataDir(), fileIn);
    final ArgumentsBuilder args = new ArgumentsBuilder();
    args.add("--input");
    args.add(ORIG_BAM.getAbsolutePath());
    if (null != referenceName) {
        final File REF = new File(getTestDataDir(), referenceName);
        args.add("-R");
        args.add(REF.getAbsolutePath());
    }
    final Object res = this.runCommandLine(args.getArgsArray());
    Assert.assertEquals(res, 808l);
}
Also used : ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) File(java.io.File) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 17 with ArgumentsBuilder

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

the class CountReadsIntegrationTest method testNoArgs.

@Test(expectedExceptions = CommandLineException.class)
public void testNoArgs() throws Exception {
    //making sure that this blows up in a very specific way (UserException.CommandLineException) if we give bogus arguments
    final ArgumentsBuilder args = new ArgumentsBuilder();
    this.runCommandLine(args.getArgsArray());
}
Also used : ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 18 with ArgumentsBuilder

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

the class CountVariantsIntegrationTest method testCountVariants.

@Test(dataProvider = "countVariantsVCFInputs")
public void testCountVariants(final File fileIn, final String moreArgs, final long expectedCount) throws Exception {
    final ArgumentsBuilder ab = new ArgumentsBuilder();
    ab.addVCF(fileIn);
    ab.add(moreArgs);
    final Object res = runCommandLine(ab.getArgsArray());
    Assert.assertEquals(res, expectedCount);
}
Also used : ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 19 with ArgumentsBuilder

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

the class PrintReadsIntegrationTest method testUnmappedReadInclusion.

@Test(dataProvider = "UnmappedReadInclusionTestData")
public void testUnmappedReadInclusion(final File input, final String reference, final List<String> intervalStrings, final List<String> expectedReadNames) {
    final File outFile = createTempFile("testUnmappedReadInclusion", ".bam");
    final ArgumentsBuilder args = new ArgumentsBuilder();
    args.add("-I");
    args.add(input.getAbsolutePath());
    args.add("-O");
    args.add(outFile.getAbsolutePath());
    for (final String intervalString : intervalStrings) {
        args.add("-L");
        args.add(intervalString);
    }
    if (reference != null) {
        args.add("-R");
        args.add(reference);
    }
    runCommandLine(args);
    try (final ReadsDataSource outputReadsSource = new ReadsDataSource(outFile.toPath())) {
        final List<GATKRead> actualReads = new ArrayList<>();
        for (final GATKRead read : outputReadsSource) {
            actualReads.add(read);
        }
        Assert.assertEquals(actualReads.size(), expectedReadNames.size(), "Wrong number of reads output");
        for (int readNumber = 0; readNumber < actualReads.size(); ++readNumber) {
            Assert.assertEquals(actualReads.get(readNumber).getName(), expectedReadNames.get(readNumber), "Unexpected read name");
        }
    }
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) ReadsDataSource(org.broadinstitute.hellbender.engine.ReadsDataSource) File(java.io.File) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 20 with ArgumentsBuilder

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

the class CollectBaseDistributionByCycleIntegrationTest method test.

@Test(dataProvider = "CollectBaseDistributionByCycle", groups = { "R" })
public void test(final String unsortedBamName, final String expectedFileName, final String referenceName, final boolean makePdf, final boolean pfReadsOnly, final boolean alignedReadsOnly) throws IOException {
    final File unsortedBam = new File(TEST_DATA_DIR, unsortedBamName);
    final File expectedFile = new File(TEST_DATA_DIR, expectedFileName);
    final File outfile = BaseTest.createTempFile("test", ".metrics");
    final File pdf = BaseTest.createTempFile("test", ".pdf");
    ArgumentsBuilder args = new ArgumentsBuilder();
    args.add("--" + "input");
    args.add(unsortedBam.getCanonicalPath());
    args.add("--" + "output");
    args.add(outfile.getCanonicalPath());
    if (null != referenceName) {
        final File REF = new File(referenceName);
        args.add("-R");
        args.add(REF.getAbsolutePath());
    }
    args.add("--" + "CHART_OUTPUT");
    args.add(pdf.getCanonicalPath());
    args.add("--" + "PRODUCE_PLOT");
    args.add(makePdf);
    args.add("--" + "PF_READS_ONLY");
    args.add(pfReadsOnly);
    args.add("--" + "ALIGNED_READS_ONLY");
    args.add(alignedReadsOnly);
    this.runCommandLine(args.getArgsArray());
    IntegrationTestSpec.assertEqualTextFiles(outfile, expectedFile, "#");
}
Also used : ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) File(java.io.File) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) 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