From e7220bc885a269907df2fd7ffdc549e43fade23b Mon Sep 17 00:00:00 2001 From: ebanks Date: Mon, 5 Jul 2010 01:10:15 +0000 Subject: [PATCH] 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 --- .../gatk/contexts/variantcontext/VariantContextUtils.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/java/src/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextUtils.java b/java/src/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextUtils.java index f4a261aa0..6e04d2585 100755 --- a/java/src/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextUtils.java +++ b/java/src/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextUtils.java @@ -198,6 +198,7 @@ public class VariantContextUtils { double negLog10PError = -1; Set filters = new TreeSet(); Map attributes = new TreeMap(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);