Skip to content

Commit

Permalink
Use configuration in VariantAnnotatorEngine too
Browse files Browse the repository at this point in the history
  • Loading branch information
magicDGS authored and lbergelson committed Jan 18, 2019
1 parent ede5aba commit f07cef9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package org.broadinstitute.hellbender.tools.walkers.annotator;

import com.google.common.collect.Sets;
import htsjdk.variant.variantcontext.*;
import htsjdk.variant.vcf.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.broadinstitute.hellbender.engine.*;
import org.broadinstitute.hellbender.engine.FeatureContext;
import org.broadinstitute.hellbender.engine.FeatureDataSource;
import org.broadinstitute.hellbender.engine.FeatureInput;
import org.broadinstitute.hellbender.engine.ReferenceContext;
import org.broadinstitute.hellbender.exceptions.GATKException;
import org.broadinstitute.hellbender.exceptions.UserException;
import org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.ReducibleAnnotation;
import org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.ReducibleAnnotationData;
import org.broadinstitute.hellbender.utils.ClassUtils;
import org.broadinstitute.hellbender.utils.Utils;
import org.broadinstitute.hellbender.utils.genotyper.ReadLikelihoods;
import org.broadinstitute.hellbender.utils.variant.GATKVariantContextUtils;
Expand Down
28 changes: 22 additions & 6 deletions src/main/java/org/broadinstitute/hellbender/utils/ClassUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,33 @@ public static <T> List<T> makeInstancesOfSubclasses(final Class<? extends T> cla
final List<T> results = new ArrayList<>(classes.size());

for (final Class<?> found: classes){
if (canMakeInstances(found)){
try {
results.add((T)found.newInstance());
} catch (InstantiationException | IllegalAccessException e) {
throw new GATKException("Problem making an instance of " + found + " Do check that the class has a non-arg constructor", e);
}
final T instance = (T) makeInstanceOf(found);
if (instance != null) {
results.add(instance);
}
}
return results;
}

/**
* Create objects of a concrete class.
*
* The public no-arg constructor is called to create the objects.
*
* @param clazz class to be instantiated
* @return new object or {@code null} if cannot be instantiated.
*/
public static <T> T makeInstanceOf(final Class<T> clazz) {
if (canMakeInstances(clazz)) {
try {
return clazz.newInstance();
} catch (final InstantiationException | IllegalAccessException e) {
throw new GATKException("Problem making an instance of " + clazz + " Do check that the class has a non-arg constructor", e);
}
}
return null;
}

/**
* Finds sub-interfaces of the given interface (in the same package) and returns their simple names.
*/
Expand Down

0 comments on commit f07cef9

Please sign in to comment.