Variant Context simple merging routine should keep ID if one of the VCs has it

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3718 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2010-07-05 01:10:15 +00:00
parent 3016e1cf80
commit e7220bc885
1 changed files with 6 additions and 1 deletions

View File

@ -198,6 +198,7 @@ public class VariantContextUtils {
double negLog10PError = -1;
Set<String> filters = new TreeSet<String>();
Map<String, Object> attributes = new TreeMap<String, Object>(first.getAttributes());
String rsID = null;
int depth = 0;
// filtering values
@ -228,7 +229,9 @@ public class VariantContextUtils {
filters.addAll(vc.getFilters());
if ( vc.hasAttribute(VCFRecord.DEPTH_KEY) )
depth += Integer.valueOf(vc.getAttribute(VCFRecord.DEPTH_KEY).toString());
depth += Integer.valueOf(vc.getAttributeAsString(VCFRecord.DEPTH_KEY));
if ( rsID == null && vc.hasAttribute("ID") )
rsID = vc.getAttributeAsString("ID");
}
// if at least one record was unfiltered and we want a union, clear all of the filters
@ -254,6 +257,8 @@ public class VariantContextUtils {
if ( depth > 0 )
attributes.put(VCFRecord.DEPTH_KEY, String.valueOf(depth));
if ( rsID != null )
attributes.put("ID", rsID);
VariantContext merged = new VariantContext(name, loc, alleles, genotypes, negLog10PError, filters, attributes);
if ( printMessages && remapped ) System.out.printf("Remapped => %s%n", merged);