-
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
Changes from all commits
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 |
---|---|---|
|
@@ -11,6 +11,10 @@ public abstract class VariantEvaluator implements Comparable<VariantEvaluator> { | |
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 commentThe reason will be displayed to describe this comment to others. Learn more. The other constructor (below) should delegate to this one now: 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. 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 commentThe reason will be displayed to describe this comment to others. Learn more. I think it should be fine. |
||
|
||
protected VariantEvaluator() { | ||
this.simpleName = getClass().getSimpleName(); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,13 +10,14 @@ | |
import org.broadinstitute.hellbender.tools.walkers.varianteval.stratifications.manager.StratificationManager; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.TreeSet; | ||
|
||
public final class EvaluationContext { | ||
public class EvaluationContext { | ||
// NOTE: must be hashset to avoid O(log n) cost of iteration in the very frequently called apply function | ||
final VariantEval walker; | ||
private final ArrayList<VariantEvaluator> evaluationInstances; | ||
private final List<VariantEvaluator> evaluationInstances; | ||
private final Set<Class<? extends VariantEvaluator>> evaluationClasses; | ||
|
||
public EvaluationContext(final VariantEval walker, final Set<Class<? extends VariantEvaluator>> evaluationClasses) { | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. |
||
|
||
for ( final Class<? extends VariantEvaluator> c : evaluationClasses ) { | ||
try { | ||
|
@@ -41,13 +42,31 @@ private EvaluationContext(final VariantEval walker, final Set<Class<? extends Va | |
} | ||
} | ||
|
||
/** | ||
* Return a list of instances of each VariantEvaluator (see getEvaluationClasses). Note: elements of this list can be null. | ||
* | ||
* @return The list of VariantEvaluator instances | ||
*/ | ||
public List<VariantEvaluator> getEvaluationInstances() { | ||
return evaluationInstances; | ||
} | ||
|
||
/** | ||
* Returns a set of VariantEvaluator classes to be used | ||
* | ||
* @return The set of VariantEvaluator classes to be used | ||
*/ | ||
public Set<Class<? extends VariantEvaluator>> getEvaluationClasses() { | ||
return evaluationClasses; | ||
} | ||
|
||
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. Fill out |
||
/** | ||
* Returns a sorted set of VariantEvaluators | ||
* | ||
* @return | ||
* @return A sorted set of VariantEvaluator instances | ||
*/ | ||
public final TreeSet<VariantEvaluator> getVariantEvaluators() { | ||
return new TreeSet<VariantEvaluator>(evaluationInstances); | ||
return new TreeSet<>(evaluationInstances); | ||
} | ||
|
||
public final void apply(ReferenceContext referenceContext, ReadsContext readsContext, FeatureContext featureContext, VariantContext comp, VariantContext eval) { | ||
|
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