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
This commit is contained in:
ebanks 2011-01-06 15:39:08 +00:00
parent 3163970ad5
commit e0d091b3db
1 changed files with 6 additions and 3 deletions

View File

@ -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];