Search in sources :

Example 26 with CommandLineArgumentParser

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

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

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

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

Example 30 with CommandLineArgumentParser

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

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