VariantEval optimization
-- Use a LinkedHashMap not a TreeMap so iteration is faster. -- Note that with a lot of stratifications the update0 is taking up a lot of time. For example, with 822 samples and functional class and sample on there are 100K contexts and 30% of the runtime is just in the update0 call
This commit is contained in:
parent
a0602e534c
commit
fee8d86f63
|
|
@ -326,7 +326,7 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> implements Tr
|
|||
*/
|
||||
@Override
|
||||
public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||
for ( NewEvaluationContext nec : evaluationContexts.values() ) {
|
||||
for ( final NewEvaluationContext nec : evaluationContexts.values() ) {
|
||||
synchronized (nec) {
|
||||
nec.update0(tracker, ref, context);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,29 +10,17 @@ import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
|||
import org.broadinstitute.sting.utils.exceptions.StingException;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.*;
|
||||
|
||||
public class NewEvaluationContext extends HashMap<VariantStratifier, String> {
|
||||
public TreeMap<String, VariantEvaluator> evaluationInstances;
|
||||
|
||||
public String toString() {
|
||||
String value = "";
|
||||
|
||||
for ( VariantStratifier key : this.keySet() ) {
|
||||
value += "\t" + key.getName() + ":" + this.get(key) + "\n";
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
private Map<String, VariantEvaluator> evaluationInstances;
|
||||
|
||||
public void addEvaluationClassList(VariantEvalWalker walker, StateKey stateKey, Set<Class<? extends VariantEvaluator>> evaluationClasses) {
|
||||
evaluationInstances = new TreeMap<String, VariantEvaluator>();
|
||||
evaluationInstances = new LinkedHashMap<String, VariantEvaluator>(evaluationClasses.size());
|
||||
|
||||
for ( Class<? extends VariantEvaluator> c : evaluationClasses ) {
|
||||
for ( final Class<? extends VariantEvaluator> c : evaluationClasses ) {
|
||||
try {
|
||||
VariantEvaluator eval = c.newInstance();
|
||||
final VariantEvaluator eval = c.newInstance();
|
||||
eval.initialize(walker);
|
||||
|
||||
if (eval.stateIsApplicable(stateKey)) {
|
||||
|
|
@ -47,11 +35,11 @@ public class NewEvaluationContext extends HashMap<VariantStratifier, String> {
|
|||
}
|
||||
|
||||
public TreeMap<String, VariantEvaluator> getEvaluationClassList() {
|
||||
return evaluationInstances;
|
||||
return new TreeMap<String, VariantEvaluator>(evaluationInstances);
|
||||
}
|
||||
|
||||
public void apply(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context, VariantContext comp, VariantContext eval) {
|
||||
for ( VariantEvaluator evaluation : evaluationInstances.values() ) {
|
||||
for ( final VariantEvaluator evaluation : evaluationInstances.values() ) {
|
||||
// we always call update0 in case the evaluation tracks things like number of bases covered
|
||||
|
||||
// the other updateN methods don't see a null context
|
||||
|
|
@ -79,7 +67,7 @@ public class NewEvaluationContext extends HashMap<VariantStratifier, String> {
|
|||
}
|
||||
|
||||
public void update0(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||
for ( VariantEvaluator evaluation : evaluationInstances.values() ) {
|
||||
for ( final VariantEvaluator evaluation : evaluationInstances.values() ) {
|
||||
evaluation.update0(tracker, ref, context);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ public class VariantEvalUtils {
|
|||
* @return a map of all the evaluation contexts
|
||||
*/
|
||||
public HashMap<StateKey, NewEvaluationContext> initializeEvaluationContexts(Set<VariantStratifier> stratificationObjects, Set<Class<? extends VariantEvaluator>> evaluationObjects, Stack<VariantStratifier> stratStack, NewEvaluationContext ec) {
|
||||
HashMap<StateKey, NewEvaluationContext> ecs = new HashMap<StateKey, NewEvaluationContext>();
|
||||
HashMap<StateKey, NewEvaluationContext> ecs = new LinkedHashMap<StateKey, NewEvaluationContext>();
|
||||
|
||||
if (stratStack == null) {
|
||||
stratStack = new Stack<VariantStratifier>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue