diff --git a/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java b/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java index 0c8d9198e..74868e61b 100755 --- a/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java +++ b/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java @@ -836,6 +836,9 @@ public class GenomeAnalysisEngine { if ( getWalkerBAQApplicationTime() == BAQ.ApplicationTime.FORBIDDEN && argCollection.BAQMode != BAQ.CalculationMode.OFF) throw new UserException.BadArgumentValue("baq", "Walker cannot accept BAQ'd base qualities, and yet BAQ mode " + argCollection.BAQMode + " was requested."); + // TEMPORARY: Force low-memory sharding to be available. + SAMDataSource.enableLowMemorySharding(argCollection.enableLowMemorySharding); + return new SAMDataSource( samReaderIDs, genomeLocParser, diff --git a/java/src/org/broadinstitute/sting/gatk/arguments/GATKArgumentCollection.java b/java/src/org/broadinstitute/sting/gatk/arguments/GATKArgumentCollection.java index 2eff6dd11..4e81b8294 100755 --- a/java/src/org/broadinstitute/sting/gatk/arguments/GATKArgumentCollection.java +++ b/java/src/org/broadinstitute/sting/gatk/arguments/GATKArgumentCollection.java @@ -238,10 +238,14 @@ public class GATKArgumentCollection { public int processTrackerID = -1; @Element(required = false) - @Argument(fullName="allow_intervals_with_unindexed_bam",doc="Allow interval processing with an unsupported BAM. NO INTEGRATION TESTS are available. Use at your own risk.") + @Argument(fullName="allow_intervals_with_unindexed_bam",doc="Allow interval processing with an unsupported BAM. NO INTEGRATION TESTS are available. Use at your own risk.",required=false) @Hidden public boolean allowIntervalsWithUnindexedBAM = false; + @Element(required = false) + @Argument(fullName="enable_experimental_low_memory_sharding",doc="Enable experimental low-memory sharding functionality. Use at your own risk.",required=false) + public boolean enableLowMemorySharding = false; + // -------------------------------------------------------------------------------------------------------------- // // methods @@ -428,6 +432,9 @@ public class GATKArgumentCollection { if (allowIntervalsWithUnindexedBAM != other.allowIntervalsWithUnindexedBAM) return false; + if (enableLowMemorySharding != other.enableLowMemorySharding) + return false; + return true; } diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/reads/LocusShardStrategy.java b/java/src/org/broadinstitute/sting/gatk/datasources/reads/LocusShardStrategy.java index d40ee74c3..c9eb5b98e 100755 --- a/java/src/org/broadinstitute/sting/gatk/datasources/reads/LocusShardStrategy.java +++ b/java/src/org/broadinstitute/sting/gatk/datasources/reads/LocusShardStrategy.java @@ -83,7 +83,7 @@ public class LocusShardStrategy implements ShardStrategy { else intervals = locations; - if(SAMDataSource.TRY_LOW_MEMORY_SHARDING) + if(SAMDataSource.isLowMemoryShardingEnabled()) this.filePointerIterator = new LowMemoryIntervalSharder(this.reads,intervals); else this.filePointerIterator = IntervalSharder.shardIntervals(this.reads,intervals); diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/reads/ReadShardStrategy.java b/java/src/org/broadinstitute/sting/gatk/datasources/reads/ReadShardStrategy.java index 4b85c61d3..465ae20d6 100755 --- a/java/src/org/broadinstitute/sting/gatk/datasources/reads/ReadShardStrategy.java +++ b/java/src/org/broadinstitute/sting/gatk/datasources/reads/ReadShardStrategy.java @@ -96,7 +96,7 @@ public class ReadShardStrategy implements ShardStrategy { this.locations = locations; if(locations != null) - filePointerIterator = SAMDataSource.TRY_LOW_MEMORY_SHARDING ? new LowMemoryIntervalSharder(this.dataSource,locations) : IntervalSharder.shardIntervals(this.dataSource,locations); + filePointerIterator = SAMDataSource.isLowMemoryShardingEnabled() ? new LowMemoryIntervalSharder(this.dataSource,locations) : IntervalSharder.shardIntervals(this.dataSource,locations); else filePointerIterator = filePointers.iterator(); diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/reads/SAMDataSource.java b/java/src/org/broadinstitute/sting/gatk/datasources/reads/SAMDataSource.java index 5877f67bb..57a01c20a 100755 --- a/java/src/org/broadinstitute/sting/gatk/datasources/reads/SAMDataSource.java +++ b/java/src/org/broadinstitute/sting/gatk/datasources/reads/SAMDataSource.java @@ -128,7 +128,10 @@ public class SAMDataSource { */ private final SAMResourcePool resourcePool; - static final boolean TRY_LOW_MEMORY_SHARDING = false; + /** + * Whether to enable the new low-memory sharding mechanism. + */ + private static boolean enableLowMemorySharding = false; /** * Create a new SAM data source given the supplied read metadata. @@ -281,7 +284,7 @@ public class SAMDataSource { originalToMergedReadGroupMappings.put(id,mappingToMerged); } - if(TRY_LOW_MEMORY_SHARDING) { + if(enableLowMemorySharding) { for(SAMReaderID id: readerIDs) { File indexFile = findIndexFile(id.samFile); if(indexFile != null) { @@ -302,6 +305,22 @@ public class SAMDataSource { */ public ReadProperties getReadsInfo() { return readProperties; } + /** + * Enable experimental low-memory sharding. + * @param enable True to enable sharding. False otherwise. + */ + public static void enableLowMemorySharding(final boolean enable) { + enableLowMemorySharding = enable; + } + + /** + * Returns whether low-memory sharding is enabled. + * @return True if enabled, false otherwise. + */ + public static boolean isLowMemoryShardingEnabled() { + return enableLowMemorySharding; + } + /** * Checks to see whether any reads files are supplying data. * @return True if no reads files are supplying data to the traversal; false otherwise. @@ -389,7 +408,7 @@ public class SAMDataSource { * @return True if all readers have an index. */ public boolean hasIndex() { - if(TRY_LOW_MEMORY_SHARDING) + if(enableLowMemorySharding) return readerIDs.size() == bamIndices.size(); else { for(SAMFileReader reader: resourcePool.getReadersWithoutLocking()) { @@ -406,7 +425,7 @@ public class SAMDataSource { * @return The index. Will preload the index if necessary. */ public BrowseableBAMIndex getIndex(final SAMReaderID id) { - if(TRY_LOW_MEMORY_SHARDING) + if(enableLowMemorySharding) return bamIndices.get(id); else { SAMReaders readers = resourcePool.getReadersWithoutLocking(); @@ -729,7 +748,7 @@ public class SAMDataSource { for(SAMReaderID readerID: readerIDs) { SAMFileReader reader = new SAMFileReader(readerID.samFile); reader.enableFileSource(true); - if(!TRY_LOW_MEMORY_SHARDING) + if(!enableLowMemorySharding) reader.enableIndexCaching(true); reader.setValidationStringency(validationStringency);