Skip to content

Commit

Permalink
Simplify override
Browse files Browse the repository at this point in the history
  • Loading branch information
bbimber authored and bbimber committed Jun 14, 2019
1 parent 8e1f238 commit c9936e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
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 List<VariantEvaluator> evaluationInstances;
private final Set<Class<? extends VariantEvaluator>> evaluationClasses;
protected final List<VariantEvaluator> evaluationInstances;
protected final Set<Class<? extends VariantEvaluator>> evaluationClasses;

public EvaluationContext(final VariantEval walker, final Set<Class<? extends VariantEvaluator>> evaluationClasses) {
this(walker, evaluationClasses, true);
Expand All @@ -27,24 +27,19 @@ 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 = initializeEvaluationInstances(doInitialize);
}
this.evaluationInstances = new ArrayList<>(evaluationClasses.size());

protected List<VariantEvaluator> initializeEvaluationInstances(boolean doInitialize) {
List<VariantEvaluator> ret = new ArrayList<>(evaluationClasses.size());
for ( final Class<? extends VariantEvaluator> c : evaluationClasses ) {
try {
final VariantEvaluator eval = c.newInstance();
if ( doInitialize ) eval.initialize(walker);
ret.add(eval);
evaluationInstances.add(eval);
} catch (InstantiationException e) {
throw new GATKException("Unable to instantiate eval module '" + c.getSimpleName() + "'", e);
} catch (IllegalAccessException e) {
throw new GATKException("Illegal access error when trying to instantiate eval module '" + c.getSimpleName() + "'", e);
}
}

return ret;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,13 @@ private void addMapping(HashMap<String, Collection<VariantContext>> mappings, St
mappings.put(sample, new ArrayList<>(1));
mappings.get(sample).add(vc);
}

/**
* Returns a map of all detected VariantStratifier classes
*
* @return An unmodifiable map of all VariantStratifier classes
*/
public static Map<String, Class<? extends VariantStratifier>> getStratifierClasses() {
return Collections.unmodifiableMap(stratifierClasses);
}
}

0 comments on commit c9936e1

Please sign in to comment.