2009-04-30 05:07:07 +08:00
|
|
|
package org.broadinstitute.sting.gatk.executive;
|
|
|
|
|
|
2009-06-12 02:13:22 +08:00
|
|
|
import org.broadinstitute.sting.gatk.datasources.providers.ShardDataProvider;
|
|
|
|
|
import org.broadinstitute.sting.gatk.datasources.shards.Shard;
|
2009-05-23 05:20:24 +08:00
|
|
|
import org.broadinstitute.sting.gatk.traversals.TraversalEngine;
|
2009-05-12 06:33:00 +08:00
|
|
|
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
|
2009-05-02 03:34:09 +08:00
|
|
|
import org.broadinstitute.sting.gatk.OutputTracker;
|
2009-05-01 04:35:56 +08:00
|
|
|
import org.broadinstitute.sting.gatk.walkers.Walker;
|
2009-04-30 05:07:07 +08:00
|
|
|
|
|
|
|
|
import java.util.concurrent.Callable;
|
|
|
|
|
/**
|
|
|
|
|
* User: hanna
|
|
|
|
|
* Date: Apr 29, 2009
|
|
|
|
|
* Time: 4:40:38 PM
|
|
|
|
|
* BROAD INSTITUTE SOFTWARE COPYRIGHT NOTICE AND AGREEMENT
|
|
|
|
|
* Software and documentation are copyright 2005 by the Broad Institute.
|
|
|
|
|
* All rights are reserved.
|
|
|
|
|
*
|
|
|
|
|
* Users acknowledge that this software is supplied without any warranty or support.
|
|
|
|
|
* The Broad Institute is not responsible for its use, misuse, or
|
|
|
|
|
* functionality.
|
|
|
|
|
*/
|
|
|
|
|
/**
|
|
|
|
|
* Carries the walker over a given shard, in a callable interface.
|
|
|
|
|
*/
|
|
|
|
|
public class ShardTraverser implements Callable {
|
2009-05-30 06:19:27 +08:00
|
|
|
private HierarchicalMicroScheduler microScheduler;
|
2009-04-30 05:07:07 +08:00
|
|
|
private Walker walker;
|
2009-05-23 05:20:24 +08:00
|
|
|
private TraversalEngine traversalEngine;
|
2009-04-30 05:07:07 +08:00
|
|
|
private Shard shard;
|
2009-05-09 05:27:54 +08:00
|
|
|
private ShardDataProvider dataProvider;
|
2009-05-02 06:01:04 +08:00
|
|
|
private OutputMerger output;
|
2009-04-30 05:07:07 +08:00
|
|
|
|
2009-05-30 06:19:27 +08:00
|
|
|
public ShardTraverser( HierarchicalMicroScheduler microScheduler,
|
|
|
|
|
TraversalEngine traversalEngine,
|
2009-04-30 05:07:07 +08:00
|
|
|
Walker walker,
|
|
|
|
|
Shard shard,
|
2009-05-09 05:27:54 +08:00
|
|
|
ShardDataProvider dataProvider,
|
2009-05-02 06:01:04 +08:00
|
|
|
OutputMerger output ) {
|
2009-05-30 06:19:27 +08:00
|
|
|
this.microScheduler = microScheduler;
|
2009-04-30 05:07:07 +08:00
|
|
|
this.walker = walker;
|
|
|
|
|
this.traversalEngine = traversalEngine;
|
|
|
|
|
this.shard = shard;
|
2009-05-09 05:27:54 +08:00
|
|
|
this.dataProvider = dataProvider;
|
2009-05-02 03:34:09 +08:00
|
|
|
this.output = output;
|
2009-04-30 05:07:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Object call() {
|
2009-05-30 06:19:27 +08:00
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
|
2009-05-08 22:12:45 +08:00
|
|
|
Object accumulator = walker.reduceInit();
|
2009-05-12 06:33:00 +08:00
|
|
|
OutputTracker outputTracker = GenomeAnalysisEngine.instance.getOutputTracker();
|
2009-05-02 03:34:09 +08:00
|
|
|
outputTracker.setLocalStreams( output.getOutStream(), output.getErrStream() );
|
2009-05-09 05:27:54 +08:00
|
|
|
|
2009-05-02 03:34:09 +08:00
|
|
|
try {
|
2009-05-09 05:27:54 +08:00
|
|
|
accumulator = traversalEngine.traverse( walker, shard, dataProvider, accumulator );
|
2009-05-02 03:34:09 +08:00
|
|
|
}
|
|
|
|
|
finally {
|
2009-05-09 05:27:54 +08:00
|
|
|
dataProvider.close();
|
2009-05-02 03:34:09 +08:00
|
|
|
output.complete();
|
2009-05-27 05:56:57 +08:00
|
|
|
outputTracker.cleanup();
|
2009-05-02 03:34:09 +08:00
|
|
|
}
|
2009-04-30 05:07:07 +08:00
|
|
|
|
2009-05-30 06:19:27 +08:00
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
microScheduler.reportShardTraverseTime(endTime-startTime);
|
|
|
|
|
|
2009-04-30 05:07:07 +08:00
|
|
|
return accumulator;
|
|
|
|
|
}
|
|
|
|
|
}
|