More cleanup -- pushing shared functions down into the traversal engine.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@639 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
7a9cfe1f75
commit
483a58627b
|
|
@ -2,6 +2,7 @@ package org.broadinstitute.sting.gatk.dataSources.providers;
|
|||
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.fasta.IndexedFastaSequenceFile;
|
||||
import org.broadinstitute.sting.gatk.dataSources.shards.Shard;
|
||||
import edu.mit.broad.picard.reference.ReferenceSequence;
|
||||
import net.sf.samtools.util.StringUtil;
|
||||
|
||||
|
|
@ -16,7 +17,8 @@ public class ReferenceProvider {
|
|||
private ReferenceSequence referenceSequence;
|
||||
private GenomeLoc referenceInterval;
|
||||
|
||||
public ReferenceProvider( IndexedFastaSequenceFile sequenceFile, GenomeLoc position ) {
|
||||
public ReferenceProvider( IndexedFastaSequenceFile sequenceFile, Shard shard ) {
|
||||
GenomeLoc position = shard.getGenomeLoc();
|
||||
this.referenceSequence = sequenceFile.getSubsequenceAt( position.getContig(),
|
||||
position.getStart(),
|
||||
position.getStop() );
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ public class HierarchicalMicroScheduler extends MicroScheduler implements Reduce
|
|||
throw new StingException("Unable to retrieve result", ex );
|
||||
}
|
||||
|
||||
traversalEngine.printOnTraversalDone("loci", result);
|
||||
traversalEngine.printOnTraversalDone(result);
|
||||
walker.onTraversalDone(result);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,12 +5,10 @@ import org.broadinstitute.sting.gatk.dataSources.providers.ReferenceProvider;
|
|||
import org.broadinstitute.sting.gatk.dataSources.shards.Shard;
|
||||
import org.broadinstitute.sting.gatk.dataSources.shards.ShardStrategy;
|
||||
import org.broadinstitute.sting.gatk.dataSources.simpleDataSources.SAMDataSource;
|
||||
import org.broadinstitute.sting.gatk.dataSources.simpleDataSources.SimpleDataSourceLoadException;
|
||||
import org.broadinstitute.sting.gatk.iterators.StingSAMIterator;
|
||||
import org.broadinstitute.sting.gatk.traversals.TraverseByReads;
|
||||
import org.broadinstitute.sting.gatk.traversals.TraverseLociByReference;
|
||||
import org.broadinstitute.sting.gatk.traversals.TraverseReads;
|
||||
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
|
||||
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
|
||||
import org.broadinstitute.sting.gatk.walkers.Walker;
|
||||
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum;
|
||||
|
|
@ -61,7 +59,7 @@ public class LinearMicroScheduler extends MicroScheduler {
|
|||
|
||||
StingSAMIterator readShard = dataSource.seek(shard);
|
||||
|
||||
ReferenceProvider referenceProvider = new ReferenceProvider(reference, shard.getGenomeLoc());
|
||||
ReferenceProvider referenceProvider = new ReferenceProvider(reference, shard);
|
||||
LocusContextProvider locusProvider = new LocusContextProvider(readShard);
|
||||
|
||||
if (!isAReadWalker) {
|
||||
|
|
@ -73,8 +71,7 @@ public class LinearMicroScheduler extends MicroScheduler {
|
|||
readShard.close();
|
||||
}
|
||||
|
||||
String type = (isAReadWalker) ? "read" : "loci";
|
||||
traversalEngine.printOnTraversalDone(type, accumulator);
|
||||
traversalEngine.printOnTraversalDone(accumulator);
|
||||
|
||||
walker.onTraversalDone(accumulator);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,12 +53,12 @@ public class ShardTraverser implements Callable {
|
|||
}
|
||||
|
||||
public Object call() {
|
||||
Object accumulator = ((LocusWalker<?,?>)walker).reduceInit();
|
||||
Object accumulator = walker.reduceInit();
|
||||
|
||||
CloseableIterator<SAMRecord> readShard = null;
|
||||
readShard = reads.seek( shard );
|
||||
|
||||
ReferenceProvider referenceProvider = new ReferenceProvider( reference, shard.getGenomeLoc() );
|
||||
ReferenceProvider referenceProvider = new ReferenceProvider( reference, shard );
|
||||
LocusContextProvider locusProvider = new LocusContextProvider( readShard );
|
||||
|
||||
OutputTracker outputTracker = GenomeAnalysisTK.Instance.getOutputTracker();
|
||||
|
|
|
|||
|
|
@ -280,6 +280,16 @@ public abstract class TraversalEngine {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A passthrough method so that subclasses can report which types of traversals they're using.
|
||||
* TODO: Make this method abstract once all traversals support it.
|
||||
* @param sum Result of the computation.
|
||||
* @param <T> Type of the computation.
|
||||
*/
|
||||
public <T> void printOnTraversalDone( T sum ) {
|
||||
throw new UnsupportedOperationException( "This method should be overridden." );
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after a traversal to print out information about the traversal process
|
||||
*
|
||||
|
|
@ -287,7 +297,7 @@ public abstract class TraversalEngine {
|
|||
* @param sum The reduce result of the traversal
|
||||
* @param <T> ReduceType of the traversal
|
||||
*/
|
||||
public <T> void printOnTraversalDone(final String type, T sum) {
|
||||
protected <T> void printOnTraversalDone(final String type, T sum) {
|
||||
printProgress(true, type, null);
|
||||
logger.info("Traversal reduce result is " + sum);
|
||||
final long curTime = System.currentTimeMillis();
|
||||
|
|
|
|||
|
|
@ -90,4 +90,14 @@ public class TraverseLociByReference extends TraversalEngine {
|
|||
|
||||
return sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporary override of printOnTraversalDone.
|
||||
* TODO: Add some sort of TE.getName() function once all TraversalEngines are ported.
|
||||
* @param sum Result of the computation.
|
||||
* @param <T> Type of the result.
|
||||
*/
|
||||
public <T> void printOnTraversalDone( T sum ) {
|
||||
printOnTraversalDone( "loci", sum );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,4 +119,13 @@ public class TraverseReads extends TraversalEngine {
|
|||
return sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporary override of printOnTraversalDone.
|
||||
* TODO: Add some sort of TE.getName() function once all TraversalEngines are ported.
|
||||
* @param sum Result of the computation.
|
||||
* @param <T> Type of the result.
|
||||
*/
|
||||
public <T> void printOnTraversalDone( T sum ) {
|
||||
printOnTraversalDone( "reads", sum );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue