Some refactoring that Mauricio and I worked through together. Changed filters
to extend from org.broadinstitute.sting.gatk.filters.ReadFilter rather than directly from net.sf.picard.filter.SamRecordFilter, which allows us to add an initialize(GATKEngine) method so that filters can do any initialization they'd like based on CL arguments, SAM headers, etc. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5760 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
b66c6dced1
commit
5c6965575e
|
|
@ -30,6 +30,7 @@ import org.broadinstitute.sting.gatk.arguments.GATKArgumentCollection;
|
|||
import org.broadinstitute.sting.commandline.CommandLineProgram;
|
||||
import org.broadinstitute.sting.commandline.ArgumentTypeDescriptor;
|
||||
import org.broadinstitute.sting.gatk.datasources.reads.SAMReaderID;
|
||||
import org.broadinstitute.sting.gatk.filters.ReadFilter;
|
||||
import org.broadinstitute.sting.gatk.io.stubs.OutputStreamArgumentTypeDescriptor;
|
||||
import org.broadinstitute.sting.gatk.io.stubs.SAMFileReaderArgumentTypeDescriptor;
|
||||
import org.broadinstitute.sting.gatk.io.stubs.SAMFileWriterArgumentTypeDescriptor;
|
||||
|
|
@ -98,7 +99,7 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
|
|||
engine.setWalker(walker);
|
||||
walker.setToolkit(engine);
|
||||
|
||||
Collection<SamRecordFilter> filters = engine.createFilters();
|
||||
Collection<ReadFilter> filters = engine.createFilters();
|
||||
engine.setFilters(filters);
|
||||
|
||||
// load the arguments into the walker / filters.
|
||||
|
|
@ -108,7 +109,7 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
|
|||
loadArgumentsIntoObject(walker);
|
||||
argumentSources.add(walker);
|
||||
|
||||
for (SamRecordFilter filter: filters) {
|
||||
for (ReadFilter filter: filters) {
|
||||
loadArgumentsIntoObject(filter);
|
||||
argumentSources.add(filter);
|
||||
}
|
||||
|
|
@ -186,8 +187,8 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
|
|||
walker.setToolkit(engine);
|
||||
argumentSources.add(walker.getClass());
|
||||
|
||||
Collection<SamRecordFilter> filters = engine.createFilters();
|
||||
for(SamRecordFilter filter: filters)
|
||||
Collection<ReadFilter> filters = engine.createFilters();
|
||||
for(ReadFilter filter: filters)
|
||||
argumentSources.add(filter.getClass());
|
||||
|
||||
Class[] argumentSourcesAsArray = new Class[argumentSources.size()];
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ import org.broadinstitute.sting.gatk.datasources.reads.ShardStrategyFactory;
|
|||
import org.broadinstitute.sting.gatk.datasources.reads.SAMDataSource;
|
||||
import org.broadinstitute.sting.gatk.executive.MicroScheduler;
|
||||
import org.broadinstitute.sting.gatk.filters.FilterManager;
|
||||
import org.broadinstitute.sting.gatk.filters.ReadFilter;
|
||||
import org.broadinstitute.sting.gatk.filters.ReadGroupBlackListFilter;
|
||||
import org.broadinstitute.sting.gatk.filters.SamRecordHeaderFilter;
|
||||
import org.broadinstitute.sting.gatk.io.OutputTracker;
|
||||
import org.broadinstitute.sting.gatk.io.stubs.Stub;
|
||||
import org.broadinstitute.sting.gatk.refdata.tracks.RMDTrack;
|
||||
|
|
@ -65,7 +65,6 @@ import org.broadinstitute.sting.utils.SequenceDictionaryUtils;
|
|||
import org.broadinstitute.sting.utils.baq.BAQ;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.interval.IntervalMergingRule;
|
||||
import org.broadinstitute.sting.utils.interval.IntervalUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -139,7 +138,7 @@ public class GenomeAnalysisEngine {
|
|||
/**
|
||||
* Collection of the filters applied to the input data.
|
||||
*/
|
||||
private Collection<SamRecordFilter> filters;
|
||||
private Collection<ReadFilter> filters;
|
||||
|
||||
/**
|
||||
* A currently hacky unique name for this GATK instance
|
||||
|
|
@ -269,8 +268,8 @@ public class GenomeAnalysisEngine {
|
|||
* the caller must handle that directly.
|
||||
* @return A collection of available filters.
|
||||
*/
|
||||
public Collection<SamRecordFilter> createFilters() {
|
||||
Set<SamRecordFilter> filters = new HashSet<SamRecordFilter>();
|
||||
public Collection<ReadFilter> createFilters() {
|
||||
Set<ReadFilter> filters = new HashSet<ReadFilter>();
|
||||
filters.addAll(WalkerManager.getReadFilters(walker,this.getFilterManager()));
|
||||
if (this.getArguments().readGroupBlackList != null && this.getArguments().readGroupBlackList.size() > 0)
|
||||
filters.add(new ReadGroupBlackListFilter(this.getArguments().readGroupBlackList));
|
||||
|
|
@ -733,9 +732,8 @@ public class GenomeAnalysisEngine {
|
|||
|
||||
sampleDataSource = new SampleDataSource(getSAMFileHeader(), argCollection.sampleFiles);
|
||||
|
||||
for (SamRecordFilter filter : filters)
|
||||
if (filter instanceof SamRecordHeaderFilter)
|
||||
((SamRecordHeaderFilter)filter).setHeader(this.getSAMFileHeader());
|
||||
for (ReadFilter filter : filters)
|
||||
filter.initialize(this);
|
||||
|
||||
sampleDataSource = new SampleDataSource(getSAMFileHeader(), argCollection.sampleFiles);
|
||||
|
||||
|
|
@ -1020,7 +1018,7 @@ public class GenomeAnalysisEngine {
|
|||
* Gets the list of filters employed by this engine.
|
||||
* @return Collection of filters (actual instances) used by this engine.
|
||||
*/
|
||||
public Collection<SamRecordFilter> getFilters() {
|
||||
public Collection<ReadFilter> getFilters() {
|
||||
return this.filters;
|
||||
}
|
||||
|
||||
|
|
@ -1028,7 +1026,7 @@ public class GenomeAnalysisEngine {
|
|||
* Sets the list of filters employed by this engine.
|
||||
* @param filters Collection of filters (actual instances) used by this engine.
|
||||
*/
|
||||
public void setFilters(Collection<SamRecordFilter> filters) {
|
||||
public void setFilters(Collection<ReadFilter> filters) {
|
||||
this.filters = filters;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import net.sf.samtools.SAMFileHeader;
|
|||
import net.sf.samtools.SAMFileReader;
|
||||
import org.broadinstitute.sting.gatk.arguments.ValidationExclusion;
|
||||
import org.broadinstitute.sting.gatk.datasources.reads.SAMReaderID;
|
||||
import org.broadinstitute.sting.gatk.filters.ReadFilter;
|
||||
import org.broadinstitute.sting.utils.baq.BAQ;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
@ -33,7 +34,7 @@ public class ReadProperties {
|
|||
private Integer readBufferSize = null;
|
||||
private DownsamplingMethod downsamplingMethod = null;
|
||||
private ValidationExclusion exclusionList = null;
|
||||
private Collection<SamRecordFilter> supplementalFilters = null;
|
||||
private Collection<ReadFilter> supplementalFilters = null;
|
||||
private boolean includeReadsWithDeletionAtLoci = false;
|
||||
private boolean useOriginalBaseQualities = false;
|
||||
private boolean generateExtendedEvents = false;
|
||||
|
|
@ -115,7 +116,7 @@ public class ReadProperties {
|
|||
return exclusionList;
|
||||
}
|
||||
|
||||
public Collection<SamRecordFilter> getSupplementalFilters() {
|
||||
public Collection<ReadFilter> getSupplementalFilters() {
|
||||
return supplementalFilters;
|
||||
}
|
||||
|
||||
|
|
@ -172,7 +173,7 @@ public class ReadProperties {
|
|||
Integer readBufferSize,
|
||||
DownsamplingMethod downsamplingMethod,
|
||||
ValidationExclusion exclusionList,
|
||||
Collection<SamRecordFilter> supplementalFilters,
|
||||
Collection<ReadFilter> supplementalFilters,
|
||||
boolean includeReadsWithDeletionAtLoci,
|
||||
boolean generateExtendedEvents,
|
||||
BAQ.CalculationMode cmode,
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import net.sf.picard.filter.SamRecordFilter;
|
|||
import org.broadinstitute.sting.commandline.Hidden;
|
||||
import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource;
|
||||
import org.broadinstitute.sting.gatk.filters.FilterManager;
|
||||
import org.broadinstitute.sting.gatk.filters.ReadFilter;
|
||||
import org.broadinstitute.sting.gatk.walkers.*;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.classloader.PluginManager;
|
||||
|
|
@ -322,9 +323,9 @@ public class WalkerManager extends PluginManager<Walker> {
|
|||
* @param filterManager Manages the creation of filters.
|
||||
* @return A non-empty list of filters to apply to the reads.
|
||||
*/
|
||||
public static List<SamRecordFilter> getReadFilters(Class<? extends Walker> walkerClass, FilterManager filterManager) {
|
||||
List<SamRecordFilter> filters = new ArrayList<SamRecordFilter>();
|
||||
for(Class<? extends SamRecordFilter> filterType: getReadFilterTypes(walkerClass))
|
||||
public static List<ReadFilter> getReadFilters(Class<? extends Walker> walkerClass, FilterManager filterManager) {
|
||||
List<ReadFilter> filters = new ArrayList<ReadFilter>();
|
||||
for(Class<? extends ReadFilter> filterType: getReadFilterTypes(walkerClass))
|
||||
filters.add(filterManager.createFilterByType(filterType));
|
||||
return filters;
|
||||
}
|
||||
|
|
@ -335,7 +336,7 @@ public class WalkerManager extends PluginManager<Walker> {
|
|||
* @param filterManager Manages the creation of filters.
|
||||
* @return A non-empty list of filters to apply to the reads.
|
||||
*/
|
||||
public static List<SamRecordFilter> getReadFilters(Walker walker, FilterManager filterManager) {
|
||||
public static List<ReadFilter> getReadFilters(Walker walker, FilterManager filterManager) {
|
||||
return getReadFilters(walker.getClass(), filterManager);
|
||||
}
|
||||
|
||||
|
|
@ -444,8 +445,8 @@ public class WalkerManager extends PluginManager<Walker> {
|
|||
* @param walkerClass Class of the walker to inspect.
|
||||
* @return An array of types extending from SamRecordFilter. Will never be null.
|
||||
*/
|
||||
public static Collection<Class<? extends SamRecordFilter>> getReadFilterTypes(Class<?> walkerClass) {
|
||||
List<Class<? extends SamRecordFilter>> filterTypes = new ArrayList<Class<? extends SamRecordFilter>>();
|
||||
public static Collection<Class<? extends ReadFilter>> getReadFilterTypes(Class<?> walkerClass) {
|
||||
List<Class<? extends ReadFilter>> filterTypes = new ArrayList<Class<? extends ReadFilter>>();
|
||||
while(walkerClass != null) {
|
||||
if(walkerClass.isAnnotationPresent(ReadFilters.class)) {
|
||||
for ( Class c : walkerClass.getAnnotation(ReadFilters.class).value() ) {
|
||||
|
|
@ -463,7 +464,7 @@ public class WalkerManager extends PluginManager<Walker> {
|
|||
* @param walker The walker to inspect.
|
||||
* @return An array of types extending from SamRecordFilter. Will never be null.
|
||||
*/
|
||||
public static Collection<Class<? extends SamRecordFilter>> getReadFilterTypes(Walker walker) {
|
||||
public static Collection<Class<? extends ReadFilter>> getReadFilterTypes(Walker walker) {
|
||||
return getReadFilterTypes(walker.getClass());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import net.sf.picard.reference.IndexedFastaSequenceFile;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.broadinstitute.sting.gatk.DownsamplingMethod;
|
||||
import org.broadinstitute.sting.gatk.filters.ReadFilter;
|
||||
import org.broadinstitute.sting.gatk.iterators.*;
|
||||
import org.broadinstitute.sting.gatk.ReadProperties;
|
||||
import org.broadinstitute.sting.gatk.ReadMetrics;
|
||||
|
|
@ -146,7 +147,7 @@ public class SAMDataSource {
|
|||
null,
|
||||
null,
|
||||
new ValidationExclusion(),
|
||||
new ArrayList<SamRecordFilter>(),
|
||||
new ArrayList<ReadFilter>(),
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
|
|
@ -163,7 +164,7 @@ public class SAMDataSource {
|
|||
Integer readBufferSize,
|
||||
DownsamplingMethod downsamplingMethod,
|
||||
ValidationExclusion exclusionList,
|
||||
Collection<SamRecordFilter> supplementalFilters,
|
||||
Collection<ReadFilter> supplementalFilters,
|
||||
boolean includeReadsWithDeletionAtLoci,
|
||||
boolean generateExtendedEvents,
|
||||
boolean enableLowMemorySharding) {
|
||||
|
|
@ -209,7 +210,7 @@ public class SAMDataSource {
|
|||
Integer readBufferSize,
|
||||
DownsamplingMethod downsamplingMethod,
|
||||
ValidationExclusion exclusionList,
|
||||
Collection<SamRecordFilter> supplementalFilters,
|
||||
Collection<ReadFilter> supplementalFilters,
|
||||
boolean includeReadsWithDeletionAtLoci,
|
||||
boolean generateExtendedEvents,
|
||||
BAQ.CalculationMode cmode,
|
||||
|
|
@ -632,7 +633,7 @@ public class SAMDataSource {
|
|||
StingSAMIterator wrappedIterator,
|
||||
Double downsamplingFraction,
|
||||
Boolean noValidationOfReadOrder,
|
||||
Collection<SamRecordFilter> supplementalFilters,
|
||||
Collection<ReadFilter> supplementalFilters,
|
||||
BAQ.CalculationMode cmode,
|
||||
BAQ.QualityMode qmode,
|
||||
IndexedFastaSequenceFile refReader,
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import org.broadinstitute.sting.gatk.arguments.GATKArgumentCollection;
|
|||
import org.broadinstitute.sting.gatk.arguments.ValidationExclusion;
|
||||
import org.broadinstitute.sting.gatk.datasources.reads.SAMReaderID;
|
||||
import org.broadinstitute.sting.gatk.datasources.sample.SampleDataSource;
|
||||
import org.broadinstitute.sting.gatk.filters.ReadFilter;
|
||||
import org.broadinstitute.sting.gatk.filters.UnmappedReadFilter;
|
||||
import org.broadinstitute.sting.gatk.iterators.LocusIteratorByState;
|
||||
import org.broadinstitute.sting.utils.GenomeLocParser;
|
||||
|
|
@ -78,7 +79,7 @@ public class DownsamplerBenchmark extends ReadProcessingBenchmark {
|
|||
0,
|
||||
downsampling.create(),
|
||||
new ValidationExclusion(Collections.singletonList(ValidationExclusion.TYPE.ALL)),
|
||||
Collections.<SamRecordFilter>emptyList(),
|
||||
Collections.<ReadFilter>emptyList(),
|
||||
false,
|
||||
false,
|
||||
BAQ.CalculationMode.OFF,
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
|
|||
import org.broadinstitute.sting.gatk.arguments.GATKArgumentCollection;
|
||||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||
import org.broadinstitute.sting.gatk.datasources.reads.SAMReaderID;
|
||||
import org.broadinstitute.sting.gatk.filters.ReadFilter;
|
||||
import org.broadinstitute.sting.gatk.filters.UnmappedReadFilter;
|
||||
import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
|
||||
import org.broadinstitute.sting.gatk.refdata.utils.RMDTriplet;
|
||||
|
|
@ -88,7 +89,7 @@ public class GATKWalkerBenchmark extends ReadProcessingBenchmark {
|
|||
engine.setArguments(argCollection);
|
||||
// Bugs in the engine mean that this has to be set twice.
|
||||
engine.setSAMFileIDs(Collections.singletonList(new SAMReaderID(inputFile,new Tags())));
|
||||
engine.setFilters(Collections.<SamRecordFilter>singletonList(new UnmappedReadFilter()));
|
||||
engine.setFilters(Collections.<ReadFilter>singletonList(new UnmappedReadFilter()));
|
||||
engine.setReferenceMetaDataFiles(Collections.<RMDTriplet>emptyList());
|
||||
|
||||
// Create the walker
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import net.sf.samtools.*;
|
|||
* @version 0.1
|
||||
*/
|
||||
|
||||
public class BadCigarFilter implements SamRecordFilter {
|
||||
public class BadCigarFilter extends ReadFilter {
|
||||
|
||||
public boolean filterOut(final SAMRecord rec) {
|
||||
Cigar c = rec.getCigar();
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import net.sf.samtools.SAMRecord;
|
|||
* @version 0.1
|
||||
*/
|
||||
|
||||
public class BadMateFilter implements SamRecordFilter {
|
||||
public class BadMateFilter extends ReadFilter {
|
||||
|
||||
public boolean filterOut(final SAMRecord rec) {
|
||||
return hasBadMate(rec);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import org.broadinstitute.sting.gatk.ReadMetrics;
|
|||
public class CountingFilteringIterator implements CloseableIterator<SAMRecord> {
|
||||
private final ReadMetrics runtimeMetrics;
|
||||
private final Iterator<SAMRecord> iterator;
|
||||
private final Collection<SamRecordFilter> filters;
|
||||
private final Collection<ReadFilter> filters;
|
||||
private SAMRecord next = null;
|
||||
|
||||
/**
|
||||
|
|
@ -52,7 +52,7 @@ public class CountingFilteringIterator implements CloseableIterator<SAMRecord> {
|
|||
* @param iterator the backing iterator
|
||||
* @param filters the filter (which may be a FilterAggregator)
|
||||
*/
|
||||
public CountingFilteringIterator(ReadMetrics metrics, Iterator<SAMRecord> iterator, Collection<SamRecordFilter> filters) {
|
||||
public CountingFilteringIterator(ReadMetrics metrics, Iterator<SAMRecord> iterator, Collection<ReadFilter> filters) {
|
||||
this.runtimeMetrics = metrics;
|
||||
this.iterator = iterator;
|
||||
this.filters = filters;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import net.sf.samtools.SAMRecord;
|
|||
* Filter out duplicate reads.
|
||||
*/
|
||||
|
||||
public class DuplicateReadFilter implements SamRecordFilter {
|
||||
public class DuplicateReadFilter extends ReadFilter {
|
||||
public boolean filterOut( final SAMRecord read ) {
|
||||
return read.getDuplicateReadFlag();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import net.sf.samtools.SAMRecord;
|
|||
* Filter out FailsVendorQualityCheck reads.
|
||||
*/
|
||||
|
||||
public class FailsVendorQualityCheckReadFilter implements SamRecordFilter {
|
||||
public class FailsVendorQualityCheckReadFilter extends ReadFilter {
|
||||
public boolean filterOut( final SAMRecord read ) {
|
||||
return read.getReadFailsVendorQualityCheckFlag();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ import java.util.Collection;
|
|||
* @author mhanna
|
||||
* @version 0.1
|
||||
*/
|
||||
public class FilterManager extends PluginManager<SamRecordFilter> {
|
||||
public class FilterManager extends PluginManager<ReadFilter> {
|
||||
public FilterManager() {
|
||||
super(SamRecordFilter.class,"filter","Filter");
|
||||
super(ReadFilter.class,"filter","Filter");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -50,11 +50,11 @@ public class FilterManager extends PluginManager<SamRecordFilter> {
|
|||
* @param filterType The type of the filter
|
||||
* @return The filter
|
||||
*/
|
||||
public SamRecordFilter createFilterByType(Class<? extends SamRecordFilter> filterType) {
|
||||
public ReadFilter createFilterByType(Class<? extends ReadFilter> filterType) {
|
||||
return this.createByName(getName(filterType));
|
||||
}
|
||||
|
||||
public Collection<Class<? extends SamRecordFilter>> getValues() {
|
||||
public Collection<Class<? extends ReadFilter>> getValues() {
|
||||
return this.getPlugins();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
package org.broadinstitute.sting.gatk.filters;
|
||||
|
||||
import net.sf.picard.filter.SamRecordFilter;
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import net.sf.samtools.SAMFileHeader;
|
||||
import net.sf.samtools.SAMSequenceRecord;
|
||||
|
|
@ -36,12 +35,12 @@ import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
|
|||
* @author mhanna
|
||||
* @version 0.1
|
||||
*/
|
||||
public class MalformedReadFilter implements SamRecordHeaderFilter {
|
||||
public class MalformedReadFilter extends ReadFilter {
|
||||
private SAMFileHeader header;
|
||||
|
||||
@Override
|
||||
public void setHeader(SAMFileHeader header) {
|
||||
this.header = header;
|
||||
public void initialize(GenomeAnalysisEngine engine) {
|
||||
this.header = engine.getSAMFileHeader();
|
||||
}
|
||||
|
||||
public boolean filterOut(SAMRecord read) {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import org.broadinstitute.sting.commandline.Argument;
|
|||
* @version 0.1
|
||||
*/
|
||||
|
||||
public class MappingQualityReadFilter implements SamRecordFilter {
|
||||
public class MappingQualityReadFilter extends ReadFilter {
|
||||
|
||||
@Argument(fullName = "min_mapping_quality_score", shortName = "mmq", doc = "Minimum read mapping quality required to consider a read for calling", required = false)
|
||||
public int MIN_MAPPING_QUALTY_SCORE = 10;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import org.broadinstitute.sting.commandline.Argument;
|
|||
* @author mhanna
|
||||
* @version 0.1
|
||||
*/
|
||||
public class MaxReadLengthFilter implements SamRecordFilter {
|
||||
public class MaxReadLengthFilter extends ReadFilter {
|
||||
@Argument(fullName = "maxReadLength", shortName = "maxRead", doc="Discard reads with length greater than the specified value", required=true)
|
||||
private int maxReadLength;
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import net.sf.samtools.SAMRecord;
|
|||
* @version 0.1
|
||||
*/
|
||||
|
||||
public class MissingReadGroupFilter implements SamRecordFilter {
|
||||
public class MissingReadGroupFilter extends ReadFilter {
|
||||
public boolean filterOut(SAMRecord rec) {
|
||||
return rec.getReadGroup() == null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import net.sf.samtools.SAMRecord;
|
|||
*
|
||||
* Filter out reads that don't have Original Quality scores inside.
|
||||
*/
|
||||
public class NoOriginalQualityScoresFilter implements SamRecordFilter {
|
||||
public class NoOriginalQualityScoresFilter extends ReadFilter {
|
||||
public boolean filterOut( final SAMRecord read ) {
|
||||
return (read.getAttribute("OQ") == null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import net.sf.samtools.SAMRecord;
|
|||
* Filter out duplicate reads.
|
||||
*/
|
||||
|
||||
public class NotPrimaryAlignmentReadFilter implements SamRecordFilter {
|
||||
public class NotPrimaryAlignmentReadFilter extends ReadFilter {
|
||||
public boolean filterOut( final SAMRecord read ) {
|
||||
return read.getNotPrimaryAlignmentFlag();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import org.broadinstitute.sting.utils.sam.ReadUtils;
|
|||
* @version 0.1
|
||||
*/
|
||||
|
||||
public class Platform454Filter implements SamRecordFilter {
|
||||
public class Platform454Filter extends ReadFilter {
|
||||
public boolean filterOut(SAMRecord rec) {
|
||||
return (ReadUtils.is454Read(rec));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import org.broadinstitute.sting.commandline.Argument;
|
|||
* @author ebanks
|
||||
* @version 0.1
|
||||
*/
|
||||
public class PlatformFilter implements SamRecordFilter {
|
||||
public class PlatformFilter extends ReadFilter {
|
||||
@Argument(fullName = "PLFilterName", shortName = "PLFilterName", doc="Discard reads with RG:PL attribute containing this strign", required=false)
|
||||
protected String[] PLFilterNames;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import org.broadinstitute.sting.utils.exceptions.UserException;
|
|||
* Time: 2:54:23 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class PlatformUnitFilter implements SamRecordFilter {
|
||||
public class PlatformUnitFilter extends ReadFilter {
|
||||
// a hack: use static in order to be able to fill it with the data from command line at runtime
|
||||
static private Set<String> blackListedLanes = new HashSet<String>();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,14 +2,15 @@ package org.broadinstitute.sting.gatk.filters;
|
|||
|
||||
import net.sf.picard.filter.SamRecordFilter;
|
||||
import net.sf.samtools.SAMFileHeader;
|
||||
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
|
||||
|
||||
/**
|
||||
* A SamRecordFilter that also depends on the header.
|
||||
*/
|
||||
public interface SamRecordHeaderFilter extends SamRecordFilter {
|
||||
public abstract class ReadFilter implements SamRecordFilter {
|
||||
/**
|
||||
* Sets the header for use by this filter.
|
||||
* @param header the header for use by this filter.
|
||||
* @param engine the engine.
|
||||
*/
|
||||
void setHeader(SAMFileHeader header);
|
||||
public void initialize(GenomeAnalysisEngine engine) {}
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ import org.broadinstitute.sting.utils.text.XReadLines;
|
|||
* PU:1000G-mpimg-080821-1_1
|
||||
* would filter out a read with the read group PU:1000G-mpimg-080821-1_1
|
||||
*/
|
||||
public class ReadGroupBlackListFilter implements SamRecordFilter {
|
||||
public class ReadGroupBlackListFilter extends ReadFilter {
|
||||
private Set<Entry<String, Collection<String>>> filterEntries;
|
||||
|
||||
public ReadGroupBlackListFilter(List<String> blackLists) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import org.broadinstitute.sting.commandline.Argument;
|
|||
* @author chartl
|
||||
* @version 0.1
|
||||
*/
|
||||
public class ReadStrandFilter implements SamRecordFilter {
|
||||
public class ReadStrandFilter extends ReadFilter {
|
||||
@Argument(fullName = "filterPositive", shortName = "fp", doc="Discard reads on the forward strand",required=false)
|
||||
boolean filterForward = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import org.broadinstitute.sting.commandline.Argument;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
public class SampleFilter implements SamRecordFilter {
|
||||
public class SampleFilter extends ReadFilter {
|
||||
@Argument(fullName = "sample_to_keep", shortName = "goodSM", doc="The name of the sample(s) to keep, filtering out all others", required=true)
|
||||
private Set SAMPLES_TO_KEEP = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import org.broadinstitute.sting.commandline.Argument;
|
|||
* Only use reads from the specified read group.
|
||||
*/
|
||||
|
||||
public class SingleReadGroupFilter implements SamRecordFilter {
|
||||
public class SingleReadGroupFilter extends ReadFilter {
|
||||
@Argument(fullName = "read_group_to_keep", shortName = "goodRG", doc="The name of the read group to keep, filtering out all others", required=true)
|
||||
private String READ_GROUP_TO_KEEP = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import net.sf.samtools.SAMRecord;
|
|||
* Filter out duplicate reads.
|
||||
*/
|
||||
|
||||
public class UnmappedReadFilter implements SamRecordFilter {
|
||||
public class UnmappedReadFilter extends ReadFilter {
|
||||
public boolean filterOut( final SAMRecord read ) {
|
||||
return read.getReadUnmappedFlag() || read.getAlignmentStart() == SAMRecord.NO_ALIGNMENT_START;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import net.sf.samtools.SAMRecord;
|
|||
* @version 0.1
|
||||
*/
|
||||
|
||||
public class ZeroMappingQualityReadFilter implements SamRecordFilter {
|
||||
public class ZeroMappingQualityReadFilter extends ReadFilter {
|
||||
public boolean filterOut(SAMRecord rec) {
|
||||
return (rec.getMappingQuality() == 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
|
|||
import org.broadinstitute.sting.gatk.WalkerManager;
|
||||
import org.broadinstitute.sting.gatk.arguments.ValidationExclusion;
|
||||
import org.broadinstitute.sting.gatk.filters.FilterManager;
|
||||
import org.broadinstitute.sting.gatk.filters.ReadFilter;
|
||||
import org.broadinstitute.sting.gatk.io.stubs.VCFWriterArgumentTypeDescriptor;
|
||||
import org.broadinstitute.sting.gatk.io.stubs.OutputStreamArgumentTypeDescriptor;
|
||||
import org.broadinstitute.sting.gatk.io.stubs.SAMFileReaderArgumentTypeDescriptor;
|
||||
|
|
@ -169,7 +170,7 @@ public class GATKExtensionsGenerator extends CommandLineProgram {
|
|||
}
|
||||
}
|
||||
|
||||
for (Class<? extends SamRecordFilter> filter: filterManager.getValues()) {
|
||||
for (Class<? extends ReadFilter> filter: filterManager.getValues()) {
|
||||
String filterName = filterManager.getName(filter);
|
||||
writeFilter(filterName, ArgumentDefinitionField.getArgumentFields(new ParsingEngine(null),filter), dependents);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import net.sf.samtools.SAMFileHeader;
|
|||
import net.sf.samtools.SAMFileReader;
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import net.sf.samtools.util.CloseableIterator;
|
||||
import org.broadinstitute.sting.gatk.filters.ReadFilter;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
|
||||
import org.testng.Assert;
|
||||
|
|
@ -302,7 +303,7 @@ public class LocusIteratorByStateUnitTest extends BaseTest {
|
|||
null,
|
||||
null,
|
||||
new ValidationExclusion(),
|
||||
new ArrayList<SamRecordFilter>(),
|
||||
Collections.<ReadFilter>emptyList(),
|
||||
false,
|
||||
false,
|
||||
BAQ.CalculationMode.OFF,
|
||||
|
|
|
|||
Loading…
Reference in New Issue