Search in sources :

Example 16 with GATKReadFilterPluginDescriptor

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

the class ReadFilterPluginUnitTest method testDisableDefaultsAndReorderWithUserEnabledFirts.

@Test
public void testDisableDefaultsAndReorderWithUserEnabledFirts() {
    final ReadLengthReadFilter rlrf = new ReadLengthReadFilter(2, 10);
    GATKReadFilterPluginDescriptor rfDesc = new GATKReadFilterPluginDescriptor(Arrays.asList(rlrf, ReadFilterLibrary.MAPPED));
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(rfDesc));
    clp.parseArguments(nullMessageStream, new String[] { "--disableToolDefaultReadFilters", "--readFilter", ReadFilterLibrary.GOOD_CIGAR.getClass().getSimpleName(), "--readFilter", ReadFilterLibrary.MAPPED.getClass().getSimpleName(), "--readFilter", ReadLengthReadFilter.class.getSimpleName() });
    List<ReadFilter> allFilters = rfDesc.getAllInstances();
    // User filter is first according to the command line
    Assert.assertSame(allFilters.get(0).getClass(), ReadFilterLibrary.GOOD_CIGAR.getClass());
    // default filters are exactly the same object
    Assert.assertSame(allFilters.get(1), ReadFilterLibrary.MAPPED);
    ReadLengthReadFilter rf = (ReadLengthReadFilter) allFilters.get(2);
    Assert.assertSame(rf, rlrf);
    // and the state is the same as in the provided default
    Assert.assertEquals(rf.minReadLength, 2);
    Assert.assertEquals(rf.maxReadLength.intValue(), 10);
}
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 GATKReadFilterPluginDescriptor

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

the class ReadFilterPluginUnitTest method testDisabledNonDefaultFilterWithArgsProvided.

@Test(expectedExceptions = CommandLineException.class)
public void testDisabledNonDefaultFilterWithArgsProvided() {
    // test for arguments provided for a non-default filter that is also disabled
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(Collections.emptyList())));
    clp.parseArguments(nullMessageStream, new String[] { "--disableReadFilter", SampleReadFilter.class.getSimpleName(), "--sample", "fred" });
    // 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 18 with GATKReadFilterPluginDescriptor

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

the class ReadFilterPluginUnitTest method testDisableDuplicateFilter.

@Test(dataProvider = "duplicateDisabledFilters", expectedExceptions = CommandLineException.BadArgumentValue.class)
public void testDisableDuplicateFilter(final List<ReadFilter> defaults, final String[] arguments) {
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(defaults)));
    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 19 with GATKReadFilterPluginDescriptor

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

the class ReadFilterPluginUnitTest method testEnableMultipleFilters.

@Test
public void testEnableMultipleFilters() {
    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", "102", "--readFilter", ReadNameReadFilter.class.getSimpleName(), "--readName", "fred" };
    clp.parseArguments(nullMessageStream, args);
    ReadFilter rf = instantiateFilter(clp, header);
    // default read name is rejected by the readName filter
    Assert.assertFalse(rf.test(read));
    String readName = read.getName();
    read.setName("fred");
    // accepted
    Assert.assertTrue(rf.test(read));
    // trigger the read length filter to reject
    read.setBases(new byte[150]);
    Assert.assertFalse(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 20 with GATKReadFilterPluginDescriptor

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

the class ReadFilterPluginUnitTest method testDisableMultipleFilters.

@Test
public void testDisableMultipleFilters() {
    List<ReadFilter> defaultFilters = new ArrayList<>();
    defaultFilters.add(ReadFilterLibrary.GOOD_CIGAR);
    defaultFilters.add(ReadFilterLibrary.HAS_MATCHING_BASES_AND_QUALS);
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(defaultFilters)));
    clp.parseArguments(nullMessageStream, new String[] { "--RF", ReadFilterLibrary.MAPPED.getClass().getSimpleName(), "-disableReadFilter", ReadFilterLibrary.GOOD_CIGAR.getClass().getSimpleName(), "-disableReadFilter", ReadFilterLibrary.HAS_MATCHING_BASES_AND_QUALS.getClass().getSimpleName() });
    // get the command line read filters
    GATKReadFilterPluginDescriptor readFilterPlugin = clp.getPluginDescriptor(GATKReadFilterPluginDescriptor.class);
    List<ReadFilter> readFilters = readFilterPlugin.getAllInstances();
    Assert.assertEquals(readFilters.size(), 1);
    Assert.assertEquals(readFilters.get(0).getClass().getSimpleName(), ReadFilterLibrary.MAPPED.getClass().getSimpleName());
    Assert.assertEquals(readFilterPlugin.userArgs.getUserDisabledReadFilterNames().size(), 2);
    Assert.assertTrue(readFilterPlugin.userArgs.getUserDisabledReadFilterNames().contains(ReadFilterLibrary.GOOD_CIGAR.getClass().getSimpleName()));
    Assert.assertTrue(readFilterPlugin.userArgs.getUserDisabledReadFilterNames().contains(ReadFilterLibrary.HAS_MATCHING_BASES_AND_QUALS.getClass().getSimpleName()));
    ReadFilter rf = instantiateFilter(clp, createHeaderWithReadGroups());
    Assert.assertEquals(rf.getClass().getSimpleName(), ReadFilterLibrary.MAPPED.getClass().getSimpleName());
}
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)

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