-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added --inverted-read-filter argument to allow for selecting reads failing read filters from the command line easily #8724
Changes from all commits
715074b
12b68e8
7618b91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
|
||
import javax.validation.constraints.AssertTrue; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.PrintStream; | ||
|
@@ -538,6 +539,44 @@ public void testEnableDisableConflict() { | |
"--" + ReadFilterArgumentDefinitions.DISABLE_READ_FILTER_LONG_NAME, "GoodCigarReadFilter"}); | ||
} | ||
|
||
@Test | ||
public void testDisableToolDefaultFiltersWithInvertedFilter() { | ||
GATKReadFilterPluginDescriptor rfDesc = new GATKReadFilterPluginDescriptor( | ||
Collections.singletonList(new ReadLengthReadFilter(1, 10))); | ||
CommandLineParser clp = new CommandLineArgumentParser( | ||
new Object(), | ||
Collections.singletonList(rfDesc), | ||
Collections.emptySet()); | ||
clp.parseArguments(nullMessageStream, new String[] { | ||
"--" + ReadFilterArgumentDefinitions.DISABLE_TOOL_DEFAULT_READ_FILTERS, | ||
"--" + ReadFilterArgumentDefinitions.INVERTED_READ_FILTER_LONG_NAME, ReadLengthReadFilter.class.getSimpleName()} | ||
); | ||
List<ReadFilter> allFilters = rfDesc.getResolvedInstances(); | ||
Assert.assertEquals(allFilters.size(), 1); | ||
Assert.assertEquals(allFilters.get(0).getClass(), ReadFilter.ReadFilterNegate.class); | ||
} | ||
|
||
@Test(expectedExceptions = CommandLineException.class) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might either add a new more specific exception type or scrape the message. It's really easy to tests like this failing for other reasons like typos and not the one you expect. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idk... commandline is a very specfic exception and i'm not super inclined to split the exception up into dozens of hyper specific commandline exceptions. Furthermore.... if you look up in the class this is already all over the place in these tests. No action There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm in favor of hyper specific exceptions all over the place but that's fine. Did you check that it's actually erroring for the reasons you expect? I says this from experience constructing commandline tests that turned out to be typos and not valid tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not 100% sure, but I think there are issues with inverted and disabled read filters. You should be allowed to Could you add tests for those cases? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will add a test for A, B is very thorny... i'm going to say thats an edge case and not handle it as it is a whole lot more complicated for a very niche case (if you want to invert a default filter you must construct your own filter list) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, that seems fine. I doubt we'll ever have someone complain. |
||
public void testEnableInvertConflict() { | ||
CommandLineParser clp = new CommandLineArgumentParser( | ||
new Object(), | ||
Collections.singletonList(new GATKReadFilterPluginDescriptor(null)), | ||
Collections.emptySet()); | ||
clp.parseArguments(nullMessageStream, new String[] { | ||
"--RF", "GoodCigarReadFilter", | ||
"--" + ReadFilterArgumentDefinitions.INVERTED_READ_FILTER_LONG_NAME, "GoodCigarReadFilter"}); | ||
} | ||
|
||
@Test(expectedExceptions = CommandLineException.class) | ||
public void testInvertToolDefaultConflict() { | ||
CommandLineParser clp = new CommandLineArgumentParser( | ||
new Object(), | ||
Collections.singletonList(new GATKReadFilterPluginDescriptor(List.of(new ReadFilterLibrary.GoodCigarReadFilter()))), | ||
Collections.emptySet()); | ||
clp.parseArguments(nullMessageStream, new String[] { | ||
"--" + ReadFilterArgumentDefinitions.INVERTED_READ_FILTER_LONG_NAME, "GoodCigarReadFilter"}); | ||
} | ||
|
||
@Test | ||
public void testPreserveCommandLineOrder() { | ||
List<ReadFilter> orderedDefaults = new ArrayList<>(); | ||
|
@@ -665,6 +704,32 @@ public void testReadLengthFilter() { | |
Assert.assertTrue(rf.test(read)); | ||
} | ||
|
||
@Test | ||
public void testInvertReadLengthFilter() { | ||
final SAMFileHeader header = createHeaderWithReadGroups(); | ||
final GATKRead read = simpleGoodRead(header); | ||
|
||
CommandLineParser clp = new CommandLineArgumentParser( | ||
new Object(), | ||
Collections.singletonList(new GATKReadFilterPluginDescriptor(null)), | ||
Collections.emptySet()); | ||
String[] args = { | ||
"--" + ReadFilterArgumentDefinitions.INVERTED_READ_FILTER_LONG_NAME, ReadLengthReadFilter.class.getSimpleName(), | ||
"--" + ReadFilterArgumentDefinitions.MIN_READ_LENGTH_ARG_NAME, "10", | ||
"--" + ReadFilterArgumentDefinitions.MAX_READ_LENGTH_ARG_NAME, "20" | ||
}; | ||
clp.parseArguments(nullMessageStream, args); | ||
ReadFilter rf = instantiateFilter(clp, header); | ||
|
||
read.setBases(new byte[5]); | ||
Assert.assertTrue(rf.test(read)); | ||
read.setBases(new byte[25]); | ||
Assert.assertTrue(rf.test(read)); | ||
|
||
read.setBases(new byte[15]); | ||
Assert.assertFalse(rf.test(read)); | ||
} | ||
|
||
final private static String readgroupName = "ReadGroup1"; | ||
|
||
@DataProvider(name="testDefaultFilters") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I thought you were going to implement special handling of
not
in the read filter name which sounded complicated. This is much clearer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered it but when we add a read filter named Not___ReadFilter i really didn't want to deal with NotNot___ReadFilters cropping up...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does mean that you can't interleave the inverted filters with regular filters in any arbitrary order however...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could potentially allow
!ReadFilter
because!
shouldn't be allowed in read filter names, but yeah, it would be more complicated I think.