Search in sources :

Example 21 with GATKReadFilterPluginDescriptor

use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.

the class ReadFilterPluginUnitTest method testDependentFilterArguments.

// fail if a filter with required arguments is specified without corresponding arguments
@Test(dataProvider = "filtersWithRequiredArguments", expectedExceptions = CommandLineException.MissingArgument.class)
public void testDependentFilterArguments(final String filter, //unused
final String argName, //unused
final String argValue) {
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(null)));
    String[] args = { // no args, just enable filters
    "--readFilter", // no args, just enable filters
    filter };
    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 22 with GATKReadFilterPluginDescriptor

use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.

the class ReadFilterPluginUnitTest method testGetAllowedValuesForDescriptorArgument.

@Test(dataProvider = "defaultFiltersForAllowedValues")
public void testGetAllowedValuesForDescriptorArgument(final List<ReadFilter> defaultFilters) {
    final CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(defaultFilters)));
    clp.parseArguments(nullMessageStream, new String[] {});
    final GATKReadFilterPluginDescriptor pluginDescriptor = clp.getPluginDescriptor(GATKReadFilterPluginDescriptor.class);
    // the help for disableReadFilter should point out to the default filters in the order provided
    Assert.assertEquals(pluginDescriptor.getAllowedValuesForDescriptorArgument("disableReadFilter"), defaultFilters.stream().map(rf -> rf.getClass().getSimpleName()).collect(Collectors.toSet()));
    // test if the help for readFilter is not empty after parsing: if custom validation throws, the help should print the readFilter available
    // the complete set could not checked because that requires to discover all the implemented filters
    Assert.assertFalse(pluginDescriptor.getAllowedValuesForDescriptorArgument("readFilter").isEmpty());
}
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 23 with GATKReadFilterPluginDescriptor

use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.

the class ReadFilterPluginUnitTest method testFilterArguments.

@Test(dataProvider = "filtersWithFilteringArguments")
public void testFilterArguments(final String filter, final Consumer<SetupTest> setup, final String argName, final String argValue) {
    final SAMFileHeader header = createHeaderWithReadGroups();
    final GATKRead read = simpleGoodRead(header);
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(null)));
    String[] args = { "--readFilter", filter, argName, argValue };
    clp.parseArguments(nullMessageStream, args);
    ReadFilter rf = instantiateFilter(clp, header);
    // to ensure that the filter is actually working, verify that the test record
    // we're using fails the filter test *before* we set it up to pass the filter
    Assert.assertFalse(rf.test(read));
    // setup the header and read for the test
    setup.accept(new SetupTest(header, read, argValue));
    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 24 with GATKReadFilterPluginDescriptor

use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.

the class ReadFilterPluginUnitTest method testNoFiltersSpecified.

@Test
public void testNoFiltersSpecified() {
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(null)));
    clp.parseArguments(nullMessageStream, new String[] {});
    // get the command line read filters
    final GATKReadFilterPluginDescriptor readFilterPlugin = clp.getPluginDescriptor(GATKReadFilterPluginDescriptor.class);
    final List<ReadFilter> readFilters = readFilterPlugin.getAllInstances();
    Assert.assertEquals(readFilters.size(), 0);
}
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 25 with GATKReadFilterPluginDescriptor

use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.

the class ReadFilterPluginUnitTest method testDisableNotEnabledFilter.

@Test
public void testDisableNotEnabledFilter() {
    GATKReadFilterPluginDescriptor rfDesc = new GATKReadFilterPluginDescriptor(null);
    final CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(rfDesc));
    final String filterName = ReadFilterLibrary.MAPPED.getClass().getSimpleName();
    clp.parseArguments(nullMessageStream, new String[] { "-disableReadFilter", filterName });
    // Make sure mapped filter got disabled with no exception
    Assert.assertTrue(rfDesc.userArgs.getUserDisabledReadFilterNames().contains(filterName));
    Assert.assertTrue(rfDesc.isDisabledFilter(filterName));
}
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)

Aggregations

CommandLineArgumentParser (org.broadinstitute.barclay.argparser.CommandLineArgumentParser)25 CommandLineParser (org.broadinstitute.barclay.argparser.CommandLineParser)25 GATKReadFilterPluginDescriptor (org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor)25 Test (org.testng.annotations.Test)25 SAMFileHeader (htsjdk.samtools.SAMFileHeader)5 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)5 ArrayList (java.util.ArrayList)4 Cigar (htsjdk.samtools.Cigar)1 TextCigarCodec (htsjdk.samtools.TextCigarCodec)1 PrintStream (java.io.PrintStream)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 NullOutputStream (org.apache.commons.io.output.NullOutputStream)1 CommandLineException (org.broadinstitute.barclay.argparser.CommandLineException)1 ArtificialReadUtils (org.broadinstitute.hellbender.utils.read.ArtificialReadUtils)1 Assert (org.testng.Assert)1 DataProvider (org.testng.annotations.DataProvider)1