Fixed double-counting bug. Fixed issue where evaluation module with an update2() method wasn't getting called if the comp track was null. Added a column to the output report indicating the table name for easy greppability. Fixed an issue where, if sample-level stratification was not required, the sample-level VCs would be generated anyway.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5000 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
af1bce3492
commit
73acfa654a
|
|
@ -88,7 +88,6 @@ public class NewVariantEvalWalker extends RodWalker<Integer, Integer> implements
|
|||
|
||||
// The list of stratifiers and evaluators to use
|
||||
private TreeSet<VariantStratifier> stratificationObjects = null;
|
||||
private Set<Class<? extends VariantEvaluator>> evaluationObjects = null;
|
||||
|
||||
// The set of all possible evaluation contexts
|
||||
private HashMap<StateKey, NewEvaluationContext> evaluationContexts = null;
|
||||
|
|
@ -106,14 +105,14 @@ public class NewVariantEvalWalker extends RodWalker<Integer, Integer> implements
|
|||
List<Class<? extends VariantStratifier>> vsClasses = new PluginManager<VariantStratifier>( VariantStratifier.class ).getPlugins();
|
||||
List<Class<? extends VariantEvaluator>> veClasses = new PluginManager<VariantEvaluator>( VariantEvaluator.class ).getPlugins();
|
||||
|
||||
logger.info("Available stratifcation modules:");
|
||||
logger.info("Available stratification modules:");
|
||||
logger.info("(Standard modules are starred)");
|
||||
for (Class<? extends VariantStratifier> vsClass : vsClasses) {
|
||||
logger.info("\t" + vsClass.getSimpleName() + (RequiredStratification.class.isAssignableFrom(vsClass) || StandardStratification.class.isAssignableFrom(vsClass) ? "*" : ""));
|
||||
}
|
||||
logger.info("");
|
||||
|
||||
logger.info("Available eval modules:");
|
||||
logger.info("Available evaluation modules:");
|
||||
logger.info("(Standard modules are starred)");
|
||||
for (Class<? extends VariantEvaluator> veClass : veClasses) {
|
||||
logger.info("\t" + veClass.getSimpleName() + (StandardEval.class.isAssignableFrom(veClass) ? "*" : ""));
|
||||
|
|
@ -123,6 +122,13 @@ public class NewVariantEvalWalker extends RodWalker<Integer, Integer> implements
|
|||
System.exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize required, standard and user-specified stratification objects
|
||||
*
|
||||
* @param noStandardStrats don't use the standard stratifications
|
||||
* @param modulesToUse the list of stratification modules to use
|
||||
* @return set of stratifications to use
|
||||
*/
|
||||
private TreeSet<VariantStratifier> initializeStratificationObjects(boolean noStandardStrats, String[] modulesToUse) {
|
||||
TreeSet<VariantStratifier> strats = new TreeSet<VariantStratifier>();
|
||||
Set<String> stratsToUse = new HashSet<String>();
|
||||
|
|
@ -177,6 +183,13 @@ public class NewVariantEvalWalker extends RodWalker<Integer, Integer> implements
|
|||
return strats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize required, standard and user-specified evaluation objects
|
||||
*
|
||||
* @param noStandardEvals don't use the standard evaluations
|
||||
* @param modulesToUse the list of evaluation modules to use
|
||||
* @return set of evaluations to use
|
||||
*/
|
||||
private Set<Class<? extends VariantEvaluator>> initializeEvaluationObjects(boolean noStandardEvals, String[] modulesToUse) {
|
||||
Set<Class<? extends VariantEvaluator>> evals = new HashSet<Class<? extends VariantEvaluator>>();
|
||||
|
||||
|
|
@ -209,6 +222,15 @@ public class NewVariantEvalWalker extends RodWalker<Integer, Integer> implements
|
|||
return evals;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively initialize the evaluation contexts
|
||||
*
|
||||
* @param stratificationObjects the stratifications to use
|
||||
* @param evaluationObjects the evaluations to use
|
||||
* @param stratStack a stack of stratifications to apply
|
||||
* @param ec evaluation context
|
||||
* @return a map of all the evaluation contexts
|
||||
*/
|
||||
private 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>();
|
||||
|
||||
|
|
@ -253,6 +275,13 @@ public class NewVariantEvalWalker extends RodWalker<Integer, Integer> implements
|
|||
return ecs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the output report
|
||||
*
|
||||
* @param stratificationObjects the stratifications to use
|
||||
* @param evaluationObjects the evaluations to use
|
||||
* @return an initialized report object
|
||||
*/
|
||||
private GATKReport initializeGATKReport(Set<VariantStratifier> stratificationObjects, Set<Class<? extends VariantEvaluator>> evaluationObjects) {
|
||||
GATKReport report = new GATKReport();
|
||||
|
||||
|
|
@ -264,13 +293,11 @@ public class NewVariantEvalWalker extends RodWalker<Integer, Integer> implements
|
|||
|
||||
GATKReportTable table = report.getTable(tableName);
|
||||
table.addPrimaryKey("entry", false);
|
||||
table.addColumn(tableName, tableName);
|
||||
|
||||
for ( VariantStratifier vs : stratificationObjects ) {
|
||||
String columnName = vs.getClass().getSimpleName();
|
||||
|
||||
columnName = columnName.replace("Stratifier", "");
|
||||
columnName = columnName.replace("Status", "");
|
||||
|
||||
table.addColumn(columnName, "unknown");
|
||||
}
|
||||
|
||||
|
|
@ -285,6 +312,9 @@ public class NewVariantEvalWalker extends RodWalker<Integer, Integer> implements
|
|||
return report;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the stratifications, evaluations, evaluation contexts, and reporting object
|
||||
*/
|
||||
public void initialize() {
|
||||
// Just list the modules, and exit quickly.
|
||||
if (LIST) { listModulesAndExit(); }
|
||||
|
|
@ -306,14 +336,19 @@ public class NewVariantEvalWalker extends RodWalker<Integer, Integer> implements
|
|||
// Now that we have all the rods categorized, determine the sample list from the eval rods.
|
||||
Map<String, VCFHeader> vcfRods = VCFUtils.getVCFHeadersFromRods(getToolkit(), evalNames);
|
||||
Set<String> vcfSamples = SampleUtils.getSampleList(vcfRods, VariantContextUtils.GenotypeMergeType.REQUIRE_UNIQUE);
|
||||
sampleNames.addAll(SampleUtils.getSamplesFromCommandLineInput(vcfSamples, SAMPLE_EXPRESSIONS));
|
||||
sampleNames.add(ALL_SAMPLE_NAME);
|
||||
|
||||
// If we're not using the per-sample stratification, don't bother loading the sample list
|
||||
if (Arrays.asList(STRATIFICATIONS_TO_USE).contains("Sample")) {
|
||||
sampleNames.addAll(SampleUtils.getSamplesFromCommandLineInput(vcfSamples, SAMPLE_EXPRESSIONS));
|
||||
}
|
||||
|
||||
// Initialize select expressions
|
||||
jexlExpressions.addAll(VariantContextUtils.initializeMatchExps(SELECT_NAMES, SELECT_EXPS));
|
||||
|
||||
// Initialize the set of stratifications and evaluations to use
|
||||
stratificationObjects = initializeStratificationObjects(NO_STANDARD_STRATIFICATIONS, STRATIFICATIONS_TO_USE);
|
||||
evaluationObjects = initializeEvaluationObjects(NO_STANDARD_MODULES, MODULES_TO_USE);
|
||||
Set<Class<? extends VariantEvaluator>> evaluationObjects = initializeEvaluationObjects(NO_STANDARD_MODULES, MODULES_TO_USE);
|
||||
|
||||
// Initialize the evaluation contexts
|
||||
evaluationContexts = initializeEvaluationContexts(stratificationObjects, evaluationObjects, null, null);
|
||||
|
|
@ -322,15 +357,26 @@ public class NewVariantEvalWalker extends RodWalker<Integer, Integer> implements
|
|||
report = initializeGATKReport(stratificationObjects, evaluationObjects);
|
||||
}
|
||||
|
||||
/**
|
||||
* Figure out what the allowable variation types are based on the eval context
|
||||
*
|
||||
* @param tracker the reference metadata tracker
|
||||
* @param ref the reference context
|
||||
* @param evalNames the evaluation track names
|
||||
* @return the set of allowable variation types
|
||||
*/
|
||||
private EnumSet<VariantContext.Type> getAllowableVariationTypes(RefMetaDataTracker tracker, ReferenceContext ref, Set<String> evalNames) {
|
||||
EnumSet<VariantContext.Type> allowableTypes = EnumSet.of(VariantContext.Type.NO_VARIATION);
|
||||
|
||||
Collection<VariantContext> vcs = tracker.getVariantContexts(ref, evalNames, null, ref.getLocus(), true, false);
|
||||
if (tracker != null) {
|
||||
Collection<VariantContext> vcs = tracker.getVariantContexts(ref, evalNames, null, ref.getLocus(), true, false);
|
||||
|
||||
for ( VariantContext vc : vcs ) {
|
||||
allowableTypes.add(vc.getType());
|
||||
for ( VariantContext vc : vcs ) {
|
||||
allowableTypes.add(vc.getType());
|
||||
}
|
||||
} else {
|
||||
allowableTypes.add(VariantContext.Type.SNP);
|
||||
}
|
||||
|
||||
return allowableTypes;
|
||||
}
|
||||
|
||||
|
|
@ -350,9 +396,9 @@ public class NewVariantEvalWalker extends RodWalker<Integer, Integer> implements
|
|||
HashMap<String, HashMap<String, VariantContext>> bindings = new HashMap<String, HashMap<String, VariantContext>>();
|
||||
|
||||
for ( String trackName : trackNames ) {
|
||||
Collection<VariantContext> contexts = tracker.getVariantContexts(ref, trackName, allowableTypes, ref.getLocus(), true, true);
|
||||
Collection<VariantContext> contexts = tracker == null ? null : tracker.getVariantContexts(ref, trackName, allowableTypes, ref.getLocus(), true, true);
|
||||
|
||||
VariantContext vc = contexts.size() == 1 ? contexts.iterator().next() : null;
|
||||
VariantContext vc = contexts != null && contexts.size() == 1 ? contexts.iterator().next() : null;
|
||||
|
||||
HashMap<String, VariantContext> vcs = new HashMap<String, VariantContext>();
|
||||
|
||||
|
|
@ -400,14 +446,22 @@ public class NewVariantEvalWalker extends RodWalker<Integer, Integer> implements
|
|||
EnumSet<VariantContext.Type> allowableTypes = getAllowableVariationTypes(tracker, ref, evalNames);
|
||||
|
||||
HashMap<String, HashMap<String, VariantContext>> compBindings = bindVariantContexts(tracker, ref, compNames, allSamplesList, allowableTypes);
|
||||
HashMap<String, HashMap<String, VariantContext>> evalBindings = bindVariantContexts(tracker, ref, evalNames, sampleNames, allowableTypes);
|
||||
|
||||
//HashMap<String, HashMap<String, VariantContext>> evalBindings;
|
||||
//if (stratificationObjects.contains(SampleStratifier) {
|
||||
// evalBindings = bindVariantContexts(tracker, ref, evalNames, sampleNames, allowableTypes);
|
||||
//} else {
|
||||
// evalBindings = bindVariantContexts(tracker, ref, evalNames, allSamplesList, allowableTypes);
|
||||
//}
|
||||
HashMap<String, HashMap<String, VariantContext>> evalBindings;
|
||||
|
||||
boolean perSampleIsEnabled = false;
|
||||
for (VariantStratifier vs : stratificationObjects) {
|
||||
if (vs.getClass().getSimpleName().equals("Sample")) {
|
||||
perSampleIsEnabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (perSampleIsEnabled) {
|
||||
evalBindings = bindVariantContexts(tracker, ref, evalNames, sampleNames, allowableTypes);
|
||||
} else {
|
||||
evalBindings = bindVariantContexts(tracker, ref, evalNames, allSamplesList, allowableTypes);
|
||||
}
|
||||
|
||||
vcs.putAll(compBindings);
|
||||
vcs.putAll(evalBindings);
|
||||
|
|
@ -415,9 +469,16 @@ public class NewVariantEvalWalker extends RodWalker<Integer, Integer> implements
|
|||
return vcs;
|
||||
}
|
||||
|
||||
private ArrayList<StateKey> initializeStateKeys(HashMap<VariantStratifier, ArrayList<String>> stateMap, Stack<HashMap<VariantStratifier, ArrayList<String>>> stateStack, StateKey stateKey) {
|
||||
ArrayList<StateKey> stateKeys = new ArrayList<StateKey>();
|
||||
|
||||
/**
|
||||
* Recursively initialize the state keys used to look up the right evaluation context based on the state of the variant context
|
||||
*
|
||||
* @param stateMap the map of allowable states
|
||||
* @param stateStack a stack of the states
|
||||
* @param stateKey a state key object
|
||||
* @param stateKeys all the state keys
|
||||
* @return a list of state keys
|
||||
*/
|
||||
private ArrayList<StateKey> initializeStateKeys(HashMap<VariantStratifier, ArrayList<String>> stateMap, Stack<HashMap<VariantStratifier, ArrayList<String>>> stateStack, StateKey stateKey, ArrayList<StateKey> stateKeys) {
|
||||
if (stateStack == null) {
|
||||
stateStack = new Stack<HashMap<VariantStratifier, ArrayList<String>>>();
|
||||
|
||||
|
|
@ -433,60 +494,62 @@ public class NewVariantEvalWalker extends RodWalker<Integer, Integer> implements
|
|||
Stack<HashMap<VariantStratifier, ArrayList<String>>> newStateStack = new Stack<HashMap<VariantStratifier, ArrayList<String>>>();
|
||||
newStateStack.addAll(stateStack);
|
||||
|
||||
StateKey newStateKey = new StateKey();
|
||||
if (stateKey != null) {
|
||||
newStateKey.putAll(stateKey);
|
||||
}
|
||||
|
||||
HashMap<VariantStratifier, ArrayList<String>> oneSetOfStates = newStateStack.pop();
|
||||
VariantStratifier vs = oneSetOfStates.keySet().iterator().next();
|
||||
|
||||
for ( String state : oneSetOfStates.get(vs)) {
|
||||
StateKey newStateKey = new StateKey();
|
||||
if (stateKey != null) {
|
||||
newStateKey.putAll(stateKey);
|
||||
}
|
||||
|
||||
newStateKey.put(vs.getClass().getSimpleName(), state);
|
||||
|
||||
stateKeys.addAll(initializeStateKeys(stateMap, newStateStack, newStateKey));
|
||||
initializeStateKeys(stateMap, newStateStack, newStateKey, stateKeys);
|
||||
}
|
||||
} else {
|
||||
ArrayList<StateKey> newStateKeys = new ArrayList<StateKey>();
|
||||
stateKeys.add(stateKey);
|
||||
|
||||
newStateKeys.add(stateKey);
|
||||
|
||||
return newStateKeys;
|
||||
return stateKeys;
|
||||
}
|
||||
|
||||
return stateKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect relevant information from each variant in the supplied VCFs
|
||||
*/
|
||||
@Override
|
||||
public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||
if (tracker != null) {
|
||||
// track sample vc
|
||||
HashMap<String, HashMap<String, VariantContext>> vcs = getVariantContexts(tracker, ref, compNames, evalNames, sampleNames);
|
||||
for ( NewEvaluationContext nec : evaluationContexts.values() ) {
|
||||
nec.update0(tracker, ref, context);
|
||||
}
|
||||
|
||||
for ( String compName : compNames ) {
|
||||
VariantContext comp = vcs.containsKey(compName) && vcs.get(compName) != null && vcs.get(compName).containsKey(ALL_SAMPLE_NAME) ? vcs.get(compName).get(ALL_SAMPLE_NAME) : null;
|
||||
// track sample vc
|
||||
HashMap<String, HashMap<String, VariantContext>> vcs = getVariantContexts(tracker, ref, compNames, evalNames, sampleNames);
|
||||
|
||||
for ( String evalName : evalNames ) {
|
||||
for ( String sampleName : sampleNames ) {
|
||||
VariantContext eval = vcs.get(evalName) == null ? null : vcs.get(evalName).get(sampleName);
|
||||
for ( String compName : compNames ) {
|
||||
VariantContext comp = vcs.containsKey(compName) && vcs.get(compName) != null && vcs.get(compName).containsKey(ALL_SAMPLE_NAME) ? vcs.get(compName).get(ALL_SAMPLE_NAME) : null;
|
||||
|
||||
HashMap<VariantStratifier, ArrayList<String>> stateMap = new HashMap<VariantStratifier, ArrayList<String>>();
|
||||
for ( VariantStratifier vs : stratificationObjects ) {
|
||||
ArrayList<String> states = vs.getRelevantStates(ref, comp, eval, sampleName);
|
||||
stateMap.put(vs, states);
|
||||
}
|
||||
for ( String evalName : evalNames ) {
|
||||
for ( String sampleName : sampleNames ) {
|
||||
VariantContext eval = vcs.containsKey(evalName) && vcs.get(evalName) != null ? vcs.get(evalName).get(sampleName) : null;
|
||||
|
||||
ArrayList<StateKey> stateKeys = initializeStateKeys(stateMap, null, null);
|
||||
HashMap<VariantStratifier, ArrayList<String>> stateMap = new HashMap<VariantStratifier, ArrayList<String>>();
|
||||
for ( VariantStratifier vs : stratificationObjects ) {
|
||||
ArrayList<String> states = vs.getRelevantStates(ref, comp, compName, eval, sampleName);
|
||||
stateMap.put(vs, states);
|
||||
}
|
||||
|
||||
for ( StateKey stateKey : stateKeys ) {
|
||||
NewEvaluationContext nec = evaluationContexts.get(stateKey);
|
||||
ArrayList<StateKey> stateKeys = new ArrayList<StateKey>();
|
||||
initializeStateKeys(stateMap, null, null, stateKeys);
|
||||
|
||||
nec.apply(tracker, ref, context, comp, eval);
|
||||
}
|
||||
HashSet<StateKey> stateKeysHash = new HashSet<StateKey>(stateKeys);
|
||||
|
||||
//logger.info(ref.getLocus());
|
||||
//logger.info("\tcomp: " + comp);
|
||||
//logger.info("\teval: " + eval);
|
||||
for ( StateKey stateKey : stateKeysHash ) {
|
||||
NewEvaluationContext nec = evaluationContexts.get(stateKey);
|
||||
|
||||
nec.apply(tracker, ref, context, comp, eval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -528,6 +591,11 @@ public class NewVariantEvalWalker extends RodWalker<Integer, Integer> implements
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the finalized report
|
||||
*
|
||||
* @param result an integer that doesn't get used for anything
|
||||
*/
|
||||
public void onTraversalDone(Integer result) {
|
||||
for ( StateKey stateKey : evaluationContexts.keySet() ) {
|
||||
NewEvaluationContext nec = evaluationContexts.get(stateKey);
|
||||
|
|
@ -543,9 +611,6 @@ public class NewVariantEvalWalker extends RodWalker<Integer, Integer> implements
|
|||
for ( VariantStratifier vs : stratificationObjects ) {
|
||||
String columnName = vs.getClass().getSimpleName();
|
||||
|
||||
columnName = columnName.replace("Stratifier", "");
|
||||
columnName = columnName.replace("Status", "");
|
||||
|
||||
table.set(stateKey.toString(), columnName, stateKey.get(vs.getClass().getSimpleName()));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,54 +16,54 @@ public class CountVariants extends VariantEvaluator implements StandardEval {
|
|||
|
||||
// basic counts on various rates found
|
||||
@DataPoint(description = "Number of processed loci")
|
||||
long nProcessedLoci = 0;
|
||||
public long nProcessedLoci = 0;
|
||||
@DataPoint(description = "Number of called loci")
|
||||
long nCalledLoci = 0;
|
||||
public long nCalledLoci = 0;
|
||||
@DataPoint(description = "Number of reference loci")
|
||||
long nRefLoci = 0;
|
||||
public long nRefLoci = 0;
|
||||
@DataPoint(description = "Number of variant loci")
|
||||
long nVariantLoci = 0;
|
||||
public long nVariantLoci = 0;
|
||||
|
||||
// the following two calculations get set in the finalizeEvaluation
|
||||
@DataPoint(description = "Variants per loci rate")
|
||||
double variantRate = 0;
|
||||
public double variantRate = 0;
|
||||
@DataPoint(description = "Number of variants per base")
|
||||
double variantRatePerBp = 0;
|
||||
public double variantRatePerBp = 0;
|
||||
|
||||
|
||||
@DataPoint(description = "Number of snp loci")
|
||||
long nSNPs = 0;
|
||||
public long nSNPs = 0;
|
||||
@DataPoint(description = "Number of insertions")
|
||||
long nInsertions = 0;
|
||||
public long nInsertions = 0;
|
||||
@DataPoint(description = "Number of deletions")
|
||||
long nDeletions = 0;
|
||||
public long nDeletions = 0;
|
||||
@DataPoint(description = "Number of complex loci")
|
||||
long nComplex = 0;
|
||||
public long nComplex = 0;
|
||||
|
||||
@DataPoint(description = "Number of no calls loci")
|
||||
long nNoCalls = 0;
|
||||
public long nNoCalls = 0;
|
||||
@DataPoint(description = "Number of het loci")
|
||||
long nHets = 0;
|
||||
public long nHets = 0;
|
||||
@DataPoint(description = "Number of hom ref loci")
|
||||
long nHomRef = 0;
|
||||
public long nHomRef = 0;
|
||||
@DataPoint(description = "Number of hom var loci")
|
||||
long nHomVar = 0;
|
||||
public long nHomVar = 0;
|
||||
@DataPoint(description = "Number of singletons")
|
||||
long nSingletons = 0;
|
||||
public long nSingletons = 0;
|
||||
|
||||
// calculations that get set in the finalizeEvaluation method
|
||||
@DataPoint(description = "heterozygosity per locus rate")
|
||||
double heterozygosity = 0;
|
||||
public double heterozygosity = 0;
|
||||
@DataPoint(description = "heterozygosity per base pair")
|
||||
double heterozygosityPerBp = 0;
|
||||
public double heterozygosityPerBp = 0;
|
||||
@DataPoint(description = "heterozygosity to homozygosity ratio")
|
||||
double hetHomRatio = 0;
|
||||
public double hetHomRatio = 0;
|
||||
@DataPoint(description = "indel rate (insertion count + deletion count)")
|
||||
double indelRate = 0;
|
||||
public double indelRate = 0;
|
||||
@DataPoint(description = "indel rate per base pair")
|
||||
double indelRatePerBp = 0;
|
||||
public double indelRatePerBp = 0;
|
||||
@DataPoint(description = "deletion to insertion ratio")
|
||||
double deletionInsertionRatio = 0;
|
||||
public double deletionInsertionRatio = 0;
|
||||
|
||||
private double perLocusRate(long n) {
|
||||
return rate(n, nProcessedLoci);
|
||||
|
|
@ -86,7 +86,6 @@ public class CountVariants extends VariantEvaluator implements StandardEval {
|
|||
}
|
||||
|
||||
public String update1(VariantContext vc1, RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||
//nProcessedLoci++;
|
||||
nCalledLoci++;
|
||||
|
||||
if (vc1.isVariant()) nVariantLoci++;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils
|
|||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
public class CompRodStratifier extends VariantStratifier implements RequiredStratification {
|
||||
public class CompRod extends VariantStratifier implements RequiredStratification {
|
||||
// Needs to know the comp rods
|
||||
private Set<String> compNames;
|
||||
private ArrayList<String> states;
|
||||
|
|
@ -17,17 +17,17 @@ public class CompRodStratifier extends VariantStratifier implements RequiredStra
|
|||
this.compNames = compNames;
|
||||
|
||||
states = new ArrayList<String>();
|
||||
states.add("comp");
|
||||
states.addAll(compNames);
|
||||
}
|
||||
|
||||
public ArrayList<String> getAllStates() {
|
||||
return states;
|
||||
}
|
||||
|
||||
public ArrayList<String> getRelevantStates(ReferenceContext ref, VariantContext comp, VariantContext eval, String sampleName) {
|
||||
public ArrayList<String> getRelevantStates(ReferenceContext ref, VariantContext comp, String compName, VariantContext eval, String sampleName) {
|
||||
ArrayList<String> relevantStates = new ArrayList<String>();
|
||||
|
||||
relevantStates.add("comp");
|
||||
relevantStates.add(compName);
|
||||
|
||||
return relevantStates;
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils
|
|||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
public class CpGStatusStratifier extends VariantStratifier {
|
||||
public class CpG extends VariantStratifier {
|
||||
private ArrayList<String> states;
|
||||
|
||||
@Override
|
||||
|
|
@ -22,7 +22,7 @@ public class CpGStatusStratifier extends VariantStratifier {
|
|||
return states;
|
||||
}
|
||||
|
||||
public ArrayList<String> getRelevantStates(ReferenceContext ref, VariantContext comp, VariantContext eval, String sampleName) {
|
||||
public ArrayList<String> getRelevantStates(ReferenceContext ref, VariantContext comp, String compName, VariantContext eval, String sampleName) {
|
||||
boolean isCpG = false;
|
||||
if (ref != null && ref.getBases() != null) {
|
||||
String fwRefBases = new String(ref.getBases());
|
||||
|
|
@ -7,7 +7,7 @@ import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils
|
|||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
public class EvalRodStratifier extends VariantStratifier implements RequiredStratification {
|
||||
public class EvalRod extends VariantStratifier implements RequiredStratification {
|
||||
// needs to know the eval rods
|
||||
private Set<String> evalNames;
|
||||
private ArrayList<String> states;
|
||||
|
|
@ -24,7 +24,7 @@ public class EvalRodStratifier extends VariantStratifier implements RequiredStra
|
|||
return states;
|
||||
}
|
||||
|
||||
public ArrayList<String> getRelevantStates(ReferenceContext ref, VariantContext comp, VariantContext eval, String sampleName) {
|
||||
public ArrayList<String> getRelevantStates(ReferenceContext ref, VariantContext comp, String compName, VariantContext eval, String sampleName) {
|
||||
ArrayList<String> relevantStates = new ArrayList<String>();
|
||||
|
||||
relevantStates.add("eval");
|
||||
|
|
@ -7,7 +7,7 @@ import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils
|
|||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
public class FilterStatusStratifier extends VariantStratifier implements StandardStratification {
|
||||
public class Filter extends VariantStratifier implements StandardStratification {
|
||||
// needs to know the variant context
|
||||
private ArrayList<String> states;
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ public class FilterStatusStratifier extends VariantStratifier implements Standar
|
|||
return states;
|
||||
}
|
||||
|
||||
public ArrayList<String> getRelevantStates(ReferenceContext ref, VariantContext comp, VariantContext eval, String sampleName) {
|
||||
public ArrayList<String> getRelevantStates(ReferenceContext ref, VariantContext comp, String compName, VariantContext eval, String sampleName) {
|
||||
ArrayList<String> relevantStates = new ArrayList<String>();
|
||||
|
||||
relevantStates.add("raw");
|
||||
|
|
@ -7,7 +7,7 @@ import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils
|
|||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
public class FunctionalClassStratifier extends VariantStratifier {
|
||||
public class FunctionalClass extends VariantStratifier {
|
||||
// needs to know the variant context
|
||||
private ArrayList<String> states;
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ public class FunctionalClassStratifier extends VariantStratifier {
|
|||
return states;
|
||||
}
|
||||
|
||||
public ArrayList<String> getRelevantStates(ReferenceContext ref, VariantContext comp, VariantContext eval, String sampleName) {
|
||||
public ArrayList<String> getRelevantStates(ReferenceContext ref, VariantContext comp, String compName, VariantContext eval, String sampleName) {
|
||||
ArrayList<String> relevantStates = new ArrayList<String>();
|
||||
|
||||
relevantStates.add("all");
|
||||
|
|
@ -7,7 +7,7 @@ import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils
|
|||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
public class JexlExpressionStratifier extends VariantStratifier implements StandardStratification {
|
||||
public class JexlExpression extends VariantStratifier implements StandardStratification {
|
||||
// needs to know the jexl expressions
|
||||
private Set<VariantContextUtils.JexlVCMatchExp> jexlExpressions;
|
||||
private ArrayList<String> states;
|
||||
|
|
@ -27,7 +27,7 @@ public class JexlExpressionStratifier extends VariantStratifier implements Stand
|
|||
return states;
|
||||
}
|
||||
|
||||
public ArrayList<String> getRelevantStates(ReferenceContext ref, VariantContext comp, VariantContext eval, String sampleName) {
|
||||
public ArrayList<String> getRelevantStates(ReferenceContext ref, VariantContext comp, String compName, VariantContext eval, String sampleName) {
|
||||
ArrayList<String> relevantStates = new ArrayList<String>();
|
||||
relevantStates.add("none");
|
||||
|
||||
|
|
@ -7,7 +7,7 @@ import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils
|
|||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
public class NoveltyStatusStratifier extends VariantStratifier implements StandardStratification {
|
||||
public class Novelty extends VariantStratifier implements StandardStratification {
|
||||
// needs the variant contexts and known names
|
||||
private Set<String> knownNames;
|
||||
private ArrayList<String> states;
|
||||
|
|
@ -26,7 +26,7 @@ public class NoveltyStatusStratifier extends VariantStratifier implements Standa
|
|||
return states;
|
||||
}
|
||||
|
||||
public ArrayList<String> getRelevantStates(ReferenceContext ref, VariantContext comp, VariantContext eval, String sampleName) {
|
||||
public ArrayList<String> getRelevantStates(ReferenceContext ref, VariantContext comp, String compName, VariantContext eval, String sampleName) {
|
||||
ArrayList<String> relevantStates = new ArrayList<String>();
|
||||
|
||||
relevantStates.add("all");
|
||||
|
|
@ -8,7 +8,7 @@ import org.broadinstitute.sting.playground.gatk.walkers.newvarianteval.NewVarian
|
|||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
public class SampleStratifier extends VariantStratifier {
|
||||
public class Sample extends VariantStratifier {
|
||||
// needs the sample names
|
||||
private ArrayList<String> samples;
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ public class SampleStratifier extends VariantStratifier {
|
|||
return samples;
|
||||
}
|
||||
|
||||
public ArrayList<String> getRelevantStates(ReferenceContext ref, VariantContext comp, VariantContext eval, String sampleName) {
|
||||
public ArrayList<String> getRelevantStates(ReferenceContext ref, VariantContext comp, String compName, VariantContext eval, String sampleName) {
|
||||
ArrayList<String> relevantStates = new ArrayList<String>();
|
||||
relevantStates.add(sampleName);
|
||||
|
||||
|
|
@ -15,11 +15,7 @@ public abstract class VariantStratifier implements Comparable {
|
|||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
public boolean isApplicable(RefMetaDataTracker tracker, ReferenceContext ref, VariantContext comp, VariantContext eval, String state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ArrayList<String> getRelevantStates(ReferenceContext ref, VariantContext comp, VariantContext eval, String sampleName) {
|
||||
public ArrayList<String> getRelevantStates(ReferenceContext ref, VariantContext comp, String compName, VariantContext eval, String sampleName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,96 +0,0 @@
|
|||
//package org.broadinstitute.sting.playground.gatk.walkers.varianteval.util;
|
||||
//
|
||||
//import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils;
|
||||
//import org.broadinstitute.sting.playground.gatk.walkers.newvarianteval.VariantEvalWalker;
|
||||
//import org.broadinstitute.sting.playground.gatk.walkers.newvarianteval.evaluators.VariantEvaluator;
|
||||
//import org.broadinstitute.sting.utils.Utils;
|
||||
//import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
|
||||
//
|
||||
//import java.lang.reflect.Constructor;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.HashSet;
|
||||
//import java.util.Set;
|
||||
//
|
||||
///**
|
||||
// * Created by IntelliJ IDEA.
|
||||
// * User: kiran
|
||||
// * Date: Dec 14, 2010
|
||||
// * Time: 11:15:32 PM
|
||||
// * To change this template use File | Settings | File Templates.
|
||||
// */
|
||||
//public class EvaluationContext implements Comparable<EvaluationContext> {
|
||||
// // useful for typing
|
||||
// public String evalTrackName, compTrackName, novelty, filtered, cpgStatus, functionalClass, sample;
|
||||
// public boolean enableInterestingSiteCaptures = false;
|
||||
// public VariantContextUtils.JexlVCMatchExp selectExp;
|
||||
// public Set<VariantEvaluator> evaluations;
|
||||
//
|
||||
// private Set<Class<? extends VariantEvaluator>> evaluationClasses;
|
||||
//
|
||||
// private static String RAW_SET_NAME = "raw";
|
||||
// private static String RETAINED_SET_NAME = "called";
|
||||
// private static String FILTERED_SET_NAME = "filtered";
|
||||
// private static String ALL_SET_NAME = "all";
|
||||
// private static String KNOWN_SET_NAME = "known";
|
||||
// private static String NOVEL_SET_NAME = "novel";
|
||||
// private final static String CONTEXT_SEPARATOR = "XXX";
|
||||
//
|
||||
// public boolean isIgnoringFilters() { return filtered.equals(RAW_SET_NAME); }
|
||||
// public boolean requiresFiltered() { return filtered.equals(FILTERED_SET_NAME); }
|
||||
// public boolean requiresNotFiltered() { return filtered.equals(RETAINED_SET_NAME); }
|
||||
// public boolean isIgnoringNovelty() { return novelty.equals(ALL_SET_NAME); }
|
||||
// public boolean requiresNovel() { return novelty.equals(NOVEL_SET_NAME); }
|
||||
// public boolean requiresKnown() { return novelty.equals(KNOWN_SET_NAME); }
|
||||
//
|
||||
// public boolean isSelected() { return selectExp == null; }
|
||||
//
|
||||
// public String getDisplayName() {
|
||||
// return getName(CONTEXT_SEPARATOR);
|
||||
// }
|
||||
//
|
||||
// public String getJexlName() {
|
||||
// return getName(".");
|
||||
// }
|
||||
//
|
||||
// private String getName(String separator) {
|
||||
// return Utils.join(separator, Arrays.asList(evalTrackName, compTrackName, selectExp == null ? "all" : selectExp.name, filtered, novelty, cpgStatus, functionalClass, sample));
|
||||
// }
|
||||
//
|
||||
// public String toString() { return getDisplayName(); }
|
||||
//
|
||||
// public int compareTo(EvaluationContext other) {
|
||||
// return this.getDisplayName().compareTo(other.getDisplayName());
|
||||
// }
|
||||
//
|
||||
// public EvaluationContext( String evalName, String compName, String novelty, String filtered, String cpgStatus, String functionalClass, String sample, VariantContextUtils.JexlVCMatchExp selectExp, Set<Class<? extends VariantEvaluator>> evaluationClasses ) {
|
||||
// this.evalTrackName = evalName;
|
||||
// this.compTrackName = compName;
|
||||
// this.novelty = novelty;
|
||||
// this.filtered = filtered;
|
||||
// this.selectExp = selectExp;
|
||||
// this.cpgStatus = cpgStatus;
|
||||
// this.functionalClass = functionalClass;
|
||||
// this.sample = sample;
|
||||
// this.enableInterestingSiteCaptures = selectExp == null;
|
||||
// this.evaluationClasses = evaluationClasses;
|
||||
// this.evaluations = instantiateEvalationsSet();
|
||||
// }
|
||||
//
|
||||
// private Set<VariantEvaluator> instantiateEvalationsSet() {
|
||||
// Set<VariantEvaluator> evals = new HashSet<VariantEvaluator>();
|
||||
// Object[] args = new Object[]{this};
|
||||
// Class<?>[] argTypes = new Class<?>[]{VariantEvalWalker.class};
|
||||
//
|
||||
// for ( Class<? extends VariantEvaluator> c : evaluationClasses ) {
|
||||
// try {
|
||||
// Constructor<? extends VariantEvaluator> constructor = c.getConstructor(argTypes);
|
||||
// VariantEvaluator eval = constructor.newInstance(args);
|
||||
// evals.add(eval);
|
||||
// } catch (Exception e) {
|
||||
// throw new DynamicClassResolutionException(c, e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return evals;
|
||||
// }
|
||||
//}
|
||||
|
|
@ -14,7 +14,7 @@ import java.util.Set;
|
|||
import java.util.TreeMap;
|
||||
|
||||
public class NewEvaluationContext extends HashMap<VariantStratifier, String> {
|
||||
private TreeMap<String, VariantEvaluator> evaluationInstances;
|
||||
public TreeMap<String, VariantEvaluator> evaluationInstances;
|
||||
|
||||
public String toString() {
|
||||
String value = "";
|
||||
|
|
@ -47,32 +47,36 @@ public class NewEvaluationContext extends HashMap<VariantStratifier, String> {
|
|||
|
||||
public void apply(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context, VariantContext comp, VariantContext eval) {
|
||||
for ( VariantEvaluator evaluation : evaluationInstances.values() ) {
|
||||
if ( evaluation.enabled() ) {
|
||||
// we always call update0 in case the evaluation tracks things like number of bases covered
|
||||
evaluation.update0(tracker, ref, context);
|
||||
// we always call update0 in case the evaluation tracks things like number of bases covered
|
||||
//evaluation.update0(tracker, ref, context);
|
||||
|
||||
// the other updateN methods don't see a null context
|
||||
if ( tracker == null )
|
||||
continue;
|
||||
// the other updateN methods don't see a null context
|
||||
if ( tracker == null )
|
||||
continue;
|
||||
|
||||
// now call the single or paired update function
|
||||
switch ( evaluation.getComparisonOrder() ) {
|
||||
case 1:
|
||||
if (eval != null) {
|
||||
evaluation.update1(eval, tracker, ref, context);
|
||||
}
|
||||
// now call the single or paired update function
|
||||
switch ( evaluation.getComparisonOrder() ) {
|
||||
case 1:
|
||||
if (eval != null) {
|
||||
evaluation.update1(eval, tracker, ref, context);
|
||||
}
|
||||
|
||||
break;
|
||||
case 2:
|
||||
if (eval != null && comp != null) {
|
||||
evaluation.update2(eval, comp, tracker, ref, context);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (eval != null) {
|
||||
evaluation.update2(eval, comp, tracker, ref, context);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new ReviewedStingException("BUG: Unexpected evaluation order " + evaluation);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new ReviewedStingException("BUG: Unexpected evaluation order " + evaluation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void update0(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||
for ( VariantEvaluator evaluation : evaluationInstances.values() ) {
|
||||
evaluation.update0(tracker, ref, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ public class StateKey extends TreeMap<String, String> {
|
|||
String value = "";
|
||||
|
||||
for ( String key : this.keySet() ) {
|
||||
value += "\tstate " + key + ":" + this.get(key) + "\n";
|
||||
//value += "\tstate " + key + ":" + this.get(key) + "\n";
|
||||
value += String.format("%s:%s;", key, this.get(key));
|
||||
}
|
||||
|
||||
return value;
|
||||
|
|
|
|||
Loading…
Reference in New Issue