Search in sources :

Example 21 with CommandLineArgumentParser

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

the class ReadFilterPluginUnitTest method testEnableNonExistentFilter.

@Test(expectedExceptions = CommandLineException.class)
public void testEnableNonExistentFilter() {
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(null)));
    clp.parseArguments(nullMessageStream, new String[] { "--RF", "fakeFilter" });
}
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 CommandLineArgumentParser

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

the class ReadFilterPluginUnitTest method testDisableDefaultsAndReenableWithDifferentArgs.

@Test
public void testDisableDefaultsAndReenableWithDifferentArgs() {
    GATKReadFilterPluginDescriptor rfDesc = new GATKReadFilterPluginDescriptor(Collections.singletonList(new ReadLengthReadFilter(1, 10)));
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(rfDesc));
    clp.parseArguments(nullMessageStream, new String[] { "--disableToolDefaultReadFilters", "--readFilter", ReadLengthReadFilter.class.getSimpleName(), "--maxReadLength", "13" });
    List<ReadFilter> allFilters = rfDesc.getAllInstances();
    ReadLengthReadFilter rf = (ReadLengthReadFilter) allFilters.get(0);
    Assert.assertEquals(rf.maxReadLength.intValue(), 13);
}
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 CommandLineArgumentParser

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

the class ReadFilterPluginUnitTest method testPreserveToolDefaultFilterOrder.

@Test
public void testPreserveToolDefaultFilterOrder() {
    List<ReadFilter> orderedDefaults = new ArrayList<>();
    orderedDefaults.add(new WellformedReadFilter());
    orderedDefaults.add(ReadFilterLibrary.MAPPED);
    orderedDefaults.add(ReadFilterLibrary.HAS_READ_GROUP);
    orderedDefaults.add(ReadFilterLibrary.MAPPING_QUALITY_NOT_ZERO);
    orderedDefaults.add(ReadFilterLibrary.PAIRED);
    orderedDefaults.add(ReadFilterLibrary.NONZERO_FRAGMENT_LENGTH_READ_FILTER);
    orderedDefaults.add(ReadFilterLibrary.FIRST_OF_PAIR);
    orderedDefaults.add(ReadFilterLibrary.PROPERLY_PAIRED);
    orderedDefaults.add(ReadFilterLibrary.NOT_DUPLICATE);
    orderedDefaults.add(ReadFilterLibrary.NOT_SECONDARY_ALIGNMENT);
    orderedDefaults.add(ReadFilterLibrary.NOT_SUPPLEMENTARY_ALIGNMENT);
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(orderedDefaults)));
    clp.parseArguments(nullMessageStream, new String[] { //disable one just to mix things up
    "-disableReadFilter", ReadFilterLibrary.MAPPED.getClass().getSimpleName(), "-readFilter", ReadFilterLibrary.HAS_MATCHING_BASES_AND_QUALS.getClass().getSimpleName(), "-readFilter", 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 reach inside the filter and navigate 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.PAIRED.getClass().getSimpleName(), ReadFilterLibrary.NONZERO_FRAGMENT_LENGTH_READ_FILTER.getClass().getSimpleName(), ReadFilterLibrary.FIRST_OF_PAIR.getClass().getSimpleName(), ReadFilterLibrary.PROPERLY_PAIRED.getClass().getSimpleName(), ReadFilterLibrary.NOT_DUPLICATE.getClass().getSimpleName(), ReadFilterLibrary.NOT_SECONDARY_ALIGNMENT.getClass().getSimpleName(), ReadFilterLibrary.NOT_SUPPLEMENTARY_ALIGNMENT.getClass().getSimpleName(), ReadFilterLibrary.HAS_MATCHING_BASES_AND_QUALS.getClass().getSimpleName(), ReadFilterLibrary.GOOD_CIGAR.getClass().getSimpleName() };
    int count = ReadFilterUnitTest.verifyAndFilterOrder(rf, expectedOrder);
    Assert.assertEquals(count, 12);
}
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 24 with CommandLineArgumentParser

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

the class ReadFilterPluginUnitTest method testDisableOneFilter.

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

use of org.broadinstitute.barclay.argparser.CommandLineArgumentParser 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)

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