Search in sources :

Example 1 with ArgumentsBuilder

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

the class PrintReadsIntegrationTest method testNonExistentReference.

@Test(expectedExceptions = UserException.MissingReference.class)
public void testNonExistentReference() throws Exception {
    final File inCram = new File(TEST_DATA_DIR, "print_reads.sorted.cram");
    final File outCram = BaseTest.createTempFile("print_reads_bad_reference", ".cram");
    ArgumentsBuilder args = new ArgumentsBuilder();
    args.add("--" + StandardArgumentDefinitions.INPUT_LONG_NAME);
    args.add(inCram.getCanonicalPath());
    args.add("--" + StandardArgumentDefinitions.OUTPUT_LONG_NAME);
    args.add(outCram.getCanonicalPath());
    args.add("-R");
    args.add(BaseTest.getSafeNonExistentFile("Nonexistent.fasta").getCanonicalPath());
    runCommandLine(args.getArgsArray());
}
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)

Example 2 with ArgumentsBuilder

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

the class PrintReadsIntegrationTest method testReadFilters.

@Test(dataProvider = "readFilterTestData")
public void testReadFilters(final String input, final String reference, final String extOut, final List<String> inputArgs, final int expectedCount) throws IOException {
    final File outFile = createTempFile("testReadFilter", extOut);
    final ArgumentsBuilder args = new ArgumentsBuilder();
    args.add("-I");
    args.add(new File(TEST_DATA_DIR, input).getAbsolutePath());
    args.add("-O");
    args.add(outFile.getAbsolutePath());
    if (reference != null) {
        args.add("-R");
        args.add(new File(TEST_DATA_DIR, reference).getAbsolutePath());
    }
    for (final String filter : inputArgs) {
        args.add(filter);
    }
    runCommandLine(args);
    SamReaderFactory factory = SamReaderFactory.makeDefault();
    if (reference != null) {
        factory = factory.referenceSequence(new File(TEST_DATA_DIR, reference));
    }
    int count = 0;
    try (final SamReader reader = factory.open(outFile)) {
        Iterator<SAMRecord> it = reader.iterator();
        while (it.hasNext()) {
            SAMRecord rec = it.next();
            count++;
        }
    }
    Assert.assertEquals(count, expectedCount);
}
Also used : SamReader(htsjdk.samtools.SamReader) SamReaderFactory(htsjdk.samtools.SamReaderFactory) SAMRecord(htsjdk.samtools.SAMRecord) 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)

Example 3 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 4 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 5 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)

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