From c7a8dffa89efe2d08530e46cb0f061f0a887bba9 Mon Sep 17 00:00:00 2001 From: ebanks Date: Thu, 7 Jan 2010 19:27:15 +0000 Subject: [PATCH] Check for division by 0 in annotations git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2539 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/gatk/walkers/annotator/QualByDepth.java | 5 ++++- .../sting/gatk/walkers/annotator/SpanningDeletions.java | 2 +- .../concordance/CallsetConcordanceIntegrationTest.java | 2 +- .../walkers/genotyper/UnifiedGenotyperIntegrationTest.java | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java index 629194964..04ccac374 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java @@ -24,8 +24,11 @@ public class QualByDepth extends StandardVariantAnnotation { return null; //double QbyD = genotypeQualByDepth(ref.getBase(), genotypes, stratifiedContexts); - double QbyD = 10.0 * variation.getNegLog10PError() / (double)variationQualByDepth(ref.getBase(), genotypes, stratifiedContexts); + int qDepth = variationQualByDepth(ref.getBase(), genotypes, stratifiedContexts); + if ( qDepth == 0 ) + return null; + double QbyD = 10.0 * variation.getNegLog10PError() / (double)qDepth; return String.format("%.2f", QbyD); } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java index 2faf52302..1348d3261 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java @@ -20,7 +20,7 @@ public class SpanningDeletions extends StandardVariantAnnotation { deletions += pileup.getNumberOfDeletions(); depth += pileup.size(); } - return String.format("%.2f", (double)deletions/(double)depth); + return String.format("%.2f", depth == 0 ? 0.0 : (double)deletions/(double)depth); } public String getKeyName() { return "Dels"; } diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/concordance/CallsetConcordanceIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/concordance/CallsetConcordanceIntegrationTest.java index 2e5ed1687..772687dce 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/concordance/CallsetConcordanceIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/concordance/CallsetConcordanceIntegrationTest.java @@ -46,7 +46,7 @@ public class CallsetConcordanceIntegrationTest extends WalkerTest { public void testComplex() { WalkerTestSpec spec = new WalkerTestSpec( baseTestString() + " -B set1,VCF," + validationDataLocation + "complexExample.vcf -B set2,VCF," + validationDataLocation + "complexExample.vcf -CT NWayVenn", 1, - Arrays.asList("8b72e557c0dd111738eaa69e9003fb3f")); + Arrays.asList("7bc72ec5f8b0fda5d59ebd2526b53e48")); executeTest("testComplex", spec); } } \ No newline at end of file diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java index d216ef53f..82c726c73 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java @@ -98,8 +98,8 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest { @Test public void testParameter() { HashMap e = new HashMap(); - e.put( "-genotype", "2a8b8d4da5ceed494e2210b15c2c3eb0" ); - e.put( "-all_bases", "69b20ce7fc18f78011ee02b48a8d69aa" ); + e.put( "-genotype", "b3161d019d467d5f9045d2f5d7203006" ); + e.put( "-all_bases", "655c7b8ce2f794a055fa49962b5a6a79" ); e.put( "--min_base_quality_score 26", "67175e0262e626d46aaf3bc8680cf888" ); e.put( "--min_mapping_quality_score 26", "8edb24206529a7a344008280ab69cbb2" ); e.put( "--max_mismatches_in_40bp_window 5", "870812ed23b2c656439dc1c8e6376f89" );