From e0d091b3db19f2e56cdf6ba30e5f6b75dc11ee35 Mon Sep 17 00:00:00 2001 From: ebanks Date: Thu, 6 Jan 2011 15:39:08 +0000 Subject: [PATCH] Die gracefully if the bam is malformed with quals that are too high git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4952 348d0f76-0448-11de-a6fe-93d51630548a --- .../walkers/genotyper/DiploidSNPGenotypeLikelihoods.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/DiploidSNPGenotypeLikelihoods.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/DiploidSNPGenotypeLikelihoods.java index 2835dea11..7fdb997d0 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/DiploidSNPGenotypeLikelihoods.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/DiploidSNPGenotypeLikelihoods.java @@ -26,15 +26,14 @@ package org.broadinstitute.sting.gatk.walkers.genotyper; import net.sf.samtools.SAMRecord; +import net.sf.samtools.SAMUtils; import org.broadinstitute.sting.utils.*; +import org.broadinstitute.sting.utils.exceptions.UserException; import org.broadinstitute.sting.utils.sam.GATKSAMRecord; import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; import org.broadinstitute.sting.utils.pileup.PileupElement; import org.broadinstitute.sting.utils.genotype.DiploidGenotype; -import java.util.HashSet; -import java.util.Set; - import static java.lang.Math.log10; import static java.lang.Math.pow; @@ -331,6 +330,8 @@ public class DiploidSNPGenotypeLikelihoods implements Cloneable { SAMRecord read, DiploidSNPGenotypeLikelihoods val ) { int i = BaseUtils.simpleBaseToBaseIndex(observedBase); int j = qualityScore; + if ( j > SAMUtils.MAX_PHRED_SCORE ) + throw new UserException.MalformedBam(read, String.format("the maximum allowed quality score is %d, but a quality of %d was observed in read %s", SAMUtils.MAX_PHRED_SCORE, j, read.getReadName())); int k = ploidy; int x = strandIndex(! read.getReadNegativeStrandFlag() ); @@ -341,6 +342,8 @@ public class DiploidSNPGenotypeLikelihoods implements Cloneable { byte observedBase, byte qualityScore, int ploidy, SAMRecord read) { int i = BaseUtils.simpleBaseToBaseIndex(observedBase); int j = qualityScore; + if ( j > SAMUtils.MAX_PHRED_SCORE ) + throw new UserException.MalformedBam(read, String.format("the maximum allowed quality score is %d, but a quality of %d was observed in read %s", SAMUtils.MAX_PHRED_SCORE, j, read.getReadName())); int k = ploidy; int x = strandIndex(! read.getReadNegativeStrandFlag() ); return cache[i][j][k][x];