Search in sources :

Example 11 with CommandLineParser

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

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

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

Example 14 with CommandLineParser

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

the class ReadFilterPluginUnitTest method testDisabledDefaultWithArgsNotProvided.

@Test
public void testDisabledDefaultWithArgsNotProvided() {
    // test for disabling a default filter that has arguments, but they are not provided
    GATKReadFilterPluginDescriptor rfDesc = new GATKReadFilterPluginDescriptor(Collections.singletonList(new ReadLengthReadFilter(1, 10)));
    CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(rfDesc));
    final String filterName = ReadLengthReadFilter.class.getSimpleName();
    clp.parseArguments(nullMessageStream, new String[] { "-disableReadFilter", filterName });
    // Make sure ReadLengthReadFilter got disabled without an 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)

Example 15 with CommandLineParser

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

the class ReadFilterPluginUnitTest method tesDisableNonExistentReadFilter.

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