From c9b2cd8ba52a25b2d8e12cdfe5f8871f8ff47e11 Mon Sep 17 00:00:00 2001 From: Matt Hanna Date: Tue, 6 Dec 2011 18:05:17 -0500 Subject: [PATCH] Fix for chartl's stale null representation issue. --- .../datasources/reads/ReadShardBalancer.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/datasources/reads/ReadShardBalancer.java b/public/java/src/org/broadinstitute/sting/gatk/datasources/reads/ReadShardBalancer.java index fa8a7d454..311c7874f 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/datasources/reads/ReadShardBalancer.java +++ b/public/java/src/org/broadinstitute/sting/gatk/datasources/reads/ReadShardBalancer.java @@ -89,11 +89,10 @@ public class ReadShardBalancer extends ShardBalancer { for(SAMReaderID id: shardPosition.keySet()) { SAMFileSpan fileSpan = new GATKBAMFileSpan(shardPosition.get(id).removeContentsBefore(position.get(id))); - if(!fileSpan.isEmpty()) - selectedReaders.put(id,fileSpan); + selectedReaders.put(id,fileSpan); } - if(selectedReaders.size() > 0) { + if(!isEmpty(selectedReaders)) { Shard shard = new ReadShard(parser,readsDataSource,selectedReaders,currentFilePointer.locations,currentFilePointer.isRegionUnmapped); readsDataSource.fillShard(shard); @@ -109,6 +108,19 @@ public class ReadShardBalancer extends ShardBalancer { position = readsDataSource.getCurrentPosition(); } + + /** + * Detects whether the list of file spans contain any read data. + * @param selectedSpans Mapping of readers to file spans. + * @return True if file spans are completely empty; false otherwise. + */ + private boolean isEmpty(Map selectedSpans) { + for(SAMFileSpan fileSpan: selectedSpans.values()) { + if(!fileSpan.isEmpty()) + return false; + } + return true; + } }; }