quick bug fix for variant context utils: only calculate the max AC if we're using the mergeInfoWithMaxAC flag, and if so deal with sites that have multiple alternate alleles correctly.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5582 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
aaron 2011-04-06 05:36:52 +00:00
parent cc713f2769
commit ab5c4064ed
1 changed files with 22 additions and 7 deletions

View File

@ -489,18 +489,33 @@ public class VariantContextUtils {
//
// special case DP (add it up) and ID (just preserve it)
//
if ( vc.hasAttribute(VCFConstants.DEPTH_KEY) )
if (vc.hasAttribute(VCFConstants.DEPTH_KEY))
depth += Integer.valueOf(vc.getAttributeAsString(VCFConstants.DEPTH_KEY));
if ( rsID == null && vc.hasID() )
if (rsID == null && vc.hasID())
rsID = vc.getID();
if ( vc.hasAttribute(VCFConstants.ALLELE_COUNT_KEY) ) {
final int ac = Integer.valueOf(vc.getAttributeAsString(VCFConstants.ALLELE_COUNT_KEY));
if( ac > maxAC ) { maxAC = ac; maxACAttributes = vc.getAttributes(); }
if (mergeInfoWithMaxAC && vc.hasAttribute(VCFConstants.ALLELE_COUNT_KEY)) {
String rawAlleleCounts = vc.getAttributeAsString(VCFConstants.ALLELE_COUNT_KEY);
// lets see if the string contains a , separator
if (rawAlleleCounts.contains(VCFConstants.INFO_FIELD_ARRAY_SEPARATOR)) {
List<String> alleleCountArray = Arrays.asList(rawAlleleCounts.substring(1, rawAlleleCounts.length() - 1).split(VCFConstants.INFO_FIELD_ARRAY_SEPARATOR));
for (String alleleCount : alleleCountArray) {
final int ac = Integer.valueOf(alleleCount.trim());
if (ac > maxAC) {
maxAC = ac;
maxACAttributes = vc.getAttributes();
}
}
} else {
final int ac = Integer.valueOf(rawAlleleCounts);
if (ac > maxAC) {
maxAC = ac;
maxACAttributes = vc.getAttributes();
}
}
}
for ( Map.Entry<String, Object> p : vc.getAttributes().entrySet() ) {
for (Map.Entry<String, Object> p : vc.getAttributes().entrySet()) {
String key = p.getKey();
// if we don't like the key already, don't go anywhere
if ( ! inconsistentAttributes.contains(key) ) {
boolean alreadyFound = attributes.containsKey(key);