Search in sources :

Example 86 with ArgumentsBuilder

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

the class GenotypeGVCFsIntegrationTest method testIntervalsAndOnlyOutputCallsStartingInIntervalsAreMutuallyRequired.

@Test
public void testIntervalsAndOnlyOutputCallsStartingInIntervalsAreMutuallyRequired() {
    ArgumentsBuilder args = new ArgumentsBuilder().addVCF(getTestFile("leadingDeletion.g.vcf")).addReference(new File(b37_reference_20_21)).addOutput(createTempFile("tmp", ".vcf")).addBooleanArgument(GenotypeGVCFs.ONLY_OUTPUT_CALLS_STARTING_IN_INTERVALS_FULL_NAME, true);
    Assert.assertThrows(CommandLineException.MissingArgument.class, () -> runCommandLine(args));
    args.addArgument("L", "20:69512-69513");
    runCommandLine(args);
}
Also used : ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) File(java.io.File) CommandLineException(org.broadinstitute.barclay.argparser.CommandLineException) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 87 with ArgumentsBuilder

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

the class GenotypeGVCFsIntegrationTest method runGenotypeGVCFSAndAssertSomething.

private void runGenotypeGVCFSAndAssertSomething(String input, File expected, List<String> additionalArguments, BiConsumer<VariantContext, VariantContext> assertion, String reference) throws IOException {
    final File output = createTempFile("genotypegvcf", ".vcf");
    final ArgumentsBuilder args = new ArgumentsBuilder();
    args.addReference(new File(reference)).addArgument("V", input).addOutput(output);
    additionalArguments.forEach(args::add);
    Utils.resetRandomGenerator();
    runCommandLine(args);
    final List<VariantContext> expectedVC = getVariantContexts(expected);
    final List<VariantContext> actualVC = getVariantContexts(output);
    assertForEachElementInLists(actualVC, expectedVC, assertion);
}
Also used : VariantContext(htsjdk.variant.variantcontext.VariantContext) ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) File(java.io.File)

Example 88 with ArgumentsBuilder

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

the class DiscoverVariantsFromContigAlignmentsSGASparkIntegrationTest method testDiscoverVariantsFromContigAlignmentsSGASparkRunnableLocal.

@Test(dataProvider = "discoverVariantsFromContigAlignmentsSGASparkIntegrationTest", groups = "sv")
public void testDiscoverVariantsFromContigAlignmentsSGASparkRunnableLocal(final DiscoverVariantsFromContigAlignmentsSGASparkIntegrationTest.DiscoverVariantsFromContigAlignmentsSGASparkIntegrationTestArgs 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_INV_VCF, Arrays.asList("ALIGN_LENGTHS", "CTG_NAMES"), false);
    Assert.assertTrue(Files.exists(Paths.get(args.get(args.indexOf("--inputAlignments") + 1) + "_withMoreThanTwoAlignments")));
    Assert.assertTrue(Files.exists(Paths.get(args.get(args.indexOf("--inputAlignments") + 1) + "_withTwoAlignments")));
}
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 89 with ArgumentsBuilder

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

the class FindBreakpointEvidenceSparkIntegrationTest method testFindBreakpointRunnableMiniCluster.

@Test(dataProvider = "findBreakpointEvidenceSparkIntegrationTest", groups = "sv")
public void testFindBreakpointRunnableMiniCluster(final FindBreakpointEvidenceSparkIntegrationTestArgs 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.bam");
        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("--kmersToIgnore");
        path = new Path(workingDirectory, "dummy.kill.kmers");
        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("-O");
        path = new Path(workingDirectory, "assemblies.sam");
        argsToBeModified.set(idx + 1, path.toUri().toString());
        idx = argsToBeModified.indexOf("--breakpointIntervals");
        path = new Path(workingDirectory, "intervals");
        argsToBeModified.set(idx + 1, path.toUri().toString());
        idx = argsToBeModified.indexOf("--fastqDir");
        path = new Path(workingDirectory, "fastq");
        argsToBeModified.set(idx + 1, path.toUri().toString());
        new IntegrationTestSpec(String.join(" ", argsToBeModified), SVIntegrationTestDataProvider.dummyExpectedFileNames).executeTest("testFindBreakpointEvidenceSparkRunnableMiniCluster-", this);
    });
}
Also used : Path(org.apache.hadoop.fs.Path) IntegrationTestSpec(org.broadinstitute.hellbender.utils.test.IntegrationTestSpec) 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 90 with ArgumentsBuilder

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

the class QualityScoreDistributionSparkIntegrationTest method test.

@Test(dataProvider = "QualityScoreDistribution", groups = { "spark", "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);
    //Note we compare to non-spark outputs
    final File outfile = BaseTest.createTempFile("test", ".metrics");
    final File pdf = BaseTest.createTempFile("test", ".pdf");
    ArgumentsBuilder args = new ArgumentsBuilder();
    args.add("--" + StandardArgumentDefinitions.INPUT_LONG_NAME);
    args.add(unsortedBam.getCanonicalPath());
    args.add("--" + StandardArgumentDefinitions.OUTPUT_LONG_NAME);
    args.add(outfile.getCanonicalPath());
    if (null != referenceName) {
        final File REF = new File(referenceName);
        args.add("-R");
        args.add(REF.getAbsolutePath());
    }
    if (makePdf) {
        args.add("--" + "chart");
        args.add(pdf.getCanonicalPath());
    }
    args.add("--" + "pfReadsOnly");
    args.add(pfReadsOnly);
    args.add("--" + "alignedReadsOnly");
    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