diff --git a/java/src/org/broadinstitute/sting/gatk/CommandLineExecutable.java b/java/src/org/broadinstitute/sting/gatk/CommandLineExecutable.java index e7f26505c..d7fac7217 100644 --- a/java/src/org/broadinstitute/sting/gatk/CommandLineExecutable.java +++ b/java/src/org/broadinstitute/sting/gatk/CommandLineExecutable.java @@ -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() }; } diff --git a/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java b/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java index 4ac1f2ac6..39a7e1bd6 100755 --- a/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java +++ b/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java @@ -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 diff --git a/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java b/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java index 2688699a6..8422659d6 100755 --- a/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java +++ b/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java @@ -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> rods = new ArrayList>(); @@ -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 filters = new ArrayList(); - 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; - } - } diff --git a/java/src/org/broadinstitute/sting/gatk/Reads.java b/java/src/org/broadinstitute/sting/gatk/Reads.java index 54ad4f429..89c89fe44 100755 --- a/java/src/org/broadinstitute/sting/gatk/Reads.java +++ b/java/src/org/broadinstitute/sting/gatk/Reads.java @@ -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 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 getSupplementalFilters() { + return supplementalFilters; } /** @@ -83,6 +81,7 @@ public class Reads { */ public Reads( List readsFiles ) { this.readsFiles = readsFiles; + this.supplementalFilters = new ArrayList(); } /** @@ -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 samFiles, SAMFileReader.ValidationStringency strictness, Double downsampleFraction, Integer downsampleCoverage, Boolean beSafe, - Boolean filterZeroMappingQualityReads ) { + List supplementalFilters ) { this.readsFiles = samFiles; this.validationStringency = strictness; this.downsamplingFraction = downsampleFraction; this.downsampleToCoverage = downsampleCoverage; this.beSafe = beSafe; - this.filterZeroMappingQualityReads = filterZeroMappingQualityReads; + this.supplementalFilters = supplementalFilters; } } diff --git a/java/src/org/broadinstitute/sting/gatk/WalkerManager.java b/java/src/org/broadinstitute/sting/gatk/WalkerManager.java index 3331dabe1..d979017f7 100755 --- a/java/src/org/broadinstitute/sting/gatk/WalkerManager.java +++ b/java/src/org/broadinstitute/sting/gatk/WalkerManager.java @@ -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 getReadFilters(Walker walker) { + Class[] filterTypes = getReadFilterTypes(walker); + List filters = new ArrayList(); + + for( Class 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[] getReadFilterTypes(Walker walker) { + Class walkerClass = walker.getClass(); + if( !walkerClass.isAnnotationPresent(ReadFilters.class) ) + return new Class[0]; + return walkerClass.getAnnotation(ReadFilters.class).value(); + } } diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/SAMDataSource.java b/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/SAMDataSource.java index 8c572d197..61781c0c6 100755 --- a/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/SAMDataSource.java +++ b/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/SAMDataSource.java @@ -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 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); - } - } - } diff --git a/java/src/org/broadinstitute/sting/gatk/filters/ZeroMappingQualityReadFilter.java b/java/src/org/broadinstitute/sting/gatk/filters/ZeroMappingQualityReadFilter.java new file mode 100644 index 000000000..311d83cd0 --- /dev/null +++ b/java/src/org/broadinstitute/sting/gatk/filters/ZeroMappingQualityReadFilter.java @@ -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); + } +} + diff --git a/java/src/org/broadinstitute/sting/gatk/filters/package.html b/java/src/org/broadinstitute/sting/gatk/filters/package.html new file mode 100644 index 000000000..a2519a659 --- /dev/null +++ b/java/src/org/broadinstitute/sting/gatk/filters/package.html @@ -0,0 +1,34 @@ + + + + + + + + +Provides a commonly used set of filters for determining which data should and should not be applied. + + \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/PrintLocusContextWalker.java b/java/src/org/broadinstitute/sting/gatk/walkers/PrintLocusContextWalker.java index 5f909db25..8d630d4d0 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/PrintLocusContextWalker.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/PrintLocusContextWalker.java @@ -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 implements TreeReducible { - public LocusContext map(RefMetaDataTracker tracker, String ref, LocusContext context) { +public class PrintLocusContextWalker extends LocusWalker implements TreeReducible { + 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()) ) ); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/RMD.java b/java/src/org/broadinstitute/sting/gatk/walkers/RMD.java index f89f886e4..db5e21d6d 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/RMD.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/RMD.java @@ -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 type(); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/ReadFilters.java b/java/src/org/broadinstitute/sting/gatk/walkers/ReadFilters.java new file mode 100644 index 000000000..ff3b6d82f --- /dev/null +++ b/java/src/org/broadinstitute/sting/gatk/walkers/ReadFilters.java @@ -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[] value() default {}; +} diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/SingleSampleGenotyper.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/SingleSampleGenotyper.java index a9771cce0..ee7a0dc1c 100644 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/SingleSampleGenotyper.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/SingleSampleGenotyper.java @@ -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 { // Control output settings @Argument(fullName="variants_out", shortName="varout", doc="File to which variants should be written", required=true) public File VARIANTS_FILE; diff --git a/java/src/org/broadinstitute/sting/utils/cmdLine/CommandLineProgram.java b/java/src/org/broadinstitute/sting/utils/cmdLine/CommandLineProgram.java index 57f56a0f9..34f16ed05 100644 --- a/java/src/org/broadinstitute/sting/utils/cmdLine/CommandLineProgram.java +++ b/java/src/org/broadinstitute/sting/utils/cmdLine/CommandLineProgram.java @@ -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();