Add hidden command-line argument for low-memory sharding.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5355 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
hanna 2011-03-02 15:13:16 +00:00
parent ae42c0c7da
commit 5e4b321f86
5 changed files with 37 additions and 8 deletions

View File

@ -836,6 +836,9 @@ public class GenomeAnalysisEngine {
if ( getWalkerBAQApplicationTime() == BAQ.ApplicationTime.FORBIDDEN && argCollection.BAQMode != BAQ.CalculationMode.OFF) 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."); 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( return new SAMDataSource(
samReaderIDs, samReaderIDs,
genomeLocParser, genomeLocParser,

View File

@ -238,10 +238,14 @@ public class GATKArgumentCollection {
public int processTrackerID = -1; public int processTrackerID = -1;
@Element(required = false) @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 @Hidden
public boolean allowIntervalsWithUnindexedBAM = false; 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 // methods
@ -428,6 +432,9 @@ public class GATKArgumentCollection {
if (allowIntervalsWithUnindexedBAM != other.allowIntervalsWithUnindexedBAM) if (allowIntervalsWithUnindexedBAM != other.allowIntervalsWithUnindexedBAM)
return false; return false;
if (enableLowMemorySharding != other.enableLowMemorySharding)
return false;
return true; return true;
} }

View File

@ -83,7 +83,7 @@ public class LocusShardStrategy implements ShardStrategy {
else else
intervals = locations; intervals = locations;
if(SAMDataSource.TRY_LOW_MEMORY_SHARDING) if(SAMDataSource.isLowMemoryShardingEnabled())
this.filePointerIterator = new LowMemoryIntervalSharder(this.reads,intervals); this.filePointerIterator = new LowMemoryIntervalSharder(this.reads,intervals);
else else
this.filePointerIterator = IntervalSharder.shardIntervals(this.reads,intervals); this.filePointerIterator = IntervalSharder.shardIntervals(this.reads,intervals);

View File

@ -96,7 +96,7 @@ public class ReadShardStrategy implements ShardStrategy {
this.locations = locations; this.locations = locations;
if(locations != null) 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 else
filePointerIterator = filePointers.iterator(); filePointerIterator = filePointers.iterator();

View File

@ -128,7 +128,10 @@ public class SAMDataSource {
*/ */
private final SAMResourcePool resourcePool; 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. * Create a new SAM data source given the supplied read metadata.
@ -281,7 +284,7 @@ public class SAMDataSource {
originalToMergedReadGroupMappings.put(id,mappingToMerged); originalToMergedReadGroupMappings.put(id,mappingToMerged);
} }
if(TRY_LOW_MEMORY_SHARDING) { if(enableLowMemorySharding) {
for(SAMReaderID id: readerIDs) { for(SAMReaderID id: readerIDs) {
File indexFile = findIndexFile(id.samFile); File indexFile = findIndexFile(id.samFile);
if(indexFile != null) { if(indexFile != null) {
@ -302,6 +305,22 @@ public class SAMDataSource {
*/ */
public ReadProperties getReadsInfo() { return readProperties; } 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. * Checks to see whether any reads files are supplying data.
* @return True if no reads files are supplying data to the traversal; false otherwise. * @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. * @return True if all readers have an index.
*/ */
public boolean hasIndex() { public boolean hasIndex() {
if(TRY_LOW_MEMORY_SHARDING) if(enableLowMemorySharding)
return readerIDs.size() == bamIndices.size(); return readerIDs.size() == bamIndices.size();
else { else {
for(SAMFileReader reader: resourcePool.getReadersWithoutLocking()) { for(SAMFileReader reader: resourcePool.getReadersWithoutLocking()) {
@ -406,7 +425,7 @@ public class SAMDataSource {
* @return The index. Will preload the index if necessary. * @return The index. Will preload the index if necessary.
*/ */
public BrowseableBAMIndex getIndex(final SAMReaderID id) { public BrowseableBAMIndex getIndex(final SAMReaderID id) {
if(TRY_LOW_MEMORY_SHARDING) if(enableLowMemorySharding)
return bamIndices.get(id); return bamIndices.get(id);
else { else {
SAMReaders readers = resourcePool.getReadersWithoutLocking(); SAMReaders readers = resourcePool.getReadersWithoutLocking();
@ -729,7 +748,7 @@ public class SAMDataSource {
for(SAMReaderID readerID: readerIDs) { for(SAMReaderID readerID: readerIDs) {
SAMFileReader reader = new SAMFileReader(readerID.samFile); SAMFileReader reader = new SAMFileReader(readerID.samFile);
reader.enableFileSource(true); reader.enableFileSource(true);
if(!TRY_LOW_MEMORY_SHARDING) if(!enableLowMemorySharding)
reader.enableIndexCaching(true); reader.enableIndexCaching(true);
reader.setValidationStringency(validationStringency); reader.setValidationStringency(validationStringency);