Search in sources :

Example 36 with CommandLineArgumentParser

use of org.broadinstitute.barclay.argparser.CommandLineArgumentParser in project gatk by broadinstitute.

the class GATKToolUnitTest method createTestVariantTool.

private TestGATKToolWithVariants createTestVariantTool(final String[] args) {
    final TestGATKToolWithVariants tool = new TestGATKToolWithVariants();
    if (null != args) {
        final CommandLineParser clp = new CommandLineArgumentParser(tool);
        clp.parseArguments(System.out, args);
    }
    return tool;
}
Also used : CommandLineArgumentParser(org.broadinstitute.barclay.argparser.CommandLineArgumentParser) CommandLineParser(org.broadinstitute.barclay.argparser.CommandLineParser)

Example 37 with CommandLineArgumentParser

use of org.broadinstitute.barclay.argparser.CommandLineArgumentParser in project gatk by broadinstitute.

the class GATKToolUnitTest method testBestSequenceDictionary_fromVariants.

@Test
public void testBestSequenceDictionary_fromVariants() throws Exception {
    final GATKTool tool = new TestGATKToolWithFeatures();
    final CommandLineParser clp = new CommandLineArgumentParser(tool);
    final File vcfFile = new File(publicTestDir + "org/broadinstitute/hellbender/engine/feature_data_source_test_withSequenceDict.vcf");
    final String[] args = { "--mask", vcfFile.getCanonicalPath() };
    clp.parseArguments(System.out, args);
    tool.onStartup();
    //read the dict back in and compare to vcf dict
    final SAMSequenceDictionary toolDict = tool.getBestAvailableSequenceDictionary();
    try (final VCFFileReader reader = new VCFFileReader(vcfFile)) {
        final SAMSequenceDictionary vcfDict = reader.getFileHeader().getSequenceDictionary();
        toolDict.assertSameDictionary(vcfDict);
        vcfDict.assertSameDictionary(toolDict);
        Assert.assertEquals(toolDict, vcfDict);
    }
}
Also used : CommandLineArgumentParser(org.broadinstitute.barclay.argparser.CommandLineArgumentParser) VCFFileReader(htsjdk.variant.vcf.VCFFileReader) CommandLineParser(org.broadinstitute.barclay.argparser.CommandLineParser) File(java.io.File) IndexedFastaSequenceFile(htsjdk.samtools.reference.IndexedFastaSequenceFile) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 38 with CommandLineArgumentParser

use of org.broadinstitute.barclay.argparser.CommandLineArgumentParser in project gatk by broadinstitute.

the class GATKToolUnitTest method testBestSequenceDictionary_fromNothing.

@Test
public void testBestSequenceDictionary_fromNothing() throws Exception {
    final GATKTool tool = new TestGATKToolWithNothing();
    final CommandLineParser clp = new CommandLineArgumentParser(tool);
    final String[] args = {};
    clp.parseArguments(System.out, args);
    tool.onStartup();
    //read the dict back in and assert that it's null
    final SAMSequenceDictionary toolDict = tool.getBestAvailableSequenceDictionary();
    Assert.assertNull(toolDict);
}
Also used : CommandLineArgumentParser(org.broadinstitute.barclay.argparser.CommandLineArgumentParser) CommandLineParser(org.broadinstitute.barclay.argparser.CommandLineParser) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 39 with CommandLineArgumentParser

use of org.broadinstitute.barclay.argparser.CommandLineArgumentParser in project gatk by broadinstitute.

the class GATKToolUnitTest method setupVCFWriter.

private File setupVCFWriter(final File inputFile, final String outputExtension, final GATKTool tool, final boolean createIndex, final boolean createMD5, final boolean lenient) throws IOException {
    final File tmpDir = createTempDir("createVCFTest");
    final File outputFile = new File(tmpDir.getAbsolutePath(), "createVCFTest" + outputExtension);
    ArgumentsBuilder args = new ArgumentsBuilder();
    args.addInput(inputFile);
    args.addOutput(outputFile);
    args.add("--createOutputVariantIndex");
    args.add(Boolean.toString(createIndex));
    args.add("--createOutputVariantMD5");
    args.add(Boolean.toString(createMD5));
    if (lenient) {
        args.add("--lenient");
    }
    final CommandLineParser clp = new CommandLineArgumentParser(tool);
    clp.parseArguments(System.out, args.getArgsArray());
    return outputFile;
}
Also used : CommandLineArgumentParser(org.broadinstitute.barclay.argparser.CommandLineArgumentParser) ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) CommandLineParser(org.broadinstitute.barclay.argparser.CommandLineParser) File(java.io.File) IndexedFastaSequenceFile(htsjdk.samtools.reference.IndexedFastaSequenceFile)

Example 40 with CommandLineArgumentParser

use of org.broadinstitute.barclay.argparser.CommandLineArgumentParser in project gatk by broadinstitute.

the class GATKToolUnitTest method testValidationStringency.

private void testValidationStringency(final String bamFileName, final String referenceFileName, final String validationStringency, final int count) throws SAMFormatException {
    final TestGATKToolValidationStringency tool = new TestGATKToolValidationStringency();
    final CommandLineParser clp = new CommandLineArgumentParser(tool);
    final File bamFile = new File(NA12878_chr17_1k_CRAM);
    final File refFile = new File(v37_chr17_1Mb_Reference);
    final String[] args = { "-I", bamFileName, "-R", referenceFileName, "-VS", validationStringency };
    clp.parseArguments(System.out, args);
    tool.onStartup();
    tool.doWork();
    tool.onShutdown();
    Assert.assertEquals(tool.getCount(), count);
}
Also used : CommandLineArgumentParser(org.broadinstitute.barclay.argparser.CommandLineArgumentParser) CommandLineParser(org.broadinstitute.barclay.argparser.CommandLineParser) File(java.io.File) IndexedFastaSequenceFile(htsjdk.samtools.reference.IndexedFastaSequenceFile)

Aggregations

CommandLineArgumentParser (org.broadinstitute.barclay.argparser.CommandLineArgumentParser)47 CommandLineParser (org.broadinstitute.barclay.argparser.CommandLineParser)47 Test (org.testng.annotations.Test)44 GATKReadFilterPluginDescriptor (org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor)25 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)13 File (java.io.File)11 IndexedFastaSequenceFile (htsjdk.samtools.reference.IndexedFastaSequenceFile)9 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)7 SAMFileHeader (htsjdk.samtools.SAMFileHeader)6 SAMSequenceDictionary (htsjdk.samtools.SAMSequenceDictionary)6 ArrayList (java.util.ArrayList)6 List (java.util.List)3 ArgumentsBuilder (org.broadinstitute.hellbender.utils.test.ArgumentsBuilder)3 Assert (org.testng.Assert)3 SamReader (htsjdk.samtools.SamReader)2 VariantContext (htsjdk.variant.variantcontext.VariantContext)2 VCFFileReader (htsjdk.variant.vcf.VCFFileReader)2 Iterator (java.util.Iterator)2 Argument (org.broadinstitute.barclay.argparser.Argument)2 CommandLineProgramProperties (org.broadinstitute.barclay.argparser.CommandLineProgramProperties)2