Search in sources :

Example 16 with CommandLineArgumentParser

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

the class ReadFilterPluginUnitTest method testToolHasDefaultRequiredArgsNegative.

@Test(expectedExceptions = CommandLineException.MissingArgument.class)
public void testToolHasDefaultRequiredArgsNegative() {
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(Collections.singletonList(new ReadGroupReadFilter()))));
    // ReadGroupReadFilter has a required "keepReadGroup" arg; don't provide it and fail
    String[] args = {};
    clp.parseArguments(nullMessageStream, args);
}
Also used : GATKReadFilterPluginDescriptor(org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor) CommandLineArgumentParser(org.broadinstitute.barclay.argparser.CommandLineArgumentParser) CommandLineParser(org.broadinstitute.barclay.argparser.CommandLineParser) Test(org.testng.annotations.Test)

Example 17 with CommandLineArgumentParser

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

the class ReadFilterPluginUnitTest method testToolHasDefaultRequiredArgsPositive.

@Test(dataProvider = "testDefaultFilters")
public void testToolHasDefaultRequiredArgsPositive(final String[] args) {
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(Collections.singletonList(new ReadGroupReadFilter()))));
    clp.parseArguments(nullMessageStream, args);
    SAMFileHeader samHeader = createHeaderWithReadGroups();
    ReadFilter rf = instantiateFilter(clp, samHeader);
    final GATKRead read = simpleGoodRead(samHeader);
    // make sure the test read actually has this read group
    Assert.assertEquals(read.getReadGroup(), readgroupName);
    Assert.assertTrue(rf.test(read));
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) GATKReadFilterPluginDescriptor(org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor) CommandLineArgumentParser(org.broadinstitute.barclay.argparser.CommandLineArgumentParser) CommandLineParser(org.broadinstitute.barclay.argparser.CommandLineParser) SAMFileHeader(htsjdk.samtools.SAMFileHeader) Test(org.testng.annotations.Test)

Example 18 with CommandLineArgumentParser

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

the class ReadFilterPluginUnitTest method testEnableDisableConflict.

@Test(expectedExceptions = CommandLineException.class)
public void testEnableDisableConflict() {
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(null)));
    clp.parseArguments(nullMessageStream, new String[] { "--RF", "GoodCigarReadFilter", "--disableReadFilter", "GoodCigarReadFilter" });
}
Also used : GATKReadFilterPluginDescriptor(org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor) CommandLineArgumentParser(org.broadinstitute.barclay.argparser.CommandLineArgumentParser) CommandLineParser(org.broadinstitute.barclay.argparser.CommandLineParser) Test(org.testng.annotations.Test)

Example 19 with CommandLineArgumentParser

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

the class VariantWalkerIntegrationTest method testBestSequenceDictionary_FromVariantReference.

@Test
public void testBestSequenceDictionary_FromVariantReference() throws Exception {
    final GATKTool tool = new TestGATKToolWithFeatures();
    final CommandLineParser clp = new CommandLineArgumentParser(tool);
    final File vcfFile = new File(publicTestDir + "org/broadinstitute/hellbender/engine/example_variants_noSequenceDict.vcf");
    final String[] args = { "-V", vcfFile.getCanonicalPath(), "-R", hg19MiniReference };
    clp.parseArguments(System.out, args);
    tool.onStartup();
    // make sure we DON'T get the seq dictionary from the VCF index, and instead get the one from
    // the reference when its better
    final SAMSequenceDictionary toolDict = tool.getBestAvailableSequenceDictionary();
    Assert.assertFalse(toolDict.getSequences().stream().allMatch(seqRec -> seqRec.getSequenceLength() == 0));
    SAMSequenceDictionary refDict = new ReferenceFileSource(new File(hg19MiniReference)).getSequenceDictionary();
    toolDict.assertSameDictionary(refDict);
    refDict.assertSameDictionary(toolDict);
    Assert.assertEquals(toolDict, refDict);
}
Also used : CommandLineProgramProperties(org.broadinstitute.barclay.argparser.CommandLineProgramProperties) Iterator(java.util.Iterator) CommandLineArgumentParser(org.broadinstitute.barclay.argparser.CommandLineArgumentParser) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) Argument(org.broadinstitute.barclay.argparser.Argument) TestProgramGroup(org.broadinstitute.hellbender.cmdline.TestProgramGroup) ExampleVariantWalker(org.broadinstitute.hellbender.tools.examples.ExampleVariantWalker) CommandLineParser(org.broadinstitute.barclay.argparser.CommandLineParser) ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) Test(org.testng.annotations.Test) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest) File(java.io.File) ArrayList(java.util.ArrayList) List(java.util.List) UserException(org.broadinstitute.hellbender.exceptions.UserException) Assert(org.testng.Assert) VariantContext(htsjdk.variant.variantcontext.VariantContext) CommandLineArgumentParser(org.broadinstitute.barclay.argparser.CommandLineArgumentParser) CommandLineParser(org.broadinstitute.barclay.argparser.CommandLineParser) File(java.io.File) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 20 with CommandLineArgumentParser

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

the class ReadFilterPluginUnitTest method testDisableToolDefaultFilters.

@Test(dataProvider = "disableToolDefaulFiltersArguments")
public void testDisableToolDefaultFilters(final String[] args, final List<ReadFilter> defaultFilters, final ReadFilter expectedFilter) {
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(defaultFilters)));
    clp.parseArguments(nullMessageStream, args);
    GATKReadFilterPluginDescriptor readFilterPlugin = clp.getPluginDescriptor(GATKReadFilterPluginDescriptor.class);
    Assert.assertTrue(readFilterPlugin.userArgs.getDisableToolDefaultReadFilters());
    // no instances because no readFilter was provided
    List<ReadFilter> readFilters = readFilterPlugin.getAllInstances();
    Assert.assertEquals(readFilters.size(), (expectedFilter == null) ? 0 : 1);
    // all the default filters returns true for isDisabledFilter if it is not the expected
    defaultFilters.stream().map(df -> df.getClass().getSimpleName()).filter(df -> expectedFilter == null || expectedFilter.getClass().getSimpleName().equals(df)).forEach(df -> Assert.assertTrue(readFilterPlugin.isDisabledFilter(df.getClass().getSimpleName())));
    ReadFilter rf = instantiateFilter(clp, createHeaderWithReadGroups());
    Assert.assertEquals(rf.getClass().getSimpleName(), (expectedFilter == null) ? ReadFilterLibrary.ALLOW_ALL_READS.getClass().getSimpleName() : expectedFilter.getClass().getSimpleName());
}
Also used : TextCigarCodec(htsjdk.samtools.TextCigarCodec) PrintStream(java.io.PrintStream) Cigar(htsjdk.samtools.Cigar) Arrays(java.util.Arrays) DataProvider(org.testng.annotations.DataProvider) CommandLineArgumentParser(org.broadinstitute.barclay.argparser.CommandLineArgumentParser) CommandLineParser(org.broadinstitute.barclay.argparser.CommandLineParser) GATKReadFilterPluginDescriptor(org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor) Test(org.testng.annotations.Test) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) SAMFileHeader(htsjdk.samtools.SAMFileHeader) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) List(java.util.List) ArtificialReadUtils(org.broadinstitute.hellbender.utils.read.ArtificialReadUtils) Assert(org.testng.Assert) NullOutputStream(org.apache.commons.io.output.NullOutputStream) Collections(java.util.Collections) CommandLineException(org.broadinstitute.barclay.argparser.CommandLineException) GATKReadFilterPluginDescriptor(org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor) CommandLineArgumentParser(org.broadinstitute.barclay.argparser.CommandLineArgumentParser) CommandLineParser(org.broadinstitute.barclay.argparser.CommandLineParser) Test(org.testng.annotations.Test)

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