gatk-3.8/java/src/org/broadinstitute/sting/gatk/executive/LinearMicroScheduler.java

60 lines
2.3 KiB
Java
Raw Normal View History

package org.broadinstitute.sting.gatk.executive;
import org.broadinstitute.sting.gatk.datasources.providers.ShardDataProvider;
import org.broadinstitute.sting.gatk.datasources.shards.Shard;
import org.broadinstitute.sting.gatk.datasources.shards.ShardStrategy;
import org.broadinstitute.sting.gatk.datasources.simpleDataSources.ReferenceOrderedDataSource;
import org.broadinstitute.sting.gatk.datasources.simpleDataSources.SAMDataSource;
import org.broadinstitute.sting.gatk.walkers.Walker;
import org.broadinstitute.sting.utils.fasta.IndexedFastaSequenceFile;
import java.util.Collection;
/** A micro-scheduling manager for single-threaded execution of a traversal. */
public class LinearMicroScheduler extends MicroScheduler {
/**
* Create a new linear microscheduler to process the given reads and reference.
*
* @param walker Walker for the traversal.
* @param reads Reads file(s) to process.
* @param reference Reference for driving the traversal.
* @param rods Reference-ordered data.
*/
protected LinearMicroScheduler( Walker walker, SAMDataSource reads, IndexedFastaSequenceFile reference, Collection<ReferenceOrderedDataSource> rods ) {
super(walker, reads, reference, rods);
}
/**
* Run this traversal over the specified subsection of the dataset.
*
* @param walker Computation to perform over dataset.
* @param shardStrategy A strategy for sharding the data.
*/
public Object execute(Walker walker, ShardStrategy shardStrategy, int maxIterations) {
// Having maxiterations in the execute method is a holdover from the old TraversalEngine days.
// Lets do something else with this.
traversalEngine.setMaximumIterations(maxIterations);
walker.initialize();
Accumulator accumulator = Accumulator.create(walker);
for (Shard shard : shardStrategy) {
ShardDataProvider dataProvider = getShardDataProvider( shard );
Object result = traversalEngine.traverse(walker, shard, dataProvider, accumulator.getReduceInit());
accumulator.accumulate( shard, result );
dataProvider.close();
}
Object result = accumulator.finishTraversal();
printOnTraversalDone(result);
return accumulator;
}
}