Better support for specifying read filters to apply directly from the walkers.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1212 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
ce08f5f0c3
commit
03e1713988
|
|
@ -50,13 +50,8 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
|
|||
/** the type of analysis to run - switch to the type of analysis */
|
||||
private String analysisName = "SomaticCoverageWalker";
|
||||
|
||||
// our walker manager
|
||||
private WalkerManager walkerManager = null;
|
||||
|
||||
// our genome analysis engine
|
||||
private GenomeAnalysisEngine GATKEngine = null;
|
||||
|
||||
public String pluginPathName = null;
|
||||
private GenomeAnalysisEngine GATKEngine = new GenomeAnalysisEngine();
|
||||
|
||||
// get the analysis name
|
||||
protected abstract String getAnalysisName();
|
||||
|
|
@ -71,17 +66,7 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
|
|||
* @return the return code to exit the program with
|
||||
*/
|
||||
protected int execute() {
|
||||
|
||||
// create the walker
|
||||
Walker<?, ?> mWalker = null;
|
||||
try {
|
||||
mWalker = walkerManager.createWalkerByName(analysisName);
|
||||
} catch (InstantiationException ex) {
|
||||
throw new RuntimeException("Unable to instantiate walker.", ex);
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
throw new RuntimeException("Unable to access walker", ex);
|
||||
}
|
||||
Walker<?,?> mWalker = GATKEngine.getWalkerByName(analysisName);
|
||||
|
||||
// load the arguments into the walkers
|
||||
loadArgumentsIntoObject(argCollection);
|
||||
|
|
@ -93,7 +78,7 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
|
|||
// set the analysis name in the argument collection
|
||||
this.argCollection.analysisName = this.analysisName;
|
||||
try {
|
||||
GATKEngine = new GenomeAnalysisEngine(argCollection, mWalker);
|
||||
GATKEngine.execute(argCollection, mWalker);
|
||||
}
|
||||
catch (ArgumentException ex) {
|
||||
// Rethrow argument exceptions. Let the command-line argument do what it's designed to do.
|
||||
|
|
@ -124,20 +109,9 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
|
|||
*/
|
||||
@Override
|
||||
protected Class[] getArgumentSources() {
|
||||
// get the analysis name from the overriding class
|
||||
analysisName = this.getAnalysisName();
|
||||
|
||||
// get any argument overrides they want to present
|
||||
overrideArguments();
|
||||
// No walker info? No plugins.
|
||||
if (analysisName == null) return new Class[]{};
|
||||
|
||||
walkerManager = new WalkerManager(pluginPathName);
|
||||
|
||||
if (!walkerManager.doesWalkerExist(analysisName))
|
||||
throw new IllegalArgumentException("Invalid analysis name");
|
||||
|
||||
return new Class[]{walkerManager.getWalkerClassByName(analysisName)};
|
||||
if (analysisName == null) return new Class[] {};
|
||||
return new Class[] { GATKEngine.getWalkerByName(analysisName).getClass() };
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.broadinstitute.sting.gatk;
|
||||
|
||||
import org.broadinstitute.sting.gatk.walkers.Walker;
|
||||
import org.broadinstitute.sting.gatk.traversals.TraversalEngine;
|
||||
import org.broadinstitute.sting.utils.StingException;
|
||||
import org.broadinstitute.sting.utils.xReadLines;
|
||||
import org.broadinstitute.sting.utils.cmdLine.*;
|
||||
|
|
@ -49,14 +48,8 @@ public class CommandLineGATK extends CommandLineProgram {
|
|||
@ArgumentCollection // our argument collection, the collection of command line args we accept
|
||||
public GATKArgumentCollection argCollection = new GATKArgumentCollection();
|
||||
|
||||
public String pluginPathName = null;
|
||||
|
||||
// our genome analysis engine
|
||||
GenomeAnalysisEngine GATKEngine = null;
|
||||
|
||||
// our walker manager
|
||||
private WalkerManager walkerManager = null;
|
||||
|
||||
/** our genome analysis engine */
|
||||
GenomeAnalysisEngine GATKEngine = new GenomeAnalysisEngine();
|
||||
|
||||
/** Required main method implementation. */
|
||||
public static void main(String[] argv) {
|
||||
|
|
@ -68,7 +61,6 @@ public class CommandLineGATK extends CommandLineProgram {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* this is the function that the inheriting class can expect to have called
|
||||
* when the command line system has initialized.
|
||||
|
|
@ -76,15 +68,8 @@ public class CommandLineGATK extends CommandLineProgram {
|
|||
* @return the return code to exit the program with
|
||||
*/
|
||||
protected int execute() {
|
||||
Walker<?, ?> mWalker = null;
|
||||
try {
|
||||
mWalker = walkerManager.createWalkerByName(analysisName);
|
||||
} catch (InstantiationException ex) {
|
||||
throw new RuntimeException("Unable to instantiate walker.", ex);
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
throw new RuntimeException("Unable to access walker", ex);
|
||||
}
|
||||
Walker<?,?> mWalker = GATKEngine.getWalkerByName(analysisName);
|
||||
|
||||
loadArgumentsIntoObject(argCollection);
|
||||
loadArgumentsIntoObject(mWalker);
|
||||
|
||||
|
|
@ -92,11 +77,11 @@ public class CommandLineGATK extends CommandLineProgram {
|
|||
|
||||
this.argCollection.analysisName = this.analysisName;
|
||||
try {
|
||||
GATKEngine = new GenomeAnalysisEngine(argCollection, mWalker);
|
||||
GATKEngine.execute(argCollection, mWalker);
|
||||
}
|
||||
catch (ArgumentException ex) {
|
||||
// Rethrow argument exceptions. Let the command-line argument do what it's designed to do.
|
||||
throw ex;
|
||||
throw ex;
|
||||
}
|
||||
catch (StingException exp) {
|
||||
System.err.println("Caught StingException. It's message is " + exp.getMessage());
|
||||
|
|
@ -125,13 +110,7 @@ public class CommandLineGATK extends CommandLineProgram {
|
|||
protected Class[] getArgumentSources() {
|
||||
// No walker info? No plugins.
|
||||
if (analysisName == null) return new Class[] {};
|
||||
|
||||
walkerManager = new WalkerManager(pluginPathName);
|
||||
|
||||
if (!walkerManager.doesWalkerExist(analysisName))
|
||||
throw new IllegalArgumentException("Invalid analysis name");
|
||||
|
||||
return new Class[]{walkerManager.getWalkerClassByName(analysisName)};
|
||||
return new Class[] { GATKEngine.getWalkerByName(analysisName).getClass() };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -27,12 +27,14 @@ package org.broadinstitute.sting.gatk;
|
|||
|
||||
import net.sf.picard.reference.ReferenceSequenceFile;
|
||||
import net.sf.picard.reference.ReferenceSequenceFileFactory;
|
||||
import net.sf.picard.filter.SamRecordFilter;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.broadinstitute.sting.gatk.executive.MicroScheduler;
|
||||
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedData;
|
||||
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum;
|
||||
import org.broadinstitute.sting.gatk.traversals.TraversalEngine;
|
||||
import org.broadinstitute.sting.gatk.walkers.*;
|
||||
import org.broadinstitute.sting.gatk.filters.ZeroMappingQualityReadFilter;
|
||||
import org.broadinstitute.sting.utils.*;
|
||||
import org.broadinstitute.sting.utils.cmdLine.ArgumentException;
|
||||
|
||||
|
|
@ -50,7 +52,7 @@ public class GenomeAnalysisEngine {
|
|||
private TraversalEngine engine = null;
|
||||
|
||||
// our argument collection
|
||||
private final GATKArgumentCollection argCollection;
|
||||
private GATKArgumentCollection argCollection;
|
||||
|
||||
/** Collection of output streams used by the walker. */
|
||||
private OutputTracker outputTracker = null;
|
||||
|
|
@ -58,8 +60,11 @@ public class GenomeAnalysisEngine {
|
|||
/** our log, which we want to capture anything from this class */
|
||||
private static Logger logger = Logger.getLogger(GenomeAnalysisEngine.class);
|
||||
|
||||
/** the return value from our walker */
|
||||
private Object walkerReturn = null;
|
||||
/** our walker manager */
|
||||
private final WalkerManager walkerManager;
|
||||
|
||||
/** plugin path for the walker manager. */
|
||||
public final String pluginPathName = null;
|
||||
|
||||
/**
|
||||
* our constructor, where all the work is done
|
||||
|
|
@ -67,22 +72,31 @@ public class GenomeAnalysisEngine {
|
|||
* legacy traversal types are sent to legacyTraversal function; as we move more of the traversals to the
|
||||
* new MicroScheduler class we'll be able to delete that function.
|
||||
*
|
||||
* @param args the argument collection, where we get all our setup information from
|
||||
* @param my_walker the walker we're running with
|
||||
*/
|
||||
public GenomeAnalysisEngine(GATKArgumentCollection args, Walker my_walker) {
|
||||
public GenomeAnalysisEngine() {
|
||||
// make sure our instance variable points to this analysis engine
|
||||
instance = this;
|
||||
walkerManager = new WalkerManager(pluginPathName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually run the GATK with the specified walker.
|
||||
* @param args the argument collection, where we get all our setup information from
|
||||
* @param my_walker Walker to run over the dataset. Must not be null.
|
||||
*/
|
||||
public Object execute(GATKArgumentCollection args, Walker<?,?> my_walker) {
|
||||
// validate our parameters
|
||||
if (args == null) {
|
||||
throw new StingException("The GATKArgumentCollection passed to GenomeAnalysisEngine can be null.");
|
||||
}
|
||||
|
||||
// validate our parameters
|
||||
if (args == null || my_walker == null) {
|
||||
throw new StingException("Neither the GATKArgumentCollection or the Walker passed to GenomeAnalysisEngine can be null.");
|
||||
}
|
||||
if (my_walker == null)
|
||||
throw new StingException("The walker passed to GenomeAnalysisEngine can be null.");
|
||||
|
||||
// save our argument parameter
|
||||
this.argCollection = args;
|
||||
|
||||
// make sure our instance variable points to this analysis engine
|
||||
instance = this;
|
||||
|
||||
// our reference ordered data collection
|
||||
List<ReferenceOrderedData<? extends ReferenceOrderedDatum>> rods = new ArrayList<ReferenceOrderedData<? extends ReferenceOrderedDatum>>();
|
||||
|
||||
|
|
@ -129,9 +143,26 @@ public class GenomeAnalysisEngine {
|
|||
locs = GenomeLocSortedSet.createSetFromList(parseIntervalRegion(argCollection.intervals));
|
||||
}
|
||||
// excute the microscheduler, storing the results
|
||||
walkerReturn = microScheduler.execute(my_walker, locs, argCollection.maximumEngineIterations);
|
||||
return microScheduler.execute(my_walker, locs, argCollection.maximumEngineIterations);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves an instance of the walker based on the walker name.
|
||||
* @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.
|
||||
*/
|
||||
public Walker<?,?> getWalkerByName( String walkerName ) {
|
||||
try {
|
||||
return walkerManager.createWalkerByName(walkerName);
|
||||
} catch (InstantiationException ex) {
|
||||
throw new StingException("Unable to instantiate walker.", ex);
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
throw new StingException("Unable to access walker", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setup a microscheduler
|
||||
*
|
||||
|
|
@ -147,12 +178,12 @@ public class GenomeAnalysisEngine {
|
|||
// we need to verify different parameter based on the walker type
|
||||
if (my_walker instanceof LocusWalker || my_walker instanceof LocusWindowWalker) {
|
||||
// create the MicroScheduler
|
||||
microScheduler = MicroScheduler.create(my_walker, extractSourceInfoFromArguments(argCollection), argCollection.referenceFile, rods, argCollection.numberOfThreads);
|
||||
microScheduler = MicroScheduler.create(my_walker, extractSourceInfo(my_walker,argCollection), argCollection.referenceFile, rods, argCollection.numberOfThreads);
|
||||
engine = microScheduler.getTraversalEngine();
|
||||
} else if (my_walker instanceof ReadWalker || my_walker instanceof DuplicateWalker) {
|
||||
if (argCollection.referenceFile == null)
|
||||
Utils.scareUser(String.format("Read-based traversals require a reference file but none was given"));
|
||||
microScheduler = MicroScheduler.create(my_walker, extractSourceInfoFromArguments(argCollection), argCollection.referenceFile, rods, argCollection.numberOfThreads);
|
||||
microScheduler = MicroScheduler.create(my_walker, extractSourceInfo(my_walker,argCollection), argCollection.referenceFile, rods, argCollection.numberOfThreads);
|
||||
engine = microScheduler.getTraversalEngine();
|
||||
} else {
|
||||
Utils.scareUser(String.format("Unable to create the appropriate TraversalEngine for analysis type " + argCollection.analysisName));
|
||||
|
|
@ -191,18 +222,24 @@ public class GenomeAnalysisEngine {
|
|||
/**
|
||||
* Bundles all the source information about the reads into a unified data structure.
|
||||
*
|
||||
* @param walker The walker for which to extract info.
|
||||
* @param argCollection The collection of arguments passed to the engine.
|
||||
*
|
||||
* @return The reads object providing reads source info.
|
||||
*/
|
||||
private Reads extractSourceInfo( Walker walker, GATKArgumentCollection argCollection ) {
|
||||
List<SamRecordFilter> filters = new ArrayList<SamRecordFilter>();
|
||||
|
||||
private Reads extractSourceInfoFromArguments(GATKArgumentCollection argCollection) {
|
||||
return new Reads(argCollection.samFiles,
|
||||
argCollection.strictnessLevel,
|
||||
argCollection.downsampleFraction,
|
||||
argCollection.downsampleCoverage,
|
||||
!argCollection.unsafe,
|
||||
argCollection.filterZeroMappingQualityReads);
|
||||
filters.addAll( WalkerManager.getReadFilters(walker) );
|
||||
if( argCollection.filterZeroMappingQualityReads != null && argCollection.filterZeroMappingQualityReads )
|
||||
filters.add( new ZeroMappingQualityReadFilter() );
|
||||
|
||||
return new Reads( argCollection.samFiles,
|
||||
argCollection.strictnessLevel,
|
||||
argCollection.downsampleFraction,
|
||||
argCollection.downsampleCoverage,
|
||||
!argCollection.unsafe,
|
||||
filters );
|
||||
}
|
||||
|
||||
private void validateInputsAgainstWalker(Walker walker,
|
||||
|
|
@ -297,14 +334,4 @@ public class GenomeAnalysisEngine {
|
|||
public GATKArgumentCollection getArguments() {
|
||||
return this.argCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get's the return value of the walker
|
||||
*
|
||||
* @return an Object representing the return value of the walker
|
||||
*/
|
||||
public Object getWalkerReturn() {
|
||||
return walkerReturn;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
package org.broadinstitute.sting.gatk;
|
||||
|
||||
import org.broadinstitute.sting.gatk.traversals.TraversalEngine;
|
||||
import org.broadinstitute.sting.utils.StingException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.sf.samtools.SAMFileReader;
|
||||
import net.sf.picard.filter.SamRecordFilter;
|
||||
/**
|
||||
* User: hanna
|
||||
* Date: May 14, 2009
|
||||
|
|
@ -31,7 +29,7 @@ public class Reads {
|
|||
private Double downsamplingFraction = null;
|
||||
private Integer downsampleToCoverage = null;
|
||||
private Boolean beSafe = null;
|
||||
private Boolean filterZeroMappingQualityReads = null;
|
||||
private List<SamRecordFilter> supplementalFilters = null;
|
||||
|
||||
/**
|
||||
* Gets a list of the files acting as sources of reads.
|
||||
|
|
@ -73,8 +71,8 @@ public class Reads {
|
|||
return beSafe;
|
||||
}
|
||||
|
||||
public Boolean getFilterZeroMappingQualityReads() {
|
||||
return filterZeroMappingQualityReads;
|
||||
public List<SamRecordFilter> getSupplementalFilters() {
|
||||
return supplementalFilters;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -83,6 +81,7 @@ public class Reads {
|
|||
*/
|
||||
public Reads( List<File> readsFiles ) {
|
||||
this.readsFiles = readsFiles;
|
||||
this.supplementalFilters = new ArrayList<SamRecordFilter>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -94,19 +93,19 @@ public class Reads {
|
|||
* @param downsampleFraction fraction of reads to downsample.
|
||||
* @param downsampleCoverage downsampling per-locus.
|
||||
* @param beSafe Whether to enable safety checking.
|
||||
* @param filterZeroMappingQualityReads whether to filter zero mapping quality reads.
|
||||
* @param supplementalFilters additional filters to dynamically apply.
|
||||
*/
|
||||
Reads( List<File> samFiles,
|
||||
SAMFileReader.ValidationStringency strictness,
|
||||
Double downsampleFraction,
|
||||
Integer downsampleCoverage,
|
||||
Boolean beSafe,
|
||||
Boolean filterZeroMappingQualityReads ) {
|
||||
List<SamRecordFilter> supplementalFilters ) {
|
||||
this.readsFiles = samFiles;
|
||||
this.validationStringency = strictness;
|
||||
this.downsamplingFraction = downsampleFraction;
|
||||
this.downsampleToCoverage = downsampleCoverage;
|
||||
this.beSafe = beSafe;
|
||||
this.filterZeroMappingQualityReads = filterZeroMappingQualityReads;
|
||||
this.supplementalFilters = supplementalFilters;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,19 +8,14 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.broadinstitute.sting.gatk.walkers.Walker;
|
||||
import org.broadinstitute.sting.gatk.walkers.WalkerName;
|
||||
import org.broadinstitute.sting.gatk.walkers.DataSource;
|
||||
import org.broadinstitute.sting.gatk.walkers.By;
|
||||
import org.broadinstitute.sting.gatk.walkers.Allows;
|
||||
import org.broadinstitute.sting.gatk.walkers.Requires;
|
||||
import org.broadinstitute.sting.gatk.walkers.RMD;
|
||||
import org.broadinstitute.sting.gatk.walkers.*;
|
||||
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum;
|
||||
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedData;
|
||||
import org.broadinstitute.sting.utils.JVMUtils;
|
||||
import org.broadinstitute.sting.utils.PathUtils;
|
||||
import org.broadinstitute.sting.utils.StingException;
|
||||
import org.apache.log4j.Logger;
|
||||
import net.sf.picard.filter.SamRecordFilter;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
|
|
@ -185,6 +180,30 @@ public class WalkerManager {
|
|||
return Arrays.asList(requiresDataSource.referenceMetaData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts filters that the walker has requested be run on the dataset.
|
||||
* @param walker Walker to inspect for filtering requests.
|
||||
* @return A non-empty list of filters to apply to the reads.
|
||||
*/
|
||||
public static List<SamRecordFilter> getReadFilters(Walker walker) {
|
||||
Class<? extends SamRecordFilter>[] filterTypes = getReadFilterTypes(walker);
|
||||
List<SamRecordFilter> filters = new ArrayList<SamRecordFilter>();
|
||||
|
||||
for( Class<? extends SamRecordFilter> filterType: filterTypes ) {
|
||||
try {
|
||||
filters.add(filterType.newInstance());
|
||||
}
|
||||
catch( InstantiationException ex ) {
|
||||
throw new StingException("Unable to instantiate filter: " + filterType, ex);
|
||||
}
|
||||
catch( IllegalAccessException ex ) {
|
||||
throw new StingException("Unable to access filter: " + filterType, ex);
|
||||
}
|
||||
}
|
||||
|
||||
return filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load classes internal to the classpath from an arbitrary location.
|
||||
*
|
||||
|
|
@ -280,4 +299,16 @@ public class WalkerManager {
|
|||
Allows allowsDataSource = walkerClass.getAnnotation(Allows.class);
|
||||
return allowsDataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of filtering classes specified as walker annotations.
|
||||
* @param walker The walker to inspect.
|
||||
* @return An array of types extending from SamRecordFilter. Will never be null.
|
||||
*/
|
||||
private static Class<? extends SamRecordFilter>[] getReadFilterTypes(Walker walker) {
|
||||
Class<? extends Walker> walkerClass = walker.getClass();
|
||||
if( !walkerClass.isAnnotationPresent(ReadFilters.class) )
|
||||
return new Class[0];
|
||||
return walkerClass.getAnnotation(ReadFilters.class).value();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import org.broadinstitute.sting.utils.GenomeLocParser;
|
|||
import org.broadinstitute.sting.utils.sam.SAMReadViolationHistogram;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 The Broad Institute
|
||||
|
|
@ -133,15 +134,15 @@ public class SAMDataSource implements SimpleDataSource {
|
|||
iterator = applyDecoratingIterators(true,
|
||||
iterator,
|
||||
reads.getDownsamplingFraction(),
|
||||
reads.getFilterZeroMappingQualityReads(),
|
||||
reads.getSafetyChecking());
|
||||
reads.getSafetyChecking(),
|
||||
reads.getSupplementalFilters());
|
||||
} else if (shard.getShardType() == Shard.ShardType.LOCUS || shard.getShardType() == Shard.ShardType.INTERVAL) {
|
||||
iterator = seekLocus(shard.getGenomeLoc());
|
||||
iterator = applyDecoratingIterators(false,
|
||||
iterator,
|
||||
reads.getDownsamplingFraction(),
|
||||
reads.getFilterZeroMappingQualityReads(),
|
||||
reads.getSafetyChecking());
|
||||
reads.getSafetyChecking(),
|
||||
reads.getSupplementalFilters());
|
||||
} else {
|
||||
throw new StingException("seek: Unknown shard type");
|
||||
}
|
||||
|
|
@ -362,15 +363,15 @@ public class SAMDataSource implements SimpleDataSource {
|
|||
* @param enableVerification Verify the order of reads.
|
||||
* @param wrappedIterator the raw data source.
|
||||
* @param downsamplingFraction whether and how much to downsample the reads themselves (not at a locus).
|
||||
* @param filterZeroMappingQualityReads whether to filter zero mapping quality reads.
|
||||
* @param beSafeP Another trigger for the verifying iterator? TODO: look into this.
|
||||
* @param supplementalFilters additional filters to apply to the reads.
|
||||
* @return An iterator wrapped with filters reflecting the passed-in parameters. Will not be null.
|
||||
*/
|
||||
private StingSAMIterator applyDecoratingIterators(boolean enableVerification,
|
||||
StingSAMIterator wrappedIterator,
|
||||
Double downsamplingFraction,
|
||||
Boolean filterZeroMappingQualityReads,
|
||||
Boolean beSafeP) {
|
||||
Boolean beSafeP,
|
||||
List<SamRecordFilter> supplementalFilters) {
|
||||
// NOTE: this (and other filtering) should be done before on-the-fly sorting
|
||||
// as there is no reason to sort something that we will end of throwing away
|
||||
if (downsamplingFraction != null)
|
||||
|
|
@ -379,19 +380,12 @@ public class SAMDataSource implements SimpleDataSource {
|
|||
if (beSafeP != null && beSafeP && enableVerification)
|
||||
wrappedIterator = new VerifyingSamIterator(wrappedIterator);
|
||||
|
||||
if ( filterZeroMappingQualityReads != null && filterZeroMappingQualityReads )
|
||||
for( SamRecordFilter supplementalFilter: supplementalFilters )
|
||||
wrappedIterator = StingSAMIteratorAdapter.adapt(wrappedIterator.getSourceInfo(),
|
||||
new FilteringIterator(wrappedIterator, new ZeroMappingQualityReadFilterFunc()));
|
||||
new FilteringIterator(wrappedIterator,supplementalFilter));
|
||||
|
||||
return wrappedIterator;
|
||||
}
|
||||
|
||||
private static class ZeroMappingQualityReadFilterFunc implements SamRecordFilter {
|
||||
public boolean filterOut(SAMRecord rec) {
|
||||
return (rec.getMappingQuality() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2009 The Broad Institute
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* 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:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* 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
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.sting.gatk.filters;
|
||||
|
||||
import net.sf.picard.filter.SamRecordFilter;
|
||||
import net.sf.samtools.SAMRecord;
|
||||
|
||||
/**
|
||||
* Filter out zero mapping quality reads.
|
||||
*
|
||||
* @author hanna
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
public class ZeroMappingQualityReadFilter implements SamRecordFilter {
|
||||
public boolean filterOut(SAMRecord rec) {
|
||||
return (rec.getMappingQuality() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<!--
|
||||
~ Copyright (c) 2009 The Broad Institute
|
||||
~ Permission is hereby granted, free of charge, to any person
|
||||
~ obtaining a copy of this software and associated documentation
|
||||
~ files (the "Software"), to deal in the Software without
|
||||
~ 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:
|
||||
~
|
||||
~ The above copyright notice and this permission notice shall be
|
||||
~ included in all copies or substantial portions of the Software.
|
||||
~
|
||||
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
~ 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
|
||||
~ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
~ OTHER DEALINGS IN THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
Provides a commonly used set of filters for determining which data should and should not be applied.
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
package org.broadinstitute.sting.gatk.walkers;
|
||||
|
||||
import org.broadinstitute.sting.gatk.LocusContext;
|
||||
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum;
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.sf.samtools.SAMRecord;
|
||||
|
||||
|
|
@ -17,8 +15,8 @@ import net.sf.samtools.SAMRecord;
|
|||
* Time: 11:23:14 AM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class PrintLocusContextWalker extends LocusWindowWalker<LocusContext, Integer> implements TreeReducible<Integer> {
|
||||
public LocusContext map(RefMetaDataTracker tracker, String ref, LocusContext context) {
|
||||
public class PrintLocusContextWalker extends LocusWalker<LocusContext, Integer> implements TreeReducible<Integer> {
|
||||
public LocusContext map(RefMetaDataTracker tracker, char ref, LocusContext context) {
|
||||
out.printf( "In map: ref = %s, loc = %s, reads = %s%n", ref,
|
||||
context.getLocation(),
|
||||
Arrays.deepToString( getReadNames(context.getReads()) ) );
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package org.broadinstitute.sting.gatk.walkers;
|
||||
|
||||
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
/**
|
||||
* User: hanna
|
||||
* Date: May 19, 2009
|
||||
|
|
@ -17,7 +19,10 @@ import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum;
|
|||
/**
|
||||
* A data type representing reference-ordered data.
|
||||
*/
|
||||
|
||||
@Documented
|
||||
@Inherited
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface RMD {
|
||||
String name();
|
||||
Class<? extends ReferenceOrderedDatum> type();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2009 The Broad Institute
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* 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:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* 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
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.sting.gatk.walkers;
|
||||
|
||||
import net.sf.picard.filter.SamRecordFilter;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* An annotation to describe what kind of data will be filtered out.
|
||||
*
|
||||
* @author hanna
|
||||
* @version 0.1
|
||||
*/
|
||||
@Documented
|
||||
@Inherited
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface ReadFilters {
|
||||
public Class<? extends SamRecordFilter>[] value() default {};
|
||||
}
|
||||
|
|
@ -3,8 +3,10 @@ package org.broadinstitute.sting.playground.gatk.walkers;
|
|||
import net.sf.samtools.SAMReadGroupRecord;
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import org.broadinstitute.sting.gatk.LocusContext;
|
||||
import org.broadinstitute.sting.gatk.filters.ZeroMappingQualityReadFilter;
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
|
||||
import org.broadinstitute.sting.gatk.walkers.ReadFilters;
|
||||
import org.broadinstitute.sting.playground.utils.AlleleFrequencyEstimate;
|
||||
import org.broadinstitute.sting.playground.utils.AlleleMetrics;
|
||||
import org.broadinstitute.sting.playground.utils.GenotypeLikelihoods;
|
||||
|
|
@ -20,6 +22,7 @@ import java.io.FileNotFoundException;
|
|||
import java.io.PrintStream;
|
||||
import java.util.List;
|
||||
|
||||
@ReadFilters(ZeroMappingQualityReadFilter.class)
|
||||
public class SingleSampleGenotyper extends LocusWalker<AlleleFrequencyEstimate, String> {
|
||||
// Control output settings
|
||||
@Argument(fullName="variants_out", shortName="varout", doc="File to which variants should be written", required=true) public File VARIANTS_FILE;
|
||||
|
|
|
|||
|
|
@ -151,6 +151,11 @@ public abstract class CommandLineProgram {
|
|||
return null;
|
||||
}
|
||||
|
||||
static {
|
||||
// setup a basic log configuration
|
||||
BasicConfigurator.configure();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called to start processing the command line, and kick
|
||||
* off the execute message of the program.
|
||||
|
|
@ -161,9 +166,6 @@ public abstract class CommandLineProgram {
|
|||
public static void start(CommandLineProgram clp, String[] args) {
|
||||
|
||||
try {
|
||||
// setup a basic log configuration
|
||||
BasicConfigurator.configure();
|
||||
|
||||
// setup our log layout
|
||||
PatternLayout layout = new PatternLayout();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue