From 5113e21437b9a69f99bdea49fa80854d8ab090e7 Mon Sep 17 00:00:00 2001 From: Michael McCowan Date: Mon, 23 Sep 2013 14:26:24 -0400 Subject: [PATCH] Bug fix: annotation values ar parsed as Doubles when they should be parsed as Integers due to implicit conversion. * Updated expected test data in which an integer annotation (MQ0) was formatted as a double. --- .../variantutils/CombineVariantsIntegrationTest.java | 2 +- .../sting/utils/variant/GATKVariantContextUtils.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/protected/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsIntegrationTest.java b/protected/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsIntegrationTest.java index 66bc74caa..2eeb9221e 100644 --- a/protected/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsIntegrationTest.java +++ b/protected/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsIntegrationTest.java @@ -194,7 +194,7 @@ public class CombineVariantsIntegrationTest extends WalkerTest { " --excludeNonVariants -combineAnnotations -setKey null" + " -L 20:10,000,000-10,001,000", b37KGReference), 1, - Arrays.asList("2e15db35359144683f1e58e147362679")); + Arrays.asList("0413f0725fc5ec3a4f1ee246f6cb3a2a")); cvExecuteTest("combineSingleSamplePipelineGVCF", spec, true); } diff --git a/public/java/src/org/broadinstitute/sting/utils/variant/GATKVariantContextUtils.java b/public/java/src/org/broadinstitute/sting/utils/variant/GATKVariantContextUtils.java index e8c438a53..11cd27a9f 100644 --- a/public/java/src/org/broadinstitute/sting/utils/variant/GATKVariantContextUtils.java +++ b/public/java/src/org/broadinstitute/sting/utils/variant/GATKVariantContextUtils.java @@ -891,7 +891,11 @@ public class GATKVariantContextUtils { } try { final String stringValue = value.toString(); - values.add(stringValue.contains(".") ? Double.parseDouble(stringValue) : Integer.parseInt(stringValue)); + // Branch to avoid unintentional, implicit type conversions that occur with the ? operator. + if (stringValue.contains(".")) + values.add(Double.parseDouble(stringValue)); + else + values.add(Integer.parseInt(stringValue)); } catch (NumberFormatException e) { badAnnotation = true; }