-
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
Refactor two VariantEval methods to allow subclasses to override #5998
Conversation
FWIW, @cmnbroad is who I worked with on the earlier VariantEval changes. |
Codecov Report
@@ Coverage Diff @@
## master #5998 +/- ##
===============================================
- Coverage 86.929% 79.945% -6.984%
+ Complexity 32765 30984 -1781
===============================================
Files 2016 2016
Lines 151460 151466 +6
Branches 16628 16628
===============================================
- Hits 131663 121090 -10573
- Misses 13732 24549 +10817
+ Partials 6065 5827 -238
|
c382256
to
8bc60eb
Compare
I restarted the travis build since the one failure seems to be an unrelated transient issue. |
c9936e1
to
a4c2910
Compare
OK, thanks. I tried to keep edits here limited and protected. I'm happy to describe more about what I'm trying to do in VariantQC if that's helpful. Also - i have not forgotten about trying to refactor VariantQC to better handle arguments (i.e. dont pass the walker to the VariantEvaluator, and to separate a VariantEvalEngine class, somewhat like VariantAnnotationEngine. |
@bbimber Yes, it might help if could elaborate a bit on what you're trying to do. Specifically I'd like to find an alternative to |
@cmnbroad : if getStratifierClasses() is the only sticking point, we can drop that. Stepping back: as you probably know we have a tool, VariantQC, which basically sets up a number of instances of VariantEval and uses them to aggregate data as it iterates a VCF. this allows the tool to capture data aggregated/stratified at multiple levels with one pass through the VCF. There are two related aims:
|
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.
A few simple requests.
stratManager.set(i, ec); | ||
} | ||
} | ||
|
||
protected EvaluationContext getEvaluationContext(final Set<Class<? extends VariantEvaluator>> evaluationObjects) { |
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.
Maybe this would be better named createEvaluationContext
, and add javadoc describing what implementers should do, i.e. that it should always create a new instance (unless there is some compelling reason to be more permissive?).
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.
ok
@@ -11,6 +11,10 @@ | |||
private VariantEval walker; | |||
private final String simpleName; | |||
|
|||
protected VariantEvaluator(String simpleName) { | |||
this.simpleName = simpleName; | |||
} |
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.
The other constructor (below) should delegate to this one now: this(getClass().getSimpleName())
, and this should have javadoc.
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.
good point, but getClass() cant be called before the supertype constructor is called? is there a way around that?
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 think it should be fine.
private final ArrayList<VariantEvaluator> evaluationInstances; | ||
private final Set<Class<? extends VariantEvaluator>> evaluationClasses; | ||
protected final List<VariantEvaluator> evaluationInstances; | ||
protected final Set<Class<? extends VariantEvaluator>> evaluationClasses; |
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.
Lets keep these private and add protected getEvaluationClasses
and getEvaluationInstances
methods to return them, with javadoc that includes stating that the return values can be null.
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.
ok. is there a reason GATK doesnt use @nullable more?
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.
ok, i got it now, disregard the question about @nullable here. nonetheless, that annotation does seem under-used across GATK
@@ -26,7 +27,7 @@ public EvaluationContext(final VariantEval walker, final Set<Class<? extends Var | |||
private EvaluationContext(final VariantEval walker, final Set<Class<? extends VariantEvaluator>> evaluationClasses, final boolean doInitialize) { | |||
this.walker = walker; | |||
this.evaluationClasses = evaluationClasses; | |||
this.evaluationInstances = new ArrayList<VariantEvaluator>(evaluationClasses.size()); | |||
this.evaluationInstances = new ArrayList<>(evaluationClasses.size()); |
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.
Thanks.
* | ||
* @return An unmodifiable map of all VariantStratifier classes | ||
*/ | ||
public static Map<String, Class<? extends VariantStratifier>> getStratifierClasses() { |
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.
Since this isn't required, lets remove it. To answer your question, I would generally avoid handing out internal structures like this, especially Maps, since its not clear from the types what it contains. There are several alternative ways to do this, and I know this code already does similar things all over the place (extreme example being bindVariantContexts), but lets not expose any more if we can avoid it. As you mentioned, the refactoring is the right way to address it - I think that would be a fair amount of work, but if we want to continue to make changes to this code it will probably be necessary.
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.
ok
@cmnbroad thanks for the quick review - i just pushed those changes. |
Restarting tests... |
@cmnbroad are these codecov results an actual problem or something incorrect in how it's running? |
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 wouldn't worry about the code cov diffs.
* @param evaluationObjects | ||
* @return | ||
*/ | ||
protected EvaluationContext createEvaluationContext(final Set<Class<? extends VariantEvaluator>> evaluationObjects) { |
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.
Its pro forma, but please add descriptions of the param and return.
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.
ok
@@ -11,6 +11,10 @@ | |||
private VariantEval walker; | |||
private final String simpleName; | |||
|
|||
protected VariantEvaluator(String simpleName) { | |||
this.simpleName = simpleName; | |||
} |
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 think it should be fine.
public Set<Class<? extends VariantEvaluator>> getEvaluationClasses() { | ||
return evaluationClasses; | ||
} | ||
|
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.
Fill out @return
.
f5ccb87
to
fb3421a
Compare
@cmnbroad OK, that's added. commits also squashed |
Thanks @bbimber. |
We have a tool, VariantQC, that extends VariantEval. This PR is a minor refactor to expose the code that creates the list of VariantStratifier and VariantEvaluator objects as protected methods, so subclasses could modify them. This should have no functional difference on VariantEval itself. We're hoping to use these changes in order to adapt our tool in response to reviewers, so if there is any way to push these changes we would appreciate it.