Avoid calling getBasePileup when there's no pileup in NBaseCount annotation
This commit is contained in:
parent
729bb954e2
commit
5f7ccdcc01
|
|
@ -27,8 +27,9 @@ public class NBaseCount extends InfoFieldAnnotation {
|
||||||
int countNBaseSolid = 0;
|
int countNBaseSolid = 0;
|
||||||
int countRegularBaseSolid = 0;
|
int countRegularBaseSolid = 0;
|
||||||
|
|
||||||
for( final Map.Entry<String, AlignmentContext> sample : stratifiedContexts.entrySet() ) {
|
for( final AlignmentContext context : stratifiedContexts.values() ) {
|
||||||
for( final PileupElement p : sample.getValue().getBasePileup()) {
|
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( p.getRead().getReadGroup().getPlatform().toUpperCase().contains("SOLID") ) {
|
||||||
if( BaseUtils.isNBase( p.getBase() ) ) {
|
if( BaseUtils.isNBase( p.getBase() ) ) {
|
||||||
countNBaseSolid++;
|
countNBaseSolid++;
|
||||||
|
|
@ -38,6 +39,7 @@ public class NBaseCount extends InfoFieldAnnotation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
final Map<String, Object> map = new HashMap<String, Object>();
|
final Map<String, Object> map = new HashMap<String, Object>();
|
||||||
map.put(getKeyNames().get(0), String.format("%.4f", (double)countNBaseSolid / (double)(countNBaseSolid + countRegularBaseSolid + 1)));
|
map.put(getKeyNames().get(0), String.format("%.4f", (double)countNBaseSolid / (double)(countNBaseSolid + countRegularBaseSolid + 1)));
|
||||||
return map;
|
return map;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue