Search in sources :

Example 1 with GATKReadFilterPluginDescriptor

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

the class ReadFilterPluginUnitTest method testDanglingFilterArguments.

// fail if a filter's arguments are passed but the filter itself is not enabled
@Test(dataProvider = "filtersWithRequiredArguments", expectedExceptions = CommandLineException.class)
public void testDanglingFilterArguments(final String filter, final String argName, final String argValue) {
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(null)));
    // no read filter set
    String[] args = { argName, argValue };
    // no need to instantiate the filters - dependency errors are caught by the command line parser
    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 2 with GATKReadFilterPluginDescriptor

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

the class ReadFilterPluginUnitTest method testPreserveCommandLineOrder.

@Test
public void testPreserveCommandLineOrder() {
    List<ReadFilter> orderedDefaults = new ArrayList<>();
    orderedDefaults.add(new WellformedReadFilter());
    orderedDefaults.add(ReadFilterLibrary.HAS_READ_GROUP);
    orderedDefaults.add(ReadFilterLibrary.MAPPING_QUALITY_NOT_ZERO);
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(orderedDefaults)));
    clp.parseArguments(nullMessageStream, new String[] { "-readFilter", ReadFilterLibrary.MAPPED.getClass().getSimpleName(), "-readFilter", ReadFilterLibrary.HAS_MATCHING_BASES_AND_QUALS.getClass().getSimpleName(), "-readFilter", ReadFilterLibrary.GOOD_CIGAR.getClass().getSimpleName() });
    GATKReadFilterPluginDescriptor readFilterPlugin = clp.getPluginDescriptor(GATKReadFilterPluginDescriptor.class);
    // get and verify the list of filters enabled on the command line (not including defaults)
    List<ReadFilter> orderedFilters = readFilterPlugin.getAllInstances();
    Assert.assertEquals(orderedFilters.size(), 3);
    Assert.assertEquals(orderedFilters.get(0).getClass().getSimpleName(), ReadFilterLibrary.MAPPED.getClass().getSimpleName());
    Assert.assertEquals(orderedFilters.get(1).getClass().getSimpleName(), ReadFilterLibrary.HAS_MATCHING_BASES_AND_QUALS.getClass().getSimpleName());
    Assert.assertEquals(orderedFilters.get(2).getClass().getSimpleName(), ReadFilterLibrary.GOOD_CIGAR.getClass().getSimpleName());
    // Now get the final merged read filter and verify the execution order. We need to ensure that
    // getMergedReadFilter creates a composite filter that honors the filter test execution
    // order rules (tool defaults first, in order, followed by command line-specified, in order
    // listed), so validate by reaching inside the filter and navigating down the tree.
    ReadFilter rf = instantiateFilter(clp, createHeaderWithReadGroups());
    String[] expectedOrder = { WellformedReadFilter.class.getSimpleName(), ReadFilterLibrary.HAS_READ_GROUP.getClass().getSimpleName(), ReadFilterLibrary.MAPPING_QUALITY_NOT_ZERO.getClass().getSimpleName(), ReadFilterLibrary.MAPPED.getClass().getSimpleName(), ReadFilterLibrary.HAS_MATCHING_BASES_AND_QUALS.getClass().getSimpleName(), ReadFilterLibrary.GOOD_CIGAR.getClass().getSimpleName() };
    int count = ReadFilterUnitTest.verifyAndFilterOrder(rf, expectedOrder);
    Assert.assertEquals(count, 6);
}
Also used : GATKReadFilterPluginDescriptor(org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor) CommandLineArgumentParser(org.broadinstitute.barclay.argparser.CommandLineArgumentParser) ArrayList(java.util.ArrayList) CommandLineParser(org.broadinstitute.barclay.argparser.CommandLineParser) Test(org.testng.annotations.Test)

Example 3 with GATKReadFilterPluginDescriptor

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

the class ReadFilterPluginUnitTest method testDisabledDefaultWithArgsProvided.

// Disabled due to https://github.com/broadinstitute/barclay/issues/23
// For now this will just generate a warning, but it should throw
@Test(expectedExceptions = CommandLineException.class, enabled = false)
public void testDisabledDefaultWithArgsProvided() {
    // test for arguments provided for a default filter that is also disabled
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(Collections.singletonList(new SampleReadFilter()))));
    clp.parseArguments(nullMessageStream, new String[] { "--sample", "fred", "-disableReadFilter", SampleReadFilter.class.getSimpleName() });
    // get the command line read filters
    clp.getPluginDescriptor(GATKReadFilterPluginDescriptor.class);
}
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 4 with GATKReadFilterPluginDescriptor

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

the class ReadFilterPluginUnitTest method testEnableDuplicateFilter.

@Test(dataProvider = "duplicateFilters", expectedExceptions = CommandLineException.BadArgumentValue.class)
public void testEnableDuplicateFilter(final String[] arguments) {
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(null)));
    clp.parseArguments(nullMessageStream, arguments);
}
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 5 with GATKReadFilterPluginDescriptor

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

the class ReadFilterPluginUnitTest method testReadLengthFilter.

@Test
public void testReadLengthFilter() {
    final SAMFileHeader header = createHeaderWithReadGroups();
    final GATKRead read = simpleGoodRead(header);
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(null)));
    String[] args = { "--readFilter", ReadLengthReadFilter.class.getSimpleName(), "--minReadLength", "10", "--maxReadLength", "20" };
    clp.parseArguments(nullMessageStream, args);
    ReadFilter rf = instantiateFilter(clp, header);
    read.setBases(new byte[5]);
    Assert.assertFalse(rf.test(read));
    read.setBases(new byte[25]);
    Assert.assertFalse(rf.test(read));
    read.setBases(new byte[15]);
    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)

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