From 5f7ccdcc01c289b7d73c134762fb4a36bb28d060 Mon Sep 17 00:00:00 2001 From: Mark DePristo Date: Mon, 27 Feb 2012 15:12:25 -0500 Subject: [PATCH] Avoid calling getBasePileup when there's no pileup in NBaseCount annotation --- .../sting/gatk/walkers/annotator/NBaseCount.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/NBaseCount.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/NBaseCount.java index 891e9ae56..acd3b9e35 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/NBaseCount.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/NBaseCount.java @@ -27,13 +27,15 @@ public class NBaseCount extends InfoFieldAnnotation { int countNBaseSolid = 0; int countRegularBaseSolid = 0; - for( final Map.Entry sample : stratifiedContexts.entrySet() ) { - for( final PileupElement p : sample.getValue().getBasePileup()) { - if( p.getRead().getReadGroup().getPlatform().toUpperCase().contains("SOLID") ) { - if( BaseUtils.isNBase( p.getBase() ) ) { - countNBaseSolid++; - } else if( BaseUtils.isRegularBase( p.getBase() ) ) { - countRegularBaseSolid++; + for( final AlignmentContext context : stratifiedContexts.values() ) { + if ( context.hasBasePileup() ) { // must be called as getBasePileup may throw error when pileup has no bases + for( final PileupElement p : context.getBasePileup()) { + if( p.getRead().getReadGroup().getPlatform().toUpperCase().contains("SOLID") ) { + if( BaseUtils.isNBase( p.getBase() ) ) { + countNBaseSolid++; + } else if( BaseUtils.isRegularBase( p.getBase() ) ) { + countRegularBaseSolid++; + } } } }