From ec774f62be0d7f0f29c07be3de8056877a7102c4 Mon Sep 17 00:00:00 2001 From: depristo Date: Wed, 6 Jan 2010 14:53:24 +0000 Subject: [PATCH] Some checking to protect the BasicGenotype git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2509 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/utils/genotype/BasicGenotype.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/java/src/org/broadinstitute/sting/utils/genotype/BasicGenotype.java b/java/src/org/broadinstitute/sting/utils/genotype/BasicGenotype.java index df6025729..cfe7f94b6 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/BasicGenotype.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/BasicGenotype.java @@ -1,6 +1,8 @@ package org.broadinstitute.sting.utils.genotype; import org.broadinstitute.sting.utils.GenomeLoc; +import org.broadinstitute.sting.utils.BaseUtils; +import org.broadinstitute.sting.utils.StingException; import java.util.List; @@ -38,6 +40,12 @@ public class BasicGenotype implements Genotype { */ public BasicGenotype(GenomeLoc location, String genotype, char ref, double negLog10PError) { mNegLog10PError = negLog10PError; + + for ( char base : genotype.toCharArray() ) { + if (! ( BaseUtils.isRegularBase(base) || BaseUtils.isNBase((byte)base) ) ) + throw new StingException(String.format("Unexpected base in Genotype at %s: '%s'", location, genotype)); + } + mGenotype = genotype; mLocation = location; mRef = ref;