2009-06-23 05:11:18 +08:00
/ *
2010-10-28 03:44:55 +08:00
* Copyright ( c ) 2010 , The Broad Institute
2010-04-20 23:26:32 +08:00
*
2009-06-23 05:11:18 +08:00
* Permission is hereby granted , free of charge , to any person
* obtaining a copy of this software and associated documentation
2010-04-20 23:26:32 +08:00
* files ( the "Software" ) , to deal in the Software without
2009-06-23 05:11:18 +08:00
* restriction , including without limitation the rights to use ,
* copy , modify , merge , publish , distribute , sublicense , and / or sell
* copies of the Software , and to permit persons to whom the
* Software is furnished to do so , subject to the following
* conditions :
2010-04-20 23:26:32 +08:00
*
2009-06-23 05:11:18 +08:00
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software .
2010-04-20 23:26:32 +08:00
* THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
2009-06-23 05:11:18 +08:00
* EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY ,
* WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING
2010-10-28 03:44:55 +08:00
* FROM , OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE .
2009-06-23 05:11:18 +08:00
* /
2009-05-11 10:07:20 +08:00
package org.broadinstitute.sting.gatk ;
2009-07-10 07:59:53 +08:00
import net.sf.picard.filter.SamRecordFilter ;
2010-04-01 06:39:56 +08:00
import net.sf.picard.reference.ReferenceSequenceFile ;
2010-09-24 07:28:55 +08:00
import net.sf.samtools.SAMFileHeader ;
import net.sf.samtools.SAMSequenceRecord ;
import org.broadinstitute.sting.commandline.ArgumentException ;
import org.broadinstitute.sting.commandline.ArgumentSource ;
2010-09-28 10:16:25 +08:00
import org.broad.tribble.util.variantcontext.VariantContext ;
2010-04-01 06:39:56 +08:00
import org.broadinstitute.sting.gatk.arguments.GATKArgumentCollection ;
import org.broadinstitute.sting.gatk.arguments.ValidationExclusion ;
import org.broadinstitute.sting.gatk.datasources.shards.MonolithicShardStrategy ;
import org.broadinstitute.sting.gatk.datasources.shards.Shard ;
2009-07-30 00:11:45 +08:00
import org.broadinstitute.sting.gatk.datasources.shards.ShardStrategy ;
import org.broadinstitute.sting.gatk.datasources.shards.ShardStrategyFactory ;
2010-09-24 07:28:55 +08:00
import org.broadinstitute.sting.gatk.datasources.simpleDataSources.ReferenceDataSource ;
import org.broadinstitute.sting.gatk.datasources.simpleDataSources.SAMDataSource ;
2009-05-11 10:07:20 +08:00
import org.broadinstitute.sting.gatk.executive.MicroScheduler ;
2009-08-23 08:56:02 +08:00
import org.broadinstitute.sting.gatk.io.OutputTracker ;
2010-09-24 07:28:55 +08:00
import org.broadinstitute.sting.gatk.io.stubs.Stub ;
2010-04-01 06:39:56 +08:00
import org.broadinstitute.sting.gatk.refdata.tracks.RMDTrack ;
import org.broadinstitute.sting.gatk.walkers.* ;
2010-09-24 07:28:55 +08:00
import org.broadinstitute.sting.utils.GenomeLoc ;
import org.broadinstitute.sting.utils.GenomeLocParser ;
import org.broadinstitute.sting.utils.GenomeLocSortedSet ;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException ;
import org.broadinstitute.sting.utils.exceptions.UserException ;
2009-05-11 10:07:20 +08:00
2009-07-30 00:11:45 +08:00
import java.util.* ;
2009-05-11 10:07:20 +08:00
2010-09-24 07:28:55 +08:00
/ * *
* A GenomeAnalysisEngine that runs a specified walker .
* /
public class GenomeAnalysisEngine extends AbstractGenomeAnalysisEngine {
2009-10-06 10:45:31 +08:00
/ * *
* our walker manager
* /
2010-09-25 10:49:30 +08:00
private final WalkerManager walkerManager = new WalkerManager ( ) ;
2009-11-11 02:40:16 +08:00
2010-09-24 07:28:55 +08:00
private Walker < ? , ? > walker ;
2010-08-29 06:53:32 +08:00
2010-09-24 07:28:55 +08:00
public void setWalker ( Walker < ? , ? > walker ) {
this . walker = walker ;
2009-07-10 07:59:53 +08:00
}
2009-05-11 10:07:20 +08:00
2009-07-10 07:59:53 +08:00
/ * *
* Actually run the GATK with the specified walker .
2009-10-06 10:45:31 +08:00
*
2009-09-30 06:23:19 +08:00
* @return the value of this traversal .
2009-07-10 07:59:53 +08:00
* /
2010-09-24 07:28:55 +08:00
public Object execute ( ) {
2010-05-18 05:00:44 +08:00
//HeapSizeMonitor monitor = new HeapSizeMonitor();
//monitor.start();
2010-09-24 07:28:55 +08:00
setStartTime ( new java . util . Date ( ) ) ;
2010-05-18 05:00:44 +08:00
2009-05-11 10:07:20 +08:00
// validate our parameters
2010-09-24 07:28:55 +08:00
if ( this . getArguments ( ) = = null ) {
2010-09-12 23:07:38 +08:00
throw new ReviewedStingException ( "The GATKArgumentCollection passed to GenomeAnalysisEngine can not be null." ) ;
2009-05-11 10:07:20 +08:00
}
2010-04-01 20:47:48 +08:00
// validate our parameters
2010-09-24 07:28:55 +08:00
if ( this . walker = = null )
2010-09-12 23:07:38 +08:00
throw new ReviewedStingException ( "The walker passed to GenomeAnalysisEngine can not be null." ) ;
2009-07-10 07:59:53 +08:00
2009-07-30 07:00:15 +08:00
// Prepare the data for traversal.
2010-09-24 07:28:55 +08:00
initializeDataSources ( ) ;
2009-05-20 07:26:17 +08:00
2009-05-11 10:07:20 +08:00
// our microscheduler, which is in charge of running everything
2010-09-24 07:28:55 +08:00
MicroScheduler microScheduler = createMicroscheduler ( ) ;
2009-05-11 10:07:20 +08:00
2010-08-22 22:27:05 +08:00
// create the output streams "
2010-09-24 07:28:55 +08:00
initializeOutputStreams ( microScheduler . getOutputTracker ( ) ) ;
2009-05-11 10:07:20 +08:00
2010-03-15 05:08:14 +08:00
initializeIntervals ( ) ;
2010-09-24 07:28:55 +08:00
ShardStrategy shardStrategy = getShardStrategy ( microScheduler . getReference ( ) ) ;
2010-03-15 05:08:14 +08:00
// execute the microscheduler, storing the results
2010-09-24 07:28:55 +08:00
Object result = microScheduler . execute ( this . walker , shardStrategy ) ;
2010-05-18 05:00:44 +08:00
//monitor.stop();
//logger.info(String.format("Maximum heap size consumed: %d",monitor.getMaxMemoryUsed()));
return result ;
2010-03-15 05:08:14 +08:00
}
2009-07-10 07:59:53 +08:00
/ * *
* Retrieves an instance of the walker based on the walker name .
2009-10-06 10:45:31 +08:00
*
2009-07-10 07:59:53 +08:00
* @param walkerName Name of the walker . Must not be null . If the walker cannot be instantiated , an exception will be thrown .
* @return An instance of the walker .
* /
2009-10-06 10:45:31 +08:00
public Walker < ? , ? > getWalkerByName ( String walkerName ) {
2009-11-11 02:40:16 +08:00
return walkerManager . createByName ( walkerName ) ;
}
/ * *
* Gets the name of a given walker type .
* @param walkerType Type of walker .
* @return Name of the walker .
* /
2010-05-21 03:02:02 +08:00
public String getWalkerName ( Class < ? extends Walker > walkerType ) {
2009-11-11 02:40:16 +08:00
return walkerManager . getName ( walkerType ) ;
2009-07-10 07:59:53 +08:00
}
2009-11-11 07:36:17 +08:00
/ * *
* Gets a list of the filters to associate with the given walker . Will NOT initialize the engine with this filters ;
* the caller must handle that directly .
* @return A collection of available filters .
* /
2010-09-24 07:28:55 +08:00
@Override
2010-09-25 10:49:30 +08:00
public Collection < SamRecordFilter > createFilters ( ) {
2010-03-18 00:24:10 +08:00
Set < SamRecordFilter > filters = new HashSet < SamRecordFilter > ( ) ;
2010-09-24 07:28:55 +08:00
filters . addAll ( WalkerManager . getReadFilters ( walker , this . getFilterManager ( ) ) ) ;
filters . addAll ( super . createFilters ( ) ) ;
2009-11-11 07:36:17 +08:00
return Collections . unmodifiableSet ( filters ) ;
}
2009-12-05 07:24:29 +08:00
/ * *
* Allow subclasses and others within this package direct access to the walker manager .
* @return The walker manager used by this package .
* /
protected WalkerManager getWalkerManager ( ) {
return walkerManager ;
}
2010-09-24 07:28:55 +08:00
2009-05-11 10:07:20 +08:00
/ * *
* setup a microscheduler
2009-10-06 10:45:31 +08:00
*
2009-05-11 10:07:20 +08:00
* @return a new microscheduler
* /
2010-09-24 07:28:55 +08:00
private MicroScheduler createMicroscheduler ( ) {
Walker my_walker = this . walker ;
2009-05-11 10:07:20 +08:00
// the mircoscheduler to return
MicroScheduler microScheduler = null ;
2010-03-22 07:22:25 +08:00
// Temporarily require all walkers to have a reference, even if that reference is not conceptually necessary.
if ( ( my_walker instanceof ReadWalker | | my_walker instanceof DuplicateWalker | | my_walker instanceof ReadPairWalker ) & &
2010-09-24 07:28:55 +08:00
this . getArguments ( ) . referenceFile = = null ) {
2010-09-12 22:02:43 +08:00
throw new UserException . CommandLineException ( "Read-based traversals require a reference file but none was given" ) ;
2009-05-11 10:07:20 +08:00
}
2010-11-11 01:59:50 +08:00
return MicroScheduler . create ( this , my_walker , this . getReadsDataSource ( ) , this . getReferenceDataSource ( ) . getReference ( ) , this . getRodDataSources ( ) , this . getArguments ( ) . numberOfThreads ) ;
2010-02-04 12:12:49 +08:00
}
2010-09-24 07:28:55 +08:00
@Override
protected DownsamplingMethod getDownsamplingMethod ( ) {
GATKArgumentCollection argCollection = this . getArguments ( ) ;
DownsamplingMethod method ;
2010-08-27 05:38:03 +08:00
if ( argCollection . getDownsamplingMethod ( ) ! = null )
method = argCollection . getDownsamplingMethod ( ) ;
2010-05-19 13:40:05 +08:00
else if ( WalkerManager . getDownsamplingMethod ( walker ) ! = null )
method = WalkerManager . getDownsamplingMethod ( walker ) ;
else
2010-08-27 05:38:03 +08:00
method = argCollection . getDefaultDownsamplingMethod ( ) ;
2010-09-24 07:28:55 +08:00
return method ;
}
@Override
protected boolean generateExtendedEvents ( ) {
return walker . generateExtendedEvents ( ) ;
}
2010-05-19 13:40:05 +08:00
2010-09-24 07:28:55 +08:00
@Override
protected boolean includeReadsWithDeletionAtLoci ( ) {
return walker . includeReadsWithDeletionAtLoci ( ) ;
2009-06-10 21:39:32 +08:00
}
2009-07-30 07:00:15 +08:00
/ * *
* Verifies that the supplied set of reads files mesh with what the walker says it requires .
* /
2010-09-24 07:28:55 +08:00
@Override
protected void validateSuppliedReads ( ) {
GATKArgumentCollection arguments = this . getArguments ( ) ;
2009-05-20 07:26:17 +08:00
// Check what the walker says is required against what was provided on the command line.
2009-07-10 05:57:00 +08:00
if ( WalkerManager . isRequired ( walker , DataSource . READS ) & & ( arguments . samFiles = = null | | arguments . samFiles . size ( ) = = 0 ) )
2010-09-23 20:08:27 +08:00
throw new ArgumentException ( "Walker requires reads but none were provided." ) ;
2009-05-20 07:26:17 +08:00
// Check what the walker says is allowed against what was provided on the command line.
2009-07-10 05:57:00 +08:00
if ( ( arguments . samFiles ! = null & & arguments . samFiles . size ( ) > 0 ) & & ! WalkerManager . isAllowed ( walker , DataSource . READS ) )
2010-09-23 20:08:27 +08:00
throw new ArgumentException ( "Walker does not allow reads but reads were provided." ) ;
2009-07-30 07:00:15 +08:00
}
/ * *
* Verifies that the supplied reference file mesh with what the walker says it requires .
* /
2010-09-24 07:28:55 +08:00
@Override
protected void validateSuppliedReference ( ) {
GATKArgumentCollection arguments = this . getArguments ( ) ;
2009-07-30 07:00:15 +08:00
// Check what the walker says is required against what was provided on the command line.
2009-12-11 03:15:48 +08:00
// TODO: Temporarily disabling WalkerManager.isRequired check on the reference because the reference is always required.
if ( /*WalkerManager.isRequired(walker, DataSource.REFERENCE) &&*/ arguments . referenceFile = = null )
2010-09-23 20:08:27 +08:00
throw new ArgumentException ( "Walker requires a reference but none was provided." ) ;
2009-07-30 07:00:15 +08:00
// Check what the walker says is allowed against what was provided on the command line.
2009-07-10 05:57:00 +08:00
if ( arguments . referenceFile ! = null & & ! WalkerManager . isAllowed ( walker , DataSource . REFERENCE ) )
2010-09-23 20:08:27 +08:00
throw new ArgumentException ( "Walker does not allow a reference but one was provided." ) ;
2009-07-30 07:00:15 +08:00
}
2009-05-20 07:26:17 +08:00
2009-07-30 07:00:15 +08:00
/ * *
* Verifies that all required reference - ordered data has been supplied , and any reference - ordered data that was not
* ' allowed ' is still present .
2009-10-06 10:45:31 +08:00
*
* @param rods Reference - ordered data to load .
2009-07-30 07:00:15 +08:00
* /
2010-09-24 07:28:55 +08:00
@Override
protected void validateSuppliedReferenceOrderedData ( List < RMDTrack > rods ) {
2009-05-20 07:26:17 +08:00
// Check to make sure that all required metadata is present.
List < RMD > allRequired = WalkerManager . getRequiredMetaData ( walker ) ;
2009-07-10 05:57:00 +08:00
for ( RMD required : allRequired ) {
2009-05-20 07:26:17 +08:00
boolean found = false ;
2010-04-01 06:39:56 +08:00
for ( RMDTrack rod : rods ) {
2010-05-28 22:52:44 +08:00
if ( rod . matchesNameAndRecordType ( required . name ( ) , required . type ( ) ) )
2009-05-20 07:26:17 +08:00
found = true ;
}
2009-07-10 05:57:00 +08:00
if ( ! found )
Error message fixes for the following issues:
nvjpM4yOwQAu3fNGxi4oXLuVpKn6aAlf,1GL0OuXK2xKQfvbu34tWYgbojSVSLo0l,
ehEGBJOfgc4V7qj8W0Homf5ICuVK5Sm3,cZsreLm1CbY3aYKZhV7DOSvQNwur41zp,
GlrlyGEyP9kJDIRCQNFQp7BGJBXSzdDJ,hyz1uiHXr39ANmdZu9K1epOSX8EL3mDw,
q0n4EucZESCI4LZhQik306zD4VAuH2cb.
Messages:
camrhG5tHzlY9WUSEVpVZGkU1tyJqKb5,s0OX2g7nYRctJxyFoQCa6clac9IsjHyi,
THIAtjllvYNlnTmiMnJEIHd2Ju4gqQIO,jwVk3JYZJNHloW7HO4LeGxFexknqro0v,
BFNRGOGmGGJNNPZqgeF1ikTNFfskbyLc,...
Were fixed in 4392.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4428 348d0f76-0448-11de-a6fe-93d51630548a
2010-10-05 11:37:13 +08:00
throw new ArgumentException ( String . format ( "Walker requires reference metadata to be supplied named '%s' of type '%s', but this metadata was not provided. " +
"Please supply the specified metadata file." , required . name ( ) , required . type ( ) . getSimpleName ( ) ) ) ;
2009-05-20 07:26:17 +08:00
}
// Check to see that no forbidden rods are present.
2010-04-01 06:39:56 +08:00
for ( RMDTrack rod : rods ) {
2009-07-10 05:57:00 +08:00
if ( ! WalkerManager . isAllowed ( walker , rod ) )
2010-09-23 20:08:27 +08:00
throw new ArgumentException ( String . format ( "Walker of type %s does not allow access to metadata: %s" , walker . getClass ( ) , rod . getName ( ) ) ) ;
2009-07-30 07:00:15 +08:00
}
}
2009-07-30 00:11:45 +08:00
/ * *
* Get the sharding strategy given a driving data source .
*
* @param drivingDataSource Data on which to shard .
2010-09-24 07:28:55 +08:00
* @return the sharding strategy
2009-07-30 00:11:45 +08:00
* /
2010-09-24 07:28:55 +08:00
protected ShardStrategy getShardStrategy ( ReferenceSequenceFile drivingDataSource ) {
GenomeLocSortedSet intervals = this . getIntervals ( ) ;
2010-11-11 01:59:50 +08:00
SAMDataSource readsDataSource = this . getReadsDataSource ( ) ;
2010-09-24 07:28:55 +08:00
ValidationExclusion exclusions = ( readsDataSource ! = null ? readsDataSource . getReadsInfo ( ) . getValidationExclusionList ( ) : null ) ;
ReferenceDataSource referenceDataSource = this . getReferenceDataSource ( ) ;
2010-03-22 07:22:25 +08:00
// Use monolithic sharding if no index is present. Monolithic sharding is always required for the original
// sharding system; it's required with the new sharding system only for locus walkers.
2010-07-03 04:09:25 +08:00
if ( readsDataSource ! = null & & ! readsDataSource . hasIndex ( ) ) {
2010-07-07 11:14:59 +08:00
if ( ! exclusions . contains ( ValidationExclusion . TYPE . ALLOW_UNINDEXED_BAM ) )
2010-09-12 22:02:43 +08:00
throw new UserException . CommandLineException ( "The GATK cannot currently process unindexed BAM files without the -U ALLOW_UNINDEXED_BAM" ) ;
2010-07-07 11:14:59 +08:00
if ( intervals ! = null & & WalkerManager . getWalkerDataSource ( walker ) ! = DataSource . REFERENCE )
2010-09-12 22:02:43 +08:00
throw new UserException . CommandLineException ( "Cannot perform interval processing when walker is not driven by reference and no index is available." ) ;
2009-12-17 05:55:42 +08:00
Shard . ShardType shardType ;
2010-03-22 07:31:45 +08:00
if ( walker instanceof LocusWalker ) {
2010-07-19 00:29:59 +08:00
if ( readsDataSource . getSortOrder ( ) ! = SAMFileHeader . SortOrder . coordinate )
2010-09-14 13:04:26 +08:00
throw new UserException . MissortedBAM ( SAMFileHeader . SortOrder . coordinate , "Locus walkers can only traverse coordinate-sorted data. Please resort your input BAM file(s) or set the Sort Order tag in the header appropriately." ) ;
2009-12-17 05:55:42 +08:00
shardType = Shard . ShardType . LOCUS ;
2010-03-22 07:31:45 +08:00
}
2010-03-22 07:22:25 +08:00
else if ( walker instanceof ReadWalker | | walker instanceof DuplicateWalker | | walker instanceof ReadPairWalker )
2009-12-17 05:55:42 +08:00
shardType = Shard . ShardType . READ ;
else
2010-09-12 22:02:43 +08:00
throw new UserException . CommandLineException ( "The GATK cannot currently process unindexed BAM files" ) ;
2009-12-17 05:55:42 +08:00
2010-07-07 11:14:59 +08:00
List < GenomeLoc > region ;
if ( intervals ! = null )
region = intervals . toList ( ) ;
else {
region = new ArrayList < GenomeLoc > ( ) ;
for ( SAMSequenceRecord sequenceRecord : drivingDataSource . getSequenceDictionary ( ) . getSequences ( ) )
2010-11-11 01:59:50 +08:00
region . add ( getGenomeLocParser ( ) . createGenomeLoc ( sequenceRecord . getSequenceName ( ) , 1 , sequenceRecord . getSequenceLength ( ) ) ) ;
2010-07-07 11:14:59 +08:00
}
2010-08-12 04:17:11 +08:00
return new MonolithicShardStrategy ( readsDataSource , shardType , region ) ;
2009-12-17 05:55:42 +08:00
}
2009-07-30 00:11:45 +08:00
ShardStrategy shardStrategy = null ;
ShardStrategyFactory . SHATTER_STRATEGY shardType ;
2009-09-13 03:13:15 +08:00
2009-12-17 05:55:42 +08:00
long SHARD_SIZE = 100000L ;
2009-07-30 00:11:45 +08:00
if ( walker instanceof LocusWalker ) {
2009-10-21 07:31:13 +08:00
if ( walker instanceof RodWalker ) SHARD_SIZE * = 1000 ;
2009-09-13 03:13:15 +08:00
2010-01-13 01:52:27 +08:00
if ( intervals ! = null & & ! intervals . isEmpty ( ) ) {
2010-08-12 04:17:11 +08:00
if ( ! readsDataSource . isEmpty ( ) & & readsDataSource . getSortOrder ( ) ! = SAMFileHeader . SortOrder . coordinate )
2010-09-14 13:04:26 +08:00
throw new UserException . MissortedBAM ( SAMFileHeader . SortOrder . coordinate , "Locus walkers can only traverse coordinate-sorted data. Please resort your input BAM file(s) or set the Sort Order tag in the header appropriately." ) ;
2010-03-22 07:22:25 +08:00
2010-01-15 11:35:55 +08:00
shardStrategy = ShardStrategyFactory . shatter ( readsDataSource ,
2010-06-11 04:10:23 +08:00
referenceDataSource . getReference ( ) ,
2010-06-18 04:17:31 +08:00
ShardStrategyFactory . SHATTER_STRATEGY . LOCUS_EXPERIMENTAL ,
2009-07-30 00:11:45 +08:00
drivingDataSource . getSequenceDictionary ( ) ,
SHARD_SIZE ,
2010-11-11 01:59:50 +08:00
getGenomeLocParser ( ) ,
2010-08-10 04:41:50 +08:00
intervals ) ;
2009-07-30 00:11:45 +08:00
} else
2010-03-01 09:58:44 +08:00
shardStrategy = ShardStrategyFactory . shatter ( readsDataSource ,
2010-06-11 04:10:23 +08:00
referenceDataSource . getReference ( ) ,
2010-06-18 04:17:31 +08:00
ShardStrategyFactory . SHATTER_STRATEGY . LOCUS_EXPERIMENTAL ,
2009-07-30 00:11:45 +08:00
drivingDataSource . getSequenceDictionary ( ) ,
2010-11-11 01:59:50 +08:00
SHARD_SIZE , getGenomeLocParser ( ) ) ;
2009-07-30 00:11:45 +08:00
} else if ( walker instanceof ReadWalker | |
walker instanceof DuplicateWalker ) {
2010-06-18 04:17:31 +08:00
shardType = ShardStrategyFactory . SHATTER_STRATEGY . READS_EXPERIMENTAL ;
2009-07-30 00:11:45 +08:00
2010-01-13 01:52:27 +08:00
if ( intervals ! = null & & ! intervals . isEmpty ( ) ) {
2010-03-08 05:01:25 +08:00
shardStrategy = ShardStrategyFactory . shatter ( readsDataSource ,
2010-06-11 04:10:23 +08:00
referenceDataSource . getReference ( ) ,
2010-03-08 05:01:25 +08:00
shardType ,
2009-07-30 00:11:45 +08:00
drivingDataSource . getSequenceDictionary ( ) ,
SHARD_SIZE ,
2010-11-11 01:59:50 +08:00
getGenomeLocParser ( ) ,
2010-08-10 04:41:50 +08:00
intervals ) ;
2009-07-30 00:11:45 +08:00
} else {
2010-03-08 05:01:25 +08:00
shardStrategy = ShardStrategyFactory . shatter ( readsDataSource ,
2010-06-11 04:10:23 +08:00
referenceDataSource . getReference ( ) ,
2010-03-08 05:01:25 +08:00
shardType ,
2009-07-30 00:11:45 +08:00
drivingDataSource . getSequenceDictionary ( ) ,
2010-11-11 01:59:50 +08:00
SHARD_SIZE ,
getGenomeLocParser ( ) ) ;
2009-07-30 00:11:45 +08:00
}
2010-03-22 07:22:25 +08:00
} else if ( walker instanceof ReadPairWalker ) {
if ( readsDataSource ! = null & & readsDataSource . getSortOrder ( ) ! = SAMFileHeader . SortOrder . queryname )
2010-09-12 22:02:43 +08:00
throw new UserException . MissortedBAM ( SAMFileHeader . SortOrder . queryname , "Read pair walkers can only walk over query name-sorted data. Please resort your input BAM file." ) ;
2010-03-22 07:22:25 +08:00
if ( intervals ! = null & & ! intervals . isEmpty ( ) )
2010-09-12 22:02:43 +08:00
throw new UserException . CommandLineException ( "Pairs traversal cannot be used in conjunction with intervals." ) ;
2010-03-22 07:22:25 +08:00
shardStrategy = ShardStrategyFactory . shatter ( readsDataSource ,
2010-06-11 04:10:23 +08:00
referenceDataSource . getReference ( ) ,
2010-03-22 07:22:25 +08:00
ShardStrategyFactory . SHATTER_STRATEGY . READS_EXPERIMENTAL ,
drivingDataSource . getSequenceDictionary ( ) ,
2010-11-11 01:59:50 +08:00
SHARD_SIZE ,
getGenomeLocParser ( ) ) ;
2009-07-30 00:11:45 +08:00
} else
2010-09-12 23:07:38 +08:00
throw new ReviewedStingException ( "Unable to support walker of type" + walker . getClass ( ) . getName ( ) ) ;
2009-07-30 00:11:45 +08:00
return shardStrategy ;
}
2010-09-24 07:28:55 +08:00
@Override
protected boolean flashbackData ( ) {
return walker instanceof ReadWalker ;
2009-07-30 00:11:45 +08:00
}
2009-05-11 10:07:20 +08:00
2009-07-10 06:10:22 +08:00
/ * *
* Initialize the output streams as specified by the user .
*
2009-09-30 06:23:19 +08:00
* @param outputTracker the tracker supplying the initialization data .
2009-07-10 06:10:22 +08:00
* /
2010-09-24 07:28:55 +08:00
private void initializeOutputStreams ( OutputTracker outputTracker ) {
for ( Map . Entry < ArgumentSource , Object > input : getInputs ( ) . entrySet ( ) )
2009-10-06 10:45:31 +08:00
outputTracker . addInput ( input . getKey ( ) , input . getValue ( ) ) ;
2010-09-24 07:28:55 +08:00
for ( Stub < ? > stub : getOutputs ( ) )
2009-08-23 08:56:02 +08:00
outputTracker . addOutput ( stub ) ;
2010-09-25 10:49:30 +08:00
outputTracker . prepareWalker ( walker , getArguments ( ) . strictnessLevel ) ;
2009-05-11 10:07:20 +08:00
}
2010-09-28 10:16:25 +08:00
2009-05-11 10:07:20 +08:00
}