diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/shards/IntervalShard.java b/java/src/org/broadinstitute/sting/gatk/datasources/shards/IntervalShard.java index 5e08fe1e5..1b56727ee 100755 --- a/java/src/org/broadinstitute/sting/gatk/datasources/shards/IntervalShard.java +++ b/java/src/org/broadinstitute/sting/gatk/datasources/shards/IntervalShard.java @@ -40,8 +40,12 @@ public class IntervalShard implements Shard { /** a collection of genomic locations to interate over */ private GenomeLoc mSet; + private Shard.ShardType mType = Shard.ShardType.LOCUS_INTERVAL; - IntervalShard(GenomeLoc myLocation) { + IntervalShard(GenomeLoc myLocation, Shard.ShardType intervalType) { + if (intervalType != Shard.ShardType.LOCUS_INTERVAL && intervalType != Shard.ShardType.READ_INTERVAL) + throw new IllegalArgumentException("The specified interval type must be either LOCUS_INTERVAL or READ_INTERVAL"); + mType = intervalType; mSet = myLocation.clone(); } @@ -56,6 +60,6 @@ public class IntervalShard implements Shard { * @return READ, indicating the shard type */ public Shard.ShardType getShardType() { - return ShardType.INTERVAL; + return mType; } } diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/shards/IntervalShardStrategy.java b/java/src/org/broadinstitute/sting/gatk/datasources/shards/IntervalShardStrategy.java index fbb6159fc..9b1d4d481 100755 --- a/java/src/org/broadinstitute/sting/gatk/datasources/shards/IntervalShardStrategy.java +++ b/java/src/org/broadinstitute/sting/gatk/datasources/shards/IntervalShardStrategy.java @@ -49,7 +49,7 @@ public class IntervalShardStrategy implements ShardStrategy { /** their prefered size of the shard, we can modify this based on what we see in the shards */ private long size; - + private Shard.ShardType type; /** * change the recommended shard size for the next shard we generate. The code will do it's * best to respect this value, but there are no guarantees. @@ -66,10 +66,11 @@ public class IntervalShardStrategy implements ShardStrategy { * @param size * @param locations */ - IntervalShardStrategy( long size, GenomeLocSortedSet locations ) { + IntervalShardStrategy( long size, GenomeLocSortedSet locations, Shard.ShardType shardType ) { if (locations == null || locations.isEmpty()) { throw new StingException("IntervalShardStrategy: genomic regions list is empty."); } + type = shardType; this.regions = locations.clone(); this.size = size; } @@ -110,7 +111,7 @@ public class IntervalShardStrategy implements ShardStrategy { GenomeLoc loc = regions.iterator().next(); regions.removeRegion(loc); - return new IntervalShard(loc); + return new IntervalShard(loc,type); } diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/shards/LocusShardStrategy.java b/java/src/org/broadinstitute/sting/gatk/datasources/shards/LocusShardStrategy.java index 03611fdfb..0a950855b 100755 --- a/java/src/org/broadinstitute/sting/gatk/datasources/shards/LocusShardStrategy.java +++ b/java/src/org/broadinstitute/sting/gatk/datasources/shards/LocusShardStrategy.java @@ -173,11 +173,11 @@ public abstract class LocusShardStrategy implements ShardStrategy { if (loc.getStop() - loc.getStart() <= proposedSize) { intervals.removeRegion(loc); - return new IntervalShard(loc); + return new IntervalShard(loc,Shard.ShardType.LOCUS_INTERVAL); } else { GenomeLoc subLoc = GenomeLocParser.createGenomeLoc(loc.getContigIndex(), loc.getStart(), loc.getStart() + proposedSize - 1); intervals.removeRegion(subLoc); - return new IntervalShard(subLoc); + return new IntervalShard(subLoc,Shard.ShardType.LOCUS_INTERVAL); } } diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/shards/Shard.java b/java/src/org/broadinstitute/sting/gatk/datasources/shards/Shard.java index c4ad2600d..39ffb2a38 100644 --- a/java/src/org/broadinstitute/sting/gatk/datasources/shards/Shard.java +++ b/java/src/org/broadinstitute/sting/gatk/datasources/shards/Shard.java @@ -30,7 +30,7 @@ import java.io.Serializable; */ public interface Shard extends Serializable { enum ShardType { - READ, LOCUS, INTERVAL + READ, LOCUS, READ_INTERVAL, LOCUS_INTERVAL } /** @return the genome location represented by this shard */ diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/shards/ShardStrategyFactory.java b/java/src/org/broadinstitute/sting/gatk/datasources/shards/ShardStrategyFactory.java index 3a771e719..26ebf7b53 100644 --- a/java/src/org/broadinstitute/sting/gatk/datasources/shards/ShardStrategyFactory.java +++ b/java/src/org/broadinstitute/sting/gatk/datasources/shards/ShardStrategyFactory.java @@ -106,8 +106,9 @@ public class ShardStrategyFactory { case EXPONENTIAL: return new ExpGrowthLocusShardStrategy(dic, startingSize, lst, limitDataCount); case INTERVAL: + return new IntervalShardStrategy(startingSize, lst, Shard.ShardType.LOCUS_INTERVAL); case READS: - return new IntervalShardStrategy(startingSize, lst); + return new IntervalShardStrategy(startingSize, lst, Shard.ShardType.READ_INTERVAL); default: throw new StingException("Strategy: " + strat + " isn't implemented"); } diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/SAMDataSource.java b/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/SAMDataSource.java index d8921047a..89d905a3e 100755 --- a/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/SAMDataSource.java +++ b/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/SAMDataSource.java @@ -76,7 +76,7 @@ public class SAMDataSource implements SimpleDataSource { /** * A histogram of exactly what reads were removed from the input stream and why. */ - private SAMReadViolationHistogram violations = new SAMReadViolationHistogram(); + private SAMReadViolationHistogram violations = new SAMReadViolationHistogram(); // A pool of SAM iterators. private SAMResourcePool resourcePool = null; @@ -120,24 +120,24 @@ public class SAMDataSource implements SimpleDataSource { return resourcePool.getHeader(); } - + /** * Returns Reads data structure containing information about the reads data sources placed in this pool as well as * information about how they are downsampled, sorted, and filtered * @return */ public Reads getReadsInfo() { return reads; } - - /** + + /** * Returns header merger: a class that keeps the mapping between original read groups and read groups * of the merged stream; merger also provides access to the individual file readers (and hence headers - * prior to the merging too) maintained by the system. + * prior to the merging too) maintained by the system. * @return */ public SamFileHeaderMerger getHeaderMerger() { return resourcePool.getHeaderMerger(); } /** - * + * * @param shard the shard to get data for * * @return an iterator for that region @@ -162,7 +162,8 @@ public class SAMDataSource implements SimpleDataSource { reads.getDownsamplingFraction(), reads.getSafetyChecking(), reads.getSupplementalFilters()); - } else if (shard.getShardType() == Shard.ShardType.INTERVAL) { + } else if ((shard.getShardType() == Shard.ShardType.LOCUS_INTERVAL) || + (shard.getShardType() == Shard.ShardType.READ_INTERVAL)) { iterator = seekLocus(shard.getGenomeLoc()); iterator = applyDecoratingIterators(false, iterator, @@ -170,8 +171,8 @@ public class SAMDataSource implements SimpleDataSource { reads.getSafetyChecking(), reads.getSupplementalFilters()); - // add the new overlapping detection iterator, if we have a last interval - if (mLastInterval != null && queryOverlapping) iterator = new IntervalOverlapIterator(iterator,mLastInterval,false); + // add the new overlapping detection iterator, if we have a last interval and we're a read based shard + if (mLastInterval != null && shard.getShardType() == Shard.ShardType.READ_INTERVAL ) iterator = new IntervalOverlapIterator(iterator,mLastInterval,false); mLastInterval = shard.getGenomeLoc(); } else { @@ -258,7 +259,7 @@ public class SAMDataSource implements SimpleDataSource { */ void setResourcePool( SAMResourcePool resourcePool ) { this.resourcePool = resourcePool; - } + } /** * Retrieve unmapped reads.