Fixes from Mark for the MutableContexts; this fixes the clearGenotypes() and the clearFilters() methods, and adds a method to clear the attributes. Also added is a method for creating a variant context where the attribute list is pruned to a specific subset, which can be null.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3955 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
72ae81c6de
commit
c68625f055
|
|
@ -213,6 +213,33 @@ public class VariantContextUtils {
|
||||||
return HardyWeinbergCalculation.hwCalculate(vc.getHomRefCount(), vc.getHetCount(), vc.getHomVarCount());
|
return HardyWeinbergCalculation.hwCalculate(vc.getHomRefCount(), vc.getHetCount(), vc.getHomVarCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static VariantContext pruneVariantContext(VariantContext vc) {
|
||||||
|
return pruneVariantContext(vc, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static VariantContext pruneVariantContext(VariantContext vc, Set<String> keysToPreserve ) {
|
||||||
|
MutableVariantContext mvc = new MutableVariantContext(vc);
|
||||||
|
|
||||||
|
if ( keysToPreserve == null || keysToPreserve.size() == 0 )
|
||||||
|
mvc.clearAttributes();
|
||||||
|
else {
|
||||||
|
Map<String, Object> d = mvc.getAttributes();
|
||||||
|
mvc.clearAttributes();
|
||||||
|
for ( String key : keysToPreserve )
|
||||||
|
mvc.putAttribute(key, d.get(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
Collection<Genotype> gs = mvc.getGenotypes().values();
|
||||||
|
mvc.clearGenotypes();
|
||||||
|
for ( Genotype g : gs ) {
|
||||||
|
MutableGenotype mg = new MutableGenotype(g);
|
||||||
|
mg.clearAttributes();
|
||||||
|
mvc.addGenotype(mg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mvc;
|
||||||
|
}
|
||||||
|
|
||||||
public enum GenotypeMergeType {
|
public enum GenotypeMergeType {
|
||||||
UNIQUIFY, PRIORITIZE, UNSORTED, REQUIRE_UNIQUE
|
UNIQUIFY, PRIORITIZE, UNSORTED, REQUIRE_UNIQUE
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue