Search in sources :

Example 51 with ArgumentsBuilder

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

the class DiscoverVariantsFromContigAlignmentsSAMSparkIntegrationTest method testDiscoverVariantsRunnableMiniCluster.

@Test(dataProvider = "discoverVariantsFromContigAlignmentsSparkIntegrationTest", groups = "sv")
public void testDiscoverVariantsRunnableMiniCluster(final DiscoverVariantsFromContigAlignmentsSAMSparkIntegrationTestArgs params) throws Exception {
    MiniClusterUtils.runOnIsolatedMiniCluster(cluster -> {
        final List<String> argsToBeModified = Arrays.asList(new ArgumentsBuilder().add(params.getCommandLineNoApiKey()).getArgsArray());
        final Path workingDirectory = MiniClusterUtils.getWorkingDir(cluster);
        int idx = 0;
        idx = argsToBeModified.indexOf("-I");
        Path path = new Path(workingDirectory, "hdfs.sam");
        File file = new File(argsToBeModified.get(idx + 1));
        cluster.getFileSystem().copyFromLocalFile(new Path(file.toURI()), path);
        argsToBeModified.set(idx + 1, path.toUri().toString());
        idx = argsToBeModified.indexOf("-R");
        path = new Path(workingDirectory, "reference.2bit");
        file = new File(argsToBeModified.get(idx + 1));
        cluster.getFileSystem().copyFromLocalFile(new Path(file.toURI()), path);
        argsToBeModified.set(idx + 1, path.toUri().toString());
        idx = argsToBeModified.indexOf("--fastaReference");
        path = new Path(workingDirectory, "reference.fasta");
        file = new File(argsToBeModified.get(idx + 1));
        cluster.getFileSystem().copyFromLocalFile(new Path(file.toURI()), path);
        argsToBeModified.set(idx + 1, path.toUri().toString());
        path = new Path(workingDirectory, "reference.fasta.fai");
        cluster.getFileSystem().copyFromLocalFile(new Path(SVIntegrationTestDataProvider.reference_fai.toURI()), path);
        path = new Path(workingDirectory, "reference.dict");
        cluster.getFileSystem().copyFromLocalFile(new Path(SVIntegrationTestDataProvider.reference_dict.toURI()), path);
        idx = argsToBeModified.indexOf("-O");
        path = new Path(workingDirectory, "variants.vcf");
        final String vcfOnHDFS = path.toUri().toString();
        argsToBeModified.set(idx + 1, vcfOnHDFS);
        runCommandLine(argsToBeModified);
        StructuralVariationDiscoveryPipelineSparkIntegrationTest.svDiscoveryVCFEquivalenceTest(vcfOnHDFS, SVIntegrationTestDataProvider.EXPECTED_SIMPLE_DEL_VCF, Arrays.asList("ALIGN_LENGTHS", "CTG_NAMES"), true);
    });
}
Also used : Path(org.apache.hadoop.fs.Path) 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 52 with ArgumentsBuilder

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

the class DiscoverVariantsFromContigAlignmentsSAMSparkIntegrationTest method testDiscoverVariantsRunnableLocal.

@Test(dataProvider = "discoverVariantsFromContigAlignmentsSparkIntegrationTest", groups = "sv")
public void testDiscoverVariantsRunnableLocal(final DiscoverVariantsFromContigAlignmentsSAMSparkIntegrationTestArgs params) throws Exception {
    final List<String> args = Arrays.asList(new ArgumentsBuilder().add(params.getCommandLineNoApiKey()).getArgsArray());
    runCommandLine(args);
    StructuralVariationDiscoveryPipelineSparkIntegrationTest.svDiscoveryVCFEquivalenceTest(args.get(args.indexOf("-O") + 1), SVIntegrationTestDataProvider.EXPECTED_SIMPLE_DEL_VCF, Arrays.asList("ALIGN_LENGTHS", "CTG_NAMES"), false);
}
Also used : ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 53 with ArgumentsBuilder

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

the class CollectMultipleMetricsSparkIntegrationTest method testBuiltInCollectors.

@Test(dataProvider = "metricsTestFiles", groups = "spark")
public void testBuiltInCollectors(final String fileName, final String referenceName, final String expectedInsertSizeResults, final String expectedQualityYieldResults) throws IOException {
    ArgumentsBuilder args = new ArgumentsBuilder();
    String outBase = setupMultipleCollector(args, fileName, referenceName);
    // for now, run the only two conforming collectors that we have
    args.add("--collectors");
    args.add("CollectInsertSizeMetrics");
    args.add("--collectors");
    args.add("CollectQualityYieldMetrics");
    this.runCommandLine(args.getArgsArray());
    validateInsertSizeMetrics(outBase, expectedInsertSizeResults);
    validateQualityYieldMetrics(outBase, expectedQualityYieldResults);
}
Also used : ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 54 with ArgumentsBuilder

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

the class CollectQualityYieldMetricsSparkIntegrationTest method test.

@Test(dataProvider = "CollectQualityYieldMetrics", groups = "spark")
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 55 with ArgumentsBuilder

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

the class MeanQualityByCycleSparkIntegrationTest method test.

@Test(dataProvider = "filenames", groups = { "R", "spark" })
public void test(final String inputFile, final String referenceName) throws IOException {
    final File input = new File(TEST_DATA_DIR, inputFile);
    final File expectedFile = new File(TEST_DATA_DIR, "meanqualbycycle.txt");
    final File outfile = BaseTest.createTempFile("testMeanQualityByCycle", ".metrics");
    final File pdf = BaseTest.createTempFile("testMeanQualityByCycle", ".pdf");
    outfile.deleteOnExit();
    pdf.deleteOnExit();
    final ArgumentsBuilder args = new ArgumentsBuilder();
    args.add("--input");
    args.add(input.getAbsolutePath());
    args.add("--output");
    args.add(outfile.getAbsolutePath());
    args.add("--chart");
    args.add(pdf.getAbsolutePath());
    if (null != referenceName) {
        final File REF = new File(referenceName);
        args.add("-R");
        args.add(REF.getAbsolutePath());
    }
    runCommandLine(args.getArgsArray());
    try (final FileReader actualReader = new FileReader(outfile)) {
        final MetricsFile<?, Integer> output = new MetricsFile<>();
        output.read(actualReader);
        Assert.assertEquals(output.getAllHistograms().size(), 1);
        Assert.assertEquals(output.getHistogram().size(), 202);
    }
    Assert.assertTrue(pdf.exists(), "exists");
    Assert.assertTrue(pdf.length() > 0, "length");
    IntegrationTestSpec.assertEqualTextFiles(outfile, expectedFile, "#");
}
Also used : MetricsFile(htsjdk.samtools.metrics.MetricsFile) ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) FileReader(java.io.FileReader) 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)

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