Search in sources :

Example 6 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 7 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)

Example 8 with ArgumentsBuilder

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

the class CollectInsertSizeMetricsIntegrationTest method test.

@Test(dataProvider = "metricsfiles")
public void test(final String fileName, final String referenceName, final boolean allLevels, final String expectedResultsFile) throws IOException {
    final File input = new File(TEST_DATA_DIR, fileName);
    final File outfile = BaseTest.createTempFile("test", ".insert_size_metrics");
    final File pdf = BaseTest.createTempFile("test", ".pdf");
    final ArgumentsBuilder args = new ArgumentsBuilder();
    args.add("--input");
    args.add(input.getAbsolutePath());
    args.add("--output");
    args.add(outfile.getAbsolutePath());
    if (null != referenceName) {
        final File REF = new File(referenceName);
        args.add("-R");
        args.add(REF.getAbsolutePath());
    }
    if (allLevels) {
        // accumulation level options (all included for better test coverage)
        args.add("-" + "LEVEL");
        args.add(MetricAccumulationLevel.ALL_READS.toString());
        args.add("-" + "LEVEL");
        args.add(MetricAccumulationLevel.SAMPLE.toString());
        args.add("-" + "LEVEL");
        args.add(MetricAccumulationLevel.LIBRARY.toString());
        args.add("-" + "LEVEL");
        args.add(MetricAccumulationLevel.READ_GROUP.toString());
    }
    args.add("--producePlot");
    args.add("--histogramPlotFile");
    args.add(pdf.getAbsolutePath());
    runCommandLine(args.getArgsArray());
    IntegrationTestSpec.assertEqualTextFiles(outfile, new File(TEST_DATA_DIR, expectedResultsFile), "#");
}
Also used : ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) MetricsFile(htsjdk.samtools.metrics.MetricsFile) File(java.io.File) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 9 with ArgumentsBuilder

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

the class CollectQualityYieldMetricsIntegrationTest method test.

@Test(dataProvider = "CollectQualityYieldMetrics")
public void test(final String inName, final String outName, final String referenceName, final boolean useOQ) throws IOException {
    final File input = new File(TEST_DATA_DIR, inName);
    //file created using picard 1.130
    final File expectedFile = new File(TEST_DATA_DIR, outName);
    final File outfile = BaseTest.createTempFile("testCollectQualityYield", ".metrics");
    ArgumentsBuilder args = new ArgumentsBuilder();
    args.add("--I");
    args.add(input.getCanonicalPath());
    args.add("--O");
    args.add(outfile.getCanonicalPath());
    if (null != referenceName) {
        final File REF = new File(referenceName);
        args.add("--R");
        args.add(REF.getAbsolutePath());
    }
    args.add("-OQ");
    args.add(String.valueOf(useOQ));
    runCommandLine(args.getArgsList());
    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)

Example 10 with ArgumentsBuilder

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

the class GenomicsDBImportIntegrationTest method testSampleMappingFileInsteadOfVCFs.

@Test
public void testSampleMappingFileInsteadOfVCFs() throws IOException {
    final File sampleNameFile = createTempSampleMapFile();
    final String workspace = createTempDir("gendbtest").getAbsolutePath() + "/workspace";
    final ArgumentsBuilder args = new ArgumentsBuilder().addArgument(GenomicsDBImport.SAMPLE_NAME_MAP_LONG_NAME, sampleNameFile.getAbsolutePath()).addArgument("L", IntervalUtils.locatableToString(INTERVAL)).addArgument(GenomicsDBImport.WORKSPACE_ARG_NAME, workspace);
    runCommandLine(args);
    checkJSONFilesAreWritten(workspace);
    checkGenomicsDBAgainstExpected(workspace, INTERVAL, COMBINED);
}
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