Search in sources :

Example 46 with ArgumentsBuilder

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

the class PileupSparkIntegrationTest method testFeaturesPileup.

@Test(dataProvider = "shuffle")
public void testFeaturesPileup(boolean useShuffle) throws Exception {
    final File out = createTempFile();
    final ArgumentsBuilder args = new ArgumentsBuilder();
    args.add("--input");
    args.add(NA12878_20_21_WGS_bam);
    args.add("--output");
    args.add(out.getAbsolutePath());
    args.add("--reference");
    args.add(b37_reference_20_21);
    args.add("-L 20:10000092-10000112");
    args.add("-metadata " + dbsnp_138_b37_20_21_vcf);
    if (useShuffle) {
        args.add("--shuffle");
    }
    this.runCommandLine(args.getArgsArray());
    File expected = new File(TEST_DATA_DIR, "expectedFeaturesPileup.txt");
    IntegrationTestSpec.assertEqualTextFiles(new File(out, "part-00000"), expected);
}
Also used : ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) File(java.io.File) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 47 with ArgumentsBuilder

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

the class GatherBQSRReportsIntegrationTest method testCombine5Reports.

@Test
public void testCombine5Reports() throws Exception {
    final File recal1 = new File(testDir + "HiSeq.1mb.1RG.sg1.table");
    final File recal2 = new File(testDir + "HiSeq.1mb.1RG.sg2.table");
    final File recal3 = new File(testDir + "HiSeq.1mb.1RG.sg3.table");
    final File recal4 = new File(testDir + "HiSeq.1mb.1RG.sg4.table");
    final File recal5 = new File(testDir + "HiSeq.1mb.1RG.sg5.table");
    //Note: the expected output was created by running GATK3, fixing table headers and sorting in unix "sort -k 2,2 -k 3,3 -k 4,4"
    final File recal_original = new File(testDir + "HiSeq.1mb.1RG.noSG.table");
    final ArgumentsBuilder args = new ArgumentsBuilder();
    args.add("--input");
    args.add(recal1.getAbsolutePath());
    args.add("--input");
    args.add(recal2.getAbsolutePath());
    args.add("--input");
    args.add(recal3.getAbsolutePath());
    args.add("--input");
    args.add(recal4.getAbsolutePath());
    args.add("--input");
    args.add(recal5.getAbsolutePath());
    final File outFile = BaseTest.createTempFile("bqsr.", "table");
    args.add("-O");
    args.add(outFile.getAbsolutePath());
    final Object res = this.runCommandLine(args.getArgsArray());
    Assert.assertEquals(res, 0);
    IntegrationTestSpec.assertEqualTextFiles(outFile, recal_original);
}
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 48 with ArgumentsBuilder

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

the class ApplyVQSRIntegrationTest method testApplyRecalibrationSnpAndIndelTogetherExcludeFiltered.

@Test
public void testApplyRecalibrationSnpAndIndelTogetherExcludeFiltered() throws Exception {
    ArgumentsBuilder args = new ArgumentsBuilder();
    File tempOut = createTempFile("testApplyRecalibrationSnpAndIndelTogetherExcludeFiltered", ".vcf");
    args.add("--variant");
    args.add(new File(getToolTestDataDir() + "VQSR.mixedTest.input.vcf"));
    args.add("-L");
    args.add("20:1000100-1000500");
    args.add("-mode");
    args.add("BOTH");
    args.add("--excludeFiltered");
    args.add("-ts_filter_level");
    args.add("90.0");
    args.add("-tranchesFile ");
    args.add(getToolTestDataDir() + "VQSR.mixedTest.tranches");
    args.add("-recalFile");
    args.add(getToolTestDataDir() + "VQSR.mixedTest.recal.vcf");
    args.addOutput(tempOut);
    runCommandLine(args);
    try (FeatureDataSource<VariantContext> featureSource = new FeatureDataSource<>(tempOut)) {
        for (VariantContext feature : featureSource) {
            // there should only be unfiltered records in the output VCF file
            Assert.assertTrue(feature.isNotFiltered());
        }
    }
}
Also used : VariantContext(htsjdk.variant.variantcontext.VariantContext) ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) File(java.io.File) FeatureDataSource(org.broadinstitute.hellbender.engine.FeatureDataSource) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 49 with ArgumentsBuilder

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

the class AlignAssembledContigsSparkIntegrationTest method testAlignAssembledContigsSparkRunnableMiniCluster.

@Test(dataProvider = "alignAssembledContigsSparkIntegrationTest", groups = "sv")
public void testAlignAssembledContigsSparkRunnableMiniCluster(final AlignAssembledContigsSparkIntegrationTest.AlignAssembledContigsSparkIntegrationTestArgs params) throws Exception {
    MiniClusterUtils.runOnIsolatedMiniCluster(cluster -> {
        final List<String> argsToBeModified = Arrays.asList(new ArgumentsBuilder().add(params.getCommandLineNoApiKey()).getArgsArray());
        final org.apache.hadoop.fs.Path workingDirectory = MiniClusterUtils.getWorkingDir(cluster);
        int idx = 0;
        idx = argsToBeModified.indexOf("--inputAssemblyDir");
        org.apache.hadoop.fs.Path path = new org.apache.hadoop.fs.Path(workingDirectory, "contents.txt");
        File file = new File(argsToBeModified.get(idx + 1));
        cluster.getFileSystem().copyFromLocalFile(new org.apache.hadoop.fs.Path(file.toURI()), path);
        argsToBeModified.set(idx + 1, path.toUri().toString());
        path = new org.apache.hadoop.fs.Path(workingDirectory, "reference.fasta");
        cluster.getFileSystem().copyFromLocalFile(new org.apache.hadoop.fs.Path(SVIntegrationTestDataProvider.reference.toURI()), path);
        path = new org.apache.hadoop.fs.Path(workingDirectory, "reference.fasta.fai");
        cluster.getFileSystem().copyFromLocalFile(new org.apache.hadoop.fs.Path(SVIntegrationTestDataProvider.reference_fai.toURI()), path);
        path = new org.apache.hadoop.fs.Path(workingDirectory, "reference.2bit");
        cluster.getFileSystem().copyFromLocalFile(new org.apache.hadoop.fs.Path(SVIntegrationTestDataProvider.reference_2bit.toURI()), path);
        path = new org.apache.hadoop.fs.Path(workingDirectory, "reference.dict");
        cluster.getFileSystem().copyFromLocalFile(new org.apache.hadoop.fs.Path(SVIntegrationTestDataProvider.reference_dict.toURI()), path);
        idx = argsToBeModified.indexOf("-O");
        path = new org.apache.hadoop.fs.Path(workingDirectory, "alignedContigs.txt");
        argsToBeModified.set(idx + 1, path.toUri().toString());
        new IntegrationTestSpec(String.join(" ", argsToBeModified), SVIntegrationTestDataProvider.dummyExpectedFileNames).executeTest("testAlignAssembledContigsSparkRunnableMiniCluster-", this);
    });
}
Also used : 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 50 with ArgumentsBuilder

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

the class DiscoverVariantsFromContigAlignmentsSGASparkIntegrationTest method testDiscoverVariantsRunnableMiniCluster.

@Test(dataProvider = "discoverVariantsFromContigAlignmentsSGASparkIntegrationTest", groups = "sv")
public void testDiscoverVariantsRunnableMiniCluster(final DiscoverVariantsFromContigAlignmentsSGASparkIntegrationTest.DiscoverVariantsFromContigAlignmentsSGASparkIntegrationTestArgs 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("--inputAssemblies");
        Path path = new Path(workingDirectory, "assemblies_0");
        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("--inputAlignments");
        path = new Path(workingDirectory, "alignments");
        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_INV_VCF, Arrays.asList("ALIGN_LENGTHS", "CTG_NAMES"), true);
        final RemoteIterator<LocatedFileStatus> it = FileSystem.get(workingDirectory.toUri(), new Configuration()).listFiles(workingDirectory, true);
        while (it.hasNext()) System.err.println(it.next());
        final FileSystem fs = FileSystem.get(workingDirectory.toUri(), new Configuration());
        Assert.assertTrue(fs.exists(new Path(argsToBeModified.get(argsToBeModified.indexOf("--inputAlignments") + 1) + "_withTwoAlignments")));
        Assert.assertTrue(fs.exists(new Path(argsToBeModified.get(argsToBeModified.indexOf("--inputAlignments") + 1) + "_withMoreThanTwoAlignments")));
    });
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) FileSystem(org.apache.hadoop.fs.FileSystem) LocatedFileStatus(org.apache.hadoop.fs.LocatedFileStatus) 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