2009-03-27 23:40:45 +08:00
|
|
|
package org.broadinstitute.sting.gatk.executive;
|
|
|
|
|
|
2009-05-09 05:27:54 +08:00
|
|
|
import org.broadinstitute.sting.gatk.dataSources.providers.ShardDataProvider;
|
2009-04-16 02:29:38 +08:00
|
|
|
import org.broadinstitute.sting.gatk.dataSources.shards.Shard;
|
2009-04-10 04:28:17 +08:00
|
|
|
import org.broadinstitute.sting.gatk.dataSources.shards.ShardStrategy;
|
2009-04-16 02:29:38 +08:00
|
|
|
import org.broadinstitute.sting.gatk.walkers.Walker;
|
2009-05-07 07:26:21 +08:00
|
|
|
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum;
|
|
|
|
|
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedData;
|
2009-05-16 05:02:12 +08:00
|
|
|
import org.broadinstitute.sting.gatk.Reads;
|
2009-04-16 02:29:38 +08:00
|
|
|
import org.broadinstitute.sting.utils.GenomeLoc;
|
2009-05-27 04:57:46 +08:00
|
|
|
import org.broadinstitute.sting.utils.GenomeLocSortedSet;
|
2009-04-10 04:28:17 +08:00
|
|
|
|
|
|
|
|
import java.io.File;
|
2009-04-16 02:29:38 +08:00
|
|
|
import java.util.List;
|
2009-03-27 23:40:45 +08:00
|
|
|
|
2009-05-07 06:36:25 +08:00
|
|
|
/** A micro-scheduling manager for single-threaded execution of a traversal. */
|
2009-04-27 01:46:52 +08:00
|
|
|
public class LinearMicroScheduler extends MicroScheduler {
|
2009-04-10 04:28:17 +08:00
|
|
|
|
2009-04-27 07:08:12 +08:00
|
|
|
/**
|
|
|
|
|
* Create a new linear microscheduler to process the given reads and reference.
|
2009-05-07 06:36:25 +08:00
|
|
|
*
|
|
|
|
|
* @param reads Reads file(s) to process.
|
2009-04-27 07:08:12 +08:00
|
|
|
* @param refFile Reference for driving the traversal.
|
|
|
|
|
*/
|
2009-05-16 05:02:12 +08:00
|
|
|
protected LinearMicroScheduler( Walker walker, Reads reads, File refFile, List<ReferenceOrderedData<? extends ReferenceOrderedDatum>> rods ) {
|
2009-05-09 05:27:54 +08:00
|
|
|
super(walker, reads, refFile, rods);
|
2009-03-27 23:40:45 +08:00
|
|
|
}
|
2009-04-10 04:28:17 +08:00
|
|
|
|
2009-04-27 07:08:12 +08:00
|
|
|
/**
|
|
|
|
|
* Run this traversal over the specified subsection of the dataset.
|
2009-05-07 06:36:25 +08:00
|
|
|
*
|
|
|
|
|
* @param walker Computation to perform over dataset.
|
2009-04-27 07:08:12 +08:00
|
|
|
* @param locations Subset of the dataset over which to walk.
|
2009-06-08 23:12:24 +08:00
|
|
|
* @param maxIterations the maximum number of iterations we're to perform
|
2009-04-27 07:08:12 +08:00
|
|
|
*/
|
2009-06-08 23:12:24 +08:00
|
|
|
public Object execute(Walker walker, GenomeLocSortedSet locations, Integer maxIterations) {
|
|
|
|
|
ShardStrategy shardStrategy = getShardStrategy(walker, reference, locations, maxIterations);
|
2009-04-11 04:50:28 +08:00
|
|
|
|
2009-05-08 08:58:37 +08:00
|
|
|
walker.initialize();
|
2009-05-19 06:54:18 +08:00
|
|
|
Accumulator accumulator = Accumulator.create(walker);
|
2009-04-10 04:28:17 +08:00
|
|
|
|
2009-05-07 06:36:25 +08:00
|
|
|
for (Shard shard : shardStrategy) {
|
2009-05-09 05:27:54 +08:00
|
|
|
ShardDataProvider dataProvider = getShardDataProvider( shard );
|
2009-05-19 06:54:18 +08:00
|
|
|
|
|
|
|
|
Object result = traversalEngine.traverse(walker, shard, dataProvider, accumulator.getReduceInit());
|
|
|
|
|
accumulator.accumulate( shard, result );
|
|
|
|
|
|
2009-05-09 05:27:54 +08:00
|
|
|
dataProvider.close();
|
2009-04-10 04:28:17 +08:00
|
|
|
}
|
|
|
|
|
|
2009-05-19 06:54:18 +08:00
|
|
|
Object result = accumulator.finishTraversal();
|
2009-05-07 06:36:25 +08:00
|
|
|
|
2009-05-19 06:54:18 +08:00
|
|
|
traversalEngine.printOnTraversalDone(result);
|
2009-05-16 04:20:27 +08:00
|
|
|
|
|
|
|
|
return accumulator;
|
2009-04-10 04:28:17 +08:00
|
|
|
}
|
|
|
|
|
|
2009-04-16 02:29:38 +08:00
|
|
|
|
2009-03-27 23:40:45 +08:00
|
|
|
}
|