Modifications to the output system for better interaction with @Output. Multiplexed arguments. More details in the Monday meeting.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4077 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
hanna 2010-08-22 14:27:05 +00:00
parent 30a104228a
commit b80cf7d1d9
129 changed files with 1325 additions and 654 deletions

View File

@ -27,6 +27,7 @@ package org.broadinstitute.sting.alignment;
import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
import org.broadinstitute.sting.gatk.walkers.WalkerName;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
@ -37,6 +38,7 @@ import net.sf.samtools.*;
import net.sf.picard.reference.ReferenceSequenceFileFactory;
import java.io.File;
import java.io.PrintStream;
/**
* Aligns reads to a given reference using Heng Li's BWA aligner, presenting the resulting alignments in SAM or BAM format.
@ -53,6 +55,9 @@ public class AlignmentWalker extends ReadWalker<Integer,Integer> {
@Argument(fullName = "outputBam", shortName = "ob", doc = "Write output to this BAM filename instead of STDOUT", required = false)
private String outputBamFile = null;
@Output
private PrintStream out = null;
@Argument(fullName = "bam_compression", shortName = "compress", doc = "Compression level to use for writing BAM files", required = false)
private Integer bamCompression = 5;

View File

@ -32,9 +32,11 @@ import org.broadinstitute.sting.alignment.bwa.BWTFiles;
import org.broadinstitute.sting.alignment.bwa.BWAConfiguration;
import org.broadinstitute.sting.alignment.bwa.c.BWACAligner;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import net.sf.samtools.SAMRecord;
import java.util.*;
import java.io.PrintStream;
/**
* Counts the number of best alignments as presented by BWA and outputs a histogram of number of placements vs. the
@ -50,6 +52,9 @@ public class CountBestAlignmentsWalker extends ReadWalker<Integer,Integer> {
@Argument(fullName="BWTPrefix",shortName="BWT",doc="Index files generated by bwa index -d bwtsw",required=false)
private String prefix = null;
@Output
private PrintStream out = null;
/**
* The actual aligner.
*/

View File

@ -79,7 +79,7 @@ public @interface Argument {
/**
* Should this command-line argument be exclusive of others. Should be
* a comma-separated list of names of arguments of which this should be
* independent.
* independent.
* @return A comma-separated string listing other arguments of which this
* argument should be independent.
*/

View File

@ -25,6 +25,8 @@
package org.broadinstitute.sting.commandline;
import org.broadinstitute.sting.gatk.walkers.Multiplexer;
import java.util.*;
/**
@ -50,8 +52,17 @@ public class ArgumentMatch implements Iterable<ArgumentMatch> {
* Create a new argument match, defining its properties later. Used to create invalid arguments.
*/
public ArgumentMatch() {
this.label = null;
this.definition = null;
this(null,null);
}
/**
* Minimal constructor for transform function.
* @param label Label of the argument match. Must not be null.
* @param definition The associated definition, if one exists. May be null.
*/
private ArgumentMatch(String label,ArgumentDefinition definition) {
this.label = label;
this.definition = definition;
}
/**
@ -64,6 +75,7 @@ public class ArgumentMatch implements Iterable<ArgumentMatch> {
this( label, definition, index, null );
}
private ArgumentMatch( String label, ArgumentDefinition definition, int index, String value ) {
this.label = label;
this.definition = definition;
@ -74,6 +86,26 @@ public class ArgumentMatch implements Iterable<ArgumentMatch> {
indices.put(index,values );
}
/**
* Reformat the given entries with the given multiplexer and key.
* TODO: Generify this.
* @param multiplexer Multiplexer that controls the transformation process.
* @param key Key which specifies the transform.
* @return A variant of this ArgumentMatch with all keys transformed.
*/
ArgumentMatch transform(Multiplexer multiplexer, Object key) {
SortedMap<Integer,List<String>> newIndices = new TreeMap<Integer,List<String>>();
for(Map.Entry<Integer,List<String>> index: indices.entrySet()) {
List<String> newEntries = new ArrayList<String>();
for(String entry: index.getValue())
newEntries.add(multiplexer.transformArgument(key,entry));
newIndices.put(index.getKey(),newEntries);
}
ArgumentMatch newArgumentMatch = new ArgumentMatch(label,definition);
newArgumentMatch.indices.putAll(newIndices);
return newArgumentMatch;
}
/**
* Return a string representation of the given argument match, for debugging purposes.
* @return String representation of the match.

View File

@ -25,6 +25,8 @@
package org.broadinstitute.sting.commandline;
import org.broadinstitute.sting.gatk.walkers.Multiplexer;
import java.util.*;
/**
* Represents a list of potential matches between the arguments defined
@ -160,6 +162,19 @@ public class ArgumentMatches implements Iterable<ArgumentMatch> {
return matches;
}
/**
* Reformat the given entries with the given multiplexer and key.
* TODO: Generify this.
* @param multiplexer Multiplexer that controls the transformation process.
* @param key Key which specifies the transform.
*/
ArgumentMatches transform(Multiplexer multiplexer, Object key) {
ArgumentMatches newArgumentMatches = new ArgumentMatches();
for(ArgumentMatch match: argumentMatches.values())
newArgumentMatches.mergeInto(match.transform(multiplexer,key));
return newArgumentMatches;
}
/**
* Merges the given argument match into the set of existing argument matches.
* If multiple arguments are present, those arguments will end up grouped.

View File

@ -25,6 +25,8 @@
package org.broadinstitute.sting.commandline;
import org.broadinstitute.sting.utils.StingException;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
@ -67,9 +69,28 @@ public class ArgumentSource {
* @param field Field containing the argument. Field must be annotated with 'Input' or 'Output'.
*/
public ArgumentSource( Field[] parentFields, Field field ) {
this(parentFields,field,ArgumentTypeDescriptor.create(field.getType()));
}
/**
* Create a new command-line argument target.
* @param parentFields Parent fields containing the the field. Field must be annotated with 'ArgumentCollection'.
* @param field Field containing the argument. Field must be annotated with 'Input' or 'Output'.
* @param typeDescriptor custom type descriptor to use when parsing.
*/
private ArgumentSource( Field[] parentFields, Field field, ArgumentTypeDescriptor typeDescriptor) {
this.parentFields = parentFields;
this.field = field;
this.typeDescriptor = ArgumentTypeDescriptor.create( field.getType() );
this.typeDescriptor = typeDescriptor;
}
/**
* Somewhat hackish copy constructor to track fields with a custom type descriptor.
* TODO: Separate type descriptor from ArgumentSource in general usage.
* @param typeDescriptor New type descriptor for the object.
*/
public ArgumentSource copyWithCustomTypeDescriptor(final ArgumentTypeDescriptor typeDescriptor) {
return new ArgumentSource(parentFields,field,typeDescriptor);
}
/**
@ -111,15 +132,15 @@ public class ArgumentSource {
* @return True if this descriptor wants to override any default the user specified. False otherwise.
*/
public boolean overridesDefault() {
return typeDescriptor.overridesDefault();
return typeDescriptor.createsTypeDefault(this,field.getType());
}
/**
* Provides the default value for the command-line argument.
* @return Default value to load into the object.
*/
public Object getDefault() {
return typeDescriptor.getDefault();
public Object createDefault() {
return typeDescriptor.createTypeDefault(this,field.getType());
}
/**
@ -155,6 +176,26 @@ public class ArgumentSource {
return field.isAnnotationPresent(Hidden.class);
}
/**
* Is this command-line argument dependent on some primitive argument types?
* @return True if this command-line argument depends on other arguments; false otherwise.
*/
public boolean isDependent() {
return typeDescriptor instanceof MultiplexArgumentTypeDescriptor;
}
/**
* Builds out a new type descriptor for the given dependent argument as a function
* of the containing object.
* @param containingObject The containing object.
* @return An argument type descriptor for the custom derivative field.
*/
public MultiplexArgumentTypeDescriptor createDependentTypeDescriptor(Object containingObject) {
if(!isDependent())
throw new StingException("Field " + field.getName() + " is independent; no dependent type descriptor can be derived.");
return ((MultiplexArgumentTypeDescriptor)typeDescriptor).createCustomTypeDescriptor(this,containingObject);
}
/**
* Gets a string representation of the argument source for debugging.
* @return String representation of the argument source.

View File

@ -26,11 +26,15 @@
package org.broadinstitute.sting.commandline;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.classloader.JVMUtils;
import org.broadinstitute.sting.gatk.walkers.Multiplex;
import org.broadinstitute.sting.gatk.walkers.Multiplexer;
import org.apache.log4j.Logger;
import java.lang.annotation.Annotation;
import java.lang.reflect.*;
import java.util.*;
import java.io.OutputStream;
/**
* An descriptor capable of providing parsers that can parse any type
@ -52,7 +56,8 @@ public abstract class ArgumentTypeDescriptor {
* The type of set used must be ordered (but not necessarily sorted).
*/
private static Set<ArgumentTypeDescriptor> descriptors = new LinkedHashSet<ArgumentTypeDescriptor>( Arrays.asList(new SimpleArgumentTypeDescriptor(),
new CompoundArgumentTypeDescriptor()) );
new CompoundArgumentTypeDescriptor(),
new MultiplexArgumentTypeDescriptor()) );
/**
* Adds new, user defined descriptors to the head of the descriptor list.
@ -88,20 +93,18 @@ public abstract class ArgumentTypeDescriptor {
public abstract boolean supports( Class type );
/**
* This argument type descriptor wants to override any default value the user might have specified.
* @return True if this descriptor wants to override any default the user specified. False otherwise.
* Returns false if a type-specific default can be employed.
* @param source Source of the command-line argument.
* @return True to throw in a type specific default. False otherwise.
*/
public boolean overridesDefault() {
return false;
}
public boolean createsTypeDefault(ArgumentSource source,Class type) { return false; }
/**
* Provides the default value for the command-line argument.
* @return Default value to load into the object.
* Generates a default for the given type.
* @param source Source of the command-line argument.
* @return A default value for the given type.
*/
public Object getDefault() {
throw new UnsupportedOperationException(String.format("Type descriptor %s cannot override default value of command-line argument",this.getClass()));
}
public Object createTypeDefault(ArgumentSource source,Class type) { throw new UnsupportedOperationException("Unable to create default for type " + getClass()); }
/**
* Given the given argument source and attributes, synthesize argument definitions for command-line arguments.
@ -156,15 +159,7 @@ public abstract class ArgumentTypeDescriptor {
* @throws IllegalArgumentException If more than one parameterized type is found on the field.
*/
protected Class getCollectionComponentType( Field field ) {
// If this is a parameterized collection, find the contained type. If blow up if more than one type exists.
if( field.getGenericType() instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType)field.getGenericType();
if( parameterizedType.getActualTypeArguments().length > 1 )
throw new IllegalArgumentException("Unable to determine collection type of field: " + field.toString());
return (Class)parameterizedType.getActualTypeArguments()[0];
}
else
return String.class;
return null;
}
/**
@ -322,6 +317,7 @@ class SimpleArgumentTypeDescriptor extends ArgumentTypeDescriptor {
}
}
/**
* A mapping of the primitive types to their associated wrapper classes. Is there really no way to infer
@ -338,7 +334,7 @@ class SimpleArgumentTypeDescriptor extends ArgumentTypeDescriptor {
put( Float.TYPE, Float.class );
put( Double.TYPE, Double.class );
}
};
};
}
/**
@ -413,4 +409,167 @@ class CompoundArgumentTypeDescriptor extends ArgumentTypeDescriptor {
else
throw new StingException("Unsupported compound argument type: " + type);
}
/**
* Return the component type of a field, or String.class if the type cannot be found.
* @param field The reflected field to inspect.
* @return The parameterized component type, or String.class if the parameterized type could not be found.
* @throws IllegalArgumentException If more than one parameterized type is found on the field.
*/
@Override
protected Class getCollectionComponentType( Field field ) {
// If this is a parameterized collection, find the contained type. If blow up if more than one type exists.
if( field.getGenericType() instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType)field.getGenericType();
if( parameterizedType.getActualTypeArguments().length > 1 )
throw new IllegalArgumentException("Unable to determine collection type of field: " + field.toString());
return (Class)parameterizedType.getActualTypeArguments()[0];
}
else
return String.class;
}
}
class MultiplexArgumentTypeDescriptor extends ArgumentTypeDescriptor {
/**
* The multiplexer controlling how data is split.
*/
private final Multiplexer multiplexer;
/**
* The set of identifiers for the multiplexed entries.
*/
private final Collection<?> multiplexedIds;
public MultiplexArgumentTypeDescriptor() {
this.multiplexer = null;
this.multiplexedIds = null;
}
/**
* Private constructor to use in creating a closure of the MultiplexArgumentTypeDescriptor specific to the
* given set of multiplexed ids.
* @param multiplexedIds The collection of multiplexed entries
*/
private MultiplexArgumentTypeDescriptor(final Multiplexer multiplexer, final Collection<?> multiplexedIds) {
this.multiplexer = multiplexer;
this.multiplexedIds = multiplexedIds;
}
@Override
public boolean supports( Class type ) {
return ( Map.class.isAssignableFrom(type) );
}
@Override
public boolean createsTypeDefault(ArgumentSource source,Class type) {
if(multiplexer == null || multiplexedIds == null)
throw new StingException("No multiplexed ids available");
// Always create a multiplexed mapping.
return true;
}
@Override
public Object createTypeDefault(ArgumentSource source,Class type) {
if(multiplexer == null || multiplexedIds == null)
throw new StingException("No multiplexed ids available");
Map<Object,Object> multiplexedMapping = new HashMap<Object,Object>();
Class componentType = getCollectionComponentType(source.field);
ArgumentTypeDescriptor componentTypeDescriptor = ArgumentTypeDescriptor.create(componentType);
for(Object id: multiplexedIds) {
Object value = null;
if(componentTypeDescriptor.createsTypeDefault(source,componentType))
value = componentTypeDescriptor.createTypeDefault(source,componentType);
multiplexedMapping.put(id,value);
}
return multiplexedMapping;
}
@Override
public Object parse( ArgumentSource source, Class type, ArgumentMatches matches ) {
if(multiplexedIds == null)
throw new StingException("Cannot directly parse a MultiplexArgumentTypeDescriptor; must create a derivative type descriptor first.");
Map<Object,Object> multiplexedMapping = new HashMap<Object,Object>();
Class componentType = getCollectionComponentType(source.field);
for(Object id: multiplexedIds) {
Object value = ArgumentTypeDescriptor.create(componentType).parse(source,componentType,matches.transform(multiplexer,id));
multiplexedMapping.put(id,value);
}
return multiplexedMapping;
}
public MultiplexArgumentTypeDescriptor createCustomTypeDescriptor(ArgumentSource dependentArgument,Object containingObject) {
String[] sourceFields = dependentArgument.field.getAnnotation(Multiplex.class).arguments();
List<ArgumentSource> allSources = ParsingEngine.extractArgumentSources(containingObject.getClass());
Class[] sourceTypes = new Class[sourceFields.length];
Object[] sourceValues = new Object[sourceFields.length];
int currentField = 0;
for(String sourceField: sourceFields) {
boolean fieldFound = false;
for(ArgumentSource source: allSources) {
if(!source.field.getName().equals(sourceField))
continue;
if(source.field.isAnnotationPresent(Multiplex.class))
throw new StingException("Command-line arguments can only depend on independent fields");
sourceTypes[currentField] = source.field.getType();
sourceValues[currentField] = JVMUtils.getFieldValue(source.field,containingObject);
currentField++;
fieldFound = true;
}
if(!fieldFound)
throw new StingException(String.format("Unable to find source field %s, referred to by dependent field %s",sourceField,dependentArgument.field.getName()));
}
Class<? extends Multiplexer> multiplexerType = dependentArgument.field.getAnnotation(Multiplex.class).value();
Constructor<? extends Multiplexer> multiplexerConstructor = null;
try {
multiplexerConstructor = multiplexerType.getConstructor(sourceTypes);
multiplexerConstructor.setAccessible(true);
}
catch(NoSuchMethodException ex) {
throw new StingException(String.format("Unable to find constructor for class %s with parameters %s",multiplexerType.getName(),Arrays.deepToString(sourceFields)),ex);
}
Multiplexer multiplexer = null;
try {
multiplexer = multiplexerConstructor.newInstance(sourceValues);
}
catch(IllegalAccessException ex) {
throw new StingException(String.format("Constructor for class %s with parameters %s is inaccessible",multiplexerType.getName(),Arrays.deepToString(sourceFields)),ex);
}
catch(InstantiationException ex) {
throw new StingException(String.format("Can't create class %s with parameters %s",multiplexerType.getName(),Arrays.deepToString(sourceFields)),ex);
}
catch(InvocationTargetException ex) {
throw new StingException(String.format("Can't invoke constructor of class %s with parameters %s",multiplexerType.getName(),Arrays.deepToString(sourceFields)),ex);
}
return new MultiplexArgumentTypeDescriptor(multiplexer,multiplexer.multiplex());
}
/**
* Return the component type of a field, or String.class if the type cannot be found.
* @param field The reflected field to inspect.
* @return The parameterized component type, or String.class if the parameterized type could not be found.
* @throws IllegalArgumentException If more than one parameterized type is found on the field.
*/
@Override
protected Class getCollectionComponentType( Field field ) {
// Multiplex arguments must resolve to maps from which the clp should extract the second type.
if( field.getGenericType() instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType)field.getGenericType();
if( parameterizedType.getActualTypeArguments().length != 2 )
throw new IllegalArgumentException("Unable to determine collection type of field: " + field.toString());
return (Class)parameterizedType.getActualTypeArguments()[1];
}
else
return String.class;
}
}

View File

@ -40,7 +40,7 @@ public @interface Output {
* prefixed on the command-line with a double dash (--).
* @return Selected full name, or "" to use the default.
*/
String fullName() default "";
String fullName() default "out";
/**
* Specified short name of the command. Short names should be prefixed
@ -48,21 +48,21 @@ public @interface Output {
* short names or be separated from them by a space.
* @return Selected short name, or "" for none.
*/
String shortName() default "";
String shortName() default "o";
/**
* Documentation for the command-line argument. Should appear when the
* --help argument is specified.
* @return Doc string associated with this command-line argument.
*/
String doc();
String doc() default "An output file presented to the walker. Will overwrite contents if file exists.";
/**
* Is this command-line argument required. The application should exit
* printing help if this command-line argument is not specified.
* @return True if the argument is required. False otherwise.
*/
boolean required() default true;
boolean required() default false;
/**
* Should this command-line argument be exclusive of others. Should be

View File

@ -254,8 +254,22 @@ public class ParsingEngine {
*/
public void loadArgumentsIntoObject( Object object ) {
List<ArgumentSource> argumentSources = extractArgumentSources(object.getClass());
for( ArgumentSource argumentSource: argumentSources )
List<ArgumentSource> dependentArguments = new ArrayList<ArgumentSource>();
for( ArgumentSource argumentSource: argumentSources ) {
// If this argument source depends on other command-line arguments, skip it and make a note to process it later.
if(argumentSource.isDependent()) {
dependentArguments.add(argumentSource);
continue;
}
loadValueIntoObject( argumentSource, object, argumentMatches.findMatches(argumentSource) );
}
for(ArgumentSource dependentArgument: dependentArguments) {
MultiplexArgumentTypeDescriptor dependentDescriptor = dependentArgument.createDependentTypeDescriptor(object);
ArgumentSource dependentSource = dependentArgument.copyWithCustomTypeDescriptor(dependentDescriptor);
loadValueIntoObject(dependentSource,object,argumentMatches.findMatches(dependentSource));
}
}
/**
@ -277,7 +291,7 @@ public class ParsingEngine {
throw new StingException("Internal command-line parser error: unable to find a home for argument matches " + argumentMatches);
for( Object target: targets ) {
Object value = (argumentMatches.size() != 0) ? source.parse(argumentMatches) : source.getDefault();
Object value = (argumentMatches.size() != 0) ? source.parse(argumentMatches) : source.createDefault();
JVMUtils.setFieldValue(source.field,target,value);
}
}

View File

@ -99,13 +99,9 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
* @return A collection of type descriptors generating implementation-dependent placeholders.
*/
protected Collection<ArgumentTypeDescriptor> getArgumentTypeDescriptors() {
return Arrays.asList( new VCFWriterArgumentTypeDescriptor(GATKEngine),
new SAMFileReaderArgumentTypeDescriptor(GATKEngine),
new SAMFileWriterArgumentTypeDescriptor(GATKEngine),
new OutputStreamArgumentTypeDescriptor(GATKEngine) );
return GATKEngine.getArgumentTypeDescriptors();
}
/**
* GATK can add arguments dynamically based on analysis type.
*

View File

@ -44,7 +44,7 @@ import org.broadinstitute.sting.gatk.filters.FilterManager;
import org.broadinstitute.sting.gatk.filters.ReadGroupBlackListFilter;
import org.broadinstitute.sting.gatk.filters.ZeroMappingQualityReadFilter;
import org.broadinstitute.sting.gatk.io.OutputTracker;
import org.broadinstitute.sting.gatk.io.stubs.Stub;
import org.broadinstitute.sting.gatk.io.stubs.*;
import org.broadinstitute.sting.gatk.refdata.tracks.RMDTrack;
import org.broadinstitute.sting.gatk.refdata.tracks.RMDTrackManager;
import org.broadinstitute.sting.gatk.refdata.utils.RMDIntervalGenerator;
@ -52,6 +52,7 @@ import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.commandline.ArgumentException;
import org.broadinstitute.sting.commandline.ArgumentSource;
import org.broadinstitute.sting.commandline.ArgumentTypeDescriptor;
import java.io.File;
import java.util.*;
@ -161,7 +162,7 @@ public class GenomeAnalysisEngine {
// our microscheduler, which is in charge of running everything
MicroScheduler microScheduler = createMicroscheduler(my_walker);
// create the output streams
// create the output streams "
initializeOutputStreams(my_walker, microScheduler.getOutputTracker());
initializeIntervals();
@ -516,6 +517,19 @@ public class GenomeAnalysisEngine {
}
/**
* Subclasses of CommandLinePrograms can provide their own types of command-line arguments.
* @return A collection of type descriptors generating implementation-dependent placeholders.
*/
protected Collection<ArgumentTypeDescriptor> getArgumentTypeDescriptors() {
return Arrays.asList( new VCFWriterArgumentTypeDescriptor(this,System.out),
new SAMFileReaderArgumentTypeDescriptor(this),
new SAMFileWriterArgumentTypeDescriptor(this,System.out),
new OutputStreamArgumentTypeDescriptor(this,System.out) );
}
/**
* Bundles all the source information about the reads into a unified data structure.
*
@ -856,11 +870,6 @@ public class GenomeAnalysisEngine {
* @param outputTracker the tracker supplying the initialization data.
*/
private void initializeOutputStreams(Walker walker, OutputTracker outputTracker) {
if (argCollection.outErrFileName != null)
outputTracker.initializeCoreIO(argCollection.outErrFileName, argCollection.outErrFileName);
else
outputTracker.initializeCoreIO(argCollection.outFileName, argCollection.errFileName);
for (Map.Entry<ArgumentSource, Object> input : inputs.entrySet())
outputTracker.addInput(input.getKey(), input.getValue());
for (Stub<?> stub : outputs)

View File

@ -30,7 +30,6 @@ import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.interval.IntervalMergingRule;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Input;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.DownsampleType;
import org.broadinstitute.sting.utils.interval.IntervalSetRule;
import org.simpleframework.xml.*;
@ -113,21 +112,6 @@ public class GATKArgumentCollection {
@Input(fullName = "hapmap_chip", shortName = "hc", doc = "Hapmap chip file", required = false)
public String HAPMAPChipFile = null;
/** An output file presented to the walker. */
@Element(required = false)
@Output(fullName = "out", shortName = "o", doc = "An output file presented to the walker. Will overwrite contents if file exists.", required = false)
public String outFileName = null;
/** An error output file presented to the walker. */
@Element(required = false)
@Output(fullName = "err", shortName = "e", doc = "An error output file presented to the walker. Will overwrite contents if file exists.", required = false)
public String errFileName = null;
/** A joint file for both 'normal' and error output presented to the walker. */
@Element(required = false)
@Output(fullName = "outerr", shortName = "oe", doc = "A joint file for 'normal' and error output presented to the walker. Will overwrite contents if file exists.", required = false)
public String outErrFileName = null;
@Element(required = false)
@Argument(fullName = "filterZeroMappingQualityReads", shortName = "fmq0", doc = "If true, mapping quality zero reads will be filtered at the lowest GATK level. Vastly improves performance at areas with abnormal depth due to mapping Q0 reads", required = false)
public Boolean filterZeroMappingQualityReads = false;
@ -325,15 +309,6 @@ public class GATKArgumentCollection {
(other.downsampleCoverage != null && !other.downsampleCoverage.equals(this.downsampleCoverage))) {
return false;
}
if (!other.outFileName.equals(this.outFileName)) {
return false;
}
if (!other.errFileName.equals(this.errFileName)) {
return false;
}
if (!other.outErrFileName.equals(this.outErrFileName)) {
return false;
}
if (other.numberOfThreads != this.numberOfThreads) {
return false;
}

View File

@ -6,13 +6,17 @@ import org.broadinstitute.sting.gatk.refdata.*;
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
import org.broadinstitute.sting.gatk.contexts.*;
import org.broadinstitute.sting.utils.pileup.*;
import org.broadinstitute.sting.commandline.Output;
import java.util.*;
import java.io.PrintStream;
/**
* Computes the coverage per sample.
*/
public class CoverageBySample extends LocusWalker<Integer, Integer> {
@Output
protected PrintStream out;
private HashSet<String> sampleNames = new HashSet<String>();

View File

@ -67,30 +67,6 @@ public abstract class OutputTracker {
*/
protected OutputStreamStub errStub = null;
/**
* Create an object to manage output given filenames for the output and error files.
* If no files are specified, returns null.
* @param outFileName Name of the output file.
* @param errFileName Name of the error file.
*/
public void initializeCoreIO( String outFileName, String errFileName ) {
// If the two output streams match and are non-null, initialize them identically.
// Otherwise, initialize them separately.
if( outFileName != null && outFileName.equals(errFileName) ) {
outStub = errStub = new OutputStreamStub(new File(outFileName));
addOutput(outStub,new OutputStreamStorage(outStub));
}
else {
outStub = (outFileName != null) ? new OutputStreamStub(new File(outFileName))
: new OutputStreamStub(System.out);
addOutput(outStub,new OutputStreamStorage(outStub));
errStub = (errFileName != null) ? new OutputStreamStub(new File(errFileName))
: new OutputStreamStub(System.err);
addOutput(errStub,new OutputStreamStorage(errStub));
}
}
/**
* Gets the output storage associated with a given stub.
* @param stub The stub for which to find / create the right output stream.
@ -100,9 +76,6 @@ public abstract class OutputTracker {
public abstract <T> T getStorage( Stub<T> stub );
public void prepareWalker( Walker walker ) {
installStub( walker, "out", new PrintStream(outStub) );
installStub( walker, "err", new PrintStream(errStub) );
for( Map.Entry<ArgumentSource,Object> io: inputs.entrySet() ) {
ArgumentSource targetField = io.getKey();
Object targetValue = io.getValue();

View File

@ -31,6 +31,7 @@ import net.sf.samtools.util.CloseableIterator;
import java.io.*;
import org.broadinstitute.sting.gatk.io.stubs.SAMFileWriterStub;
import org.broadinstitute.sting.utils.StingException;
/**
* Provides temporary storage for SAMFileWriters.
@ -48,10 +49,17 @@ public class SAMFileWriterStorage implements SAMFileWriter, Storage<SAMFileWrite
public SAMFileWriterStorage( SAMFileWriterStub stub, File file ) {
this.file = file;
if( stub.getCompressionLevel() != null )
this.writer = new SAMFileWriterFactory().makeBAMWriter( stub.getFileHeader(), stub.isPresorted(), file, stub.getCompressionLevel() );
if(stub.getSAMFile() != null) {
if( stub.getCompressionLevel() != null )
this.writer = new SAMFileWriterFactory().makeBAMWriter( stub.getFileHeader(), stub.isPresorted(), file, stub.getCompressionLevel() );
else
this.writer = new SAMFileWriterFactory().makeBAMWriter( stub.getFileHeader(), stub.isPresorted(), file );
}
else if(stub.getSAMOutputStream() != null){
this.writer = new SAMFileWriterFactory().makeSAMWriter( stub.getFileHeader(), stub.isPresorted(), stub.getSAMOutputStream());
}
else
this.writer = new SAMFileWriterFactory().makeBAMWriter( stub.getFileHeader(), stub.isPresorted(), file );
throw new StingException("Unable to write to SAM file; neither a target file nor a stream has been specified");
}
public SAMFileHeader getFileHeader() {

View File

@ -4,7 +4,7 @@ import org.broad.tribble.vcf.VCFHeader;
import org.broad.tribble.vcf.VCFHeaderLine;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriter;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriterImpl;
import org.broadinstitute.sting.utils.genotype.vcf.StandardVCFWriter;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.gatk.io.stubs.VCFWriterStub;
@ -32,7 +32,7 @@ public class VCFWriterStorage implements Storage<VCFWriterStorage>, VCFWriter {
if(stub.getFile() != null) {
this.file = stub.getFile();
try {
this.stream = new PrintStream(stub.getFile());
this.stream = new PrintStream(file);
}
catch(IOException ex) {
throw new StingException("Unable to open target output stream",ex);
@ -45,7 +45,7 @@ public class VCFWriterStorage implements Storage<VCFWriterStorage>, VCFWriter {
else
throw new StingException("Unable to create target to which to write; storage was provided with neither a file nor a stream.");
writer = new VCFWriterImpl(stream);
writer = new StandardVCFWriter(stream);
}
/**
@ -61,7 +61,7 @@ public class VCFWriterStorage implements Storage<VCFWriterStorage>, VCFWriter {
catch(IOException ex) {
throw new StingException("Unable to open target output stream",ex);
}
writer = new VCFWriterImpl(this.stream);
writer = new StandardVCFWriter(this.stream);
Set<String> samples = SampleUtils.getSAMFileSamples(stub.getSAMFileHeader());
writer.writeHeader(new VCFHeader(null, samples));
}

View File

@ -33,6 +33,7 @@ import java.io.OutputStream;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Field;
/**
* Insert an OutputStreamStub instead of a full-fledged concrete OutputStream implementations.
@ -41,14 +42,21 @@ public class OutputStreamArgumentTypeDescriptor extends ArgumentTypeDescriptor {
/**
* The engine into which output stubs should be fed.
*/
private GenomeAnalysisEngine engine;
private final GenomeAnalysisEngine engine;
/**
* The default output stream to write to write this info if
*/
private final OutputStream defaultOutputStream;
/**
* Create a new OutputStream argument, notifying the given engine when that argument has been created.
* @param engine Engine to add SAMFileWriter output to.
* @param defaultOutputStream Default target for output file.
*/
public OutputStreamArgumentTypeDescriptor( GenomeAnalysisEngine engine ) {
this.engine = engine;
public OutputStreamArgumentTypeDescriptor(GenomeAnalysisEngine engine,OutputStream defaultOutputStream) {
this.engine = engine;
this.defaultOutputStream = defaultOutputStream;
}
@Override
@ -56,6 +64,18 @@ public class OutputStreamArgumentTypeDescriptor extends ArgumentTypeDescriptor {
return getConstructorForClass(type) != null;
}
@Override
public boolean createsTypeDefault(ArgumentSource source,Class type) {
return true;
}
@Override
public Object createTypeDefault(ArgumentSource source,Class type) {
OutputStreamStub stub = new OutputStreamStub(defaultOutputStream);
engine.addOutput(stub);
return createInstanceOfClass(type,stub);
}
@Override
public Object parse( ArgumentSource source, Class type, ArgumentMatches matches ) {
ArgumentDefinition definition = createDefaultArgumentDefinition(source);
@ -65,18 +85,7 @@ public class OutputStreamArgumentTypeDescriptor extends ArgumentTypeDescriptor {
engine.addOutput(stub);
try {
return getConstructorForClass(type).newInstance(stub);
}
catch( InstantiationException ex ) {
throw new StingException("Could not instantiate class with OutputStream constructor: " + type.getName());
}
catch( IllegalAccessException ex ) {
throw new StingException("Could not access class with OutputStream constructor: " + type.getName());
}
catch( InvocationTargetException ex ) {
throw new StingException("Could not invoke constructor for class with OutputStream constructor: " + type.getName());
}
return createInstanceOfClass(type,stub);
}
/**
@ -92,4 +101,25 @@ public class OutputStreamArgumentTypeDescriptor extends ArgumentTypeDescriptor {
return null;
}
}
/**
* Creat a new instance of the class accepting a single outputstream constructor.
* @param type Type of object to create.
* @param outputStream resulting output stream.
* @return A new instance of the outputstream-derived class.
*/
private Object createInstanceOfClass(Class type,OutputStream outputStream) {
try {
return getConstructorForClass(type).newInstance(outputStream);
}
catch( InstantiationException ex ) {
throw new StingException("Could not instantiate class with OutputStream constructor: " + type.getName());
}
catch( IllegalAccessException ex ) {
throw new StingException("Could not access class with OutputStream constructor: " + type.getName());
}
catch( InvocationTargetException ex ) {
throw new StingException("Could not invoke constructor for class with OutputStream constructor: " + type.getName());
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010 The Broad Institute
* Copyright (c) 2010, The Broad Institute
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@ -12,15 +12,14 @@
*
* 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.
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
package org.broadinstitute.sting.gatk.io.stubs;
@ -34,6 +33,7 @@ import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import net.sf.samtools.SAMFileReader;
import java.io.File;
import java.io.OutputStream;
/**
* Describe how to parse SAMFileReaders.

View File

@ -35,6 +35,7 @@ import java.lang.annotation.Annotation;
import java.util.List;
import java.util.Arrays;
import java.io.File;
import java.io.OutputStream;
/**
* Insert a SAMFileWriterStub instead of a full-fledged concrete OutputStream implementations.
@ -49,16 +50,22 @@ public class SAMFileWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor
/**
* The engine into which output stubs should be fed.
*/
private GenomeAnalysisEngine engine;
private final GenomeAnalysisEngine engine;
/**
* The default location to which data should be written if the user specifies no such location.
*/
private final OutputStream defaultOutputStream;
/**
* Create a new SAMFileWriter argument, notifying the given engine when that argument has been created.
* @param engine Engine to add SAMFileWriter output to.
* @param defaultOutputStream the target for the data
*/
public SAMFileWriterArgumentTypeDescriptor( GenomeAnalysisEngine engine ) {
public SAMFileWriterArgumentTypeDescriptor( GenomeAnalysisEngine engine, OutputStream defaultOutputStream ) {
this.engine = engine;
this.defaultOutputStream = defaultOutputStream;
}
@Override
public boolean supports( Class type ) {
@ -71,6 +78,18 @@ public class SAMFileWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor
createBAMCompressionArgumentDefinition(source) );
}
@Override
public boolean createsTypeDefault(ArgumentSource source,Class type) {
return true;
}
@Override
public Object createTypeDefault(ArgumentSource source,Class type) {
SAMFileWriterStub stub = new SAMFileWriterStub(engine,defaultOutputStream);
engine.addOutput(stub);
return stub;
}
@Override
public Object parse( ArgumentSource source, Class type, ArgumentMatches matches ) {
String writerFileName = getArgumentValue( createBAMArgumentDefinition(source), matches );

View File

@ -30,6 +30,7 @@ import net.sf.samtools.SAMRecord;
import net.sf.samtools.SAMFileHeader;
import java.io.File;
import java.io.OutputStream;
import org.broadinstitute.sting.gatk.io.OutputTracker;
import org.broadinstitute.sting.gatk.io.StingSAMFileWriter;
@ -59,6 +60,11 @@ public class SAMFileWriterStub implements Stub<SAMFileWriter>, StingSAMFileWrite
*/
private final File samFile;
/**
* The target output stream, to be used in place of the SAM file.
*/
private final OutputStream samOutputStream;
/**
* The validation stringency to apply when reading this file.
*/
@ -90,6 +96,18 @@ public class SAMFileWriterStub implements Stub<SAMFileWriter>, StingSAMFileWrite
public SAMFileWriterStub( GenomeAnalysisEngine engine, File samFile ) {
this.engine = engine;
this.samFile = samFile;
this.samOutputStream = null;
}
/**
* Create a new stub given the requested SAM file and compression level.
* @param engine source of header data, maybe other data about input files.
* @param stream Output stream to which data should be written.
*/
public SAMFileWriterStub( GenomeAnalysisEngine engine, OutputStream stream ) {
this.engine = engine;
this.samFile = null;
this.samOutputStream = stream;
}
/**
@ -100,6 +118,10 @@ public class SAMFileWriterStub implements Stub<SAMFileWriter>, StingSAMFileWrite
return samFile;
}
public OutputStream getSAMOutputStream() {
return samOutputStream;
}
/**
* Retrieves the header to use when creating the new SAM file.
* @return header to use when creating the new SAM file.

View File

@ -30,6 +30,7 @@ import org.broadinstitute.sting.utils.genotype.vcf.VCFWriter;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import java.io.File;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.util.List;
import java.util.Arrays;
@ -46,12 +47,19 @@ public class VCFWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor {
*/
private GenomeAnalysisEngine engine;
/**
* The default location to which data should be written if the user specifies no such location.
*/
private final OutputStream defaultOutputStream;
/**
* Create a new GenotypeWriter argument, notifying the given engine when that argument has been created.
* @param engine the engine to be notified.
* @param defaultOutputStream the default output stream to be written to if nothing else is specified.
*/
public VCFWriterArgumentTypeDescriptor(GenomeAnalysisEngine engine) {
public VCFWriterArgumentTypeDescriptor(GenomeAnalysisEngine engine, OutputStream defaultOutputStream) {
this.engine = engine;
this.defaultOutputStream = defaultOutputStream;
}
/**
@ -64,12 +72,6 @@ public class VCFWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor {
return VCFWriter.class.equals(type);
}
/**
* Create the argument definitions associated with this source.
* Assumes that this type descriptor is relevant for this source.
* @param source Source class and field for the given argument.
* @return A list of all associated argument definitions.
*/
@Override
public List<ArgumentDefinition> createArgumentDefinitions( ArgumentSource source ) {
return Arrays.asList( createGenotypeFileArgumentDefinition(source) );
@ -80,19 +82,15 @@ public class VCFWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor {
* @return true always.
*/
@Override
public boolean overridesDefault() {
public boolean createsTypeDefault(ArgumentSource source,Class type) {
return true;
}
/**
* Provide the default value for this argument.
* @return A VCFGenotypeWriter which writes to the default output stream.
*/
@Override
public Object getDefault() {
VCFWriterStub defaultGenotypeWriter = new VCFWriterStub(engine,System.out);
engine.addOutput(defaultGenotypeWriter);
return defaultGenotypeWriter;
public Object createTypeDefault(ArgumentSource source,Class type) {
VCFWriterStub stub = new VCFWriterStub(engine,defaultOutputStream);
engine.addOutput(stub);
return stub;
}
/**

View File

@ -27,6 +27,7 @@ package org.broadinstitute.sting.gatk.io.stubs;
import java.io.File;
import java.io.PrintStream;
import java.io.OutputStream;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broad.tribble.vcf.VCFHeader;
@ -83,10 +84,10 @@ public class VCFWriterStub implements Stub<VCFWriter>, VCFWriter {
* @param engine GATK engine.
* @param genotypeStream stream to (ultimately) write.
*/
public VCFWriterStub(GenomeAnalysisEngine engine,PrintStream genotypeStream) {
public VCFWriterStub(GenomeAnalysisEngine engine, OutputStream genotypeStream) {
this.engine = engine;
this.genotypeFile = null;
this.genotypeStream = genotypeStream;
this.genotypeStream = new PrintStream(genotypeStream);
}
/**

View File

@ -31,6 +31,7 @@ import net.sf.picard.reference.ReferenceSequenceFile;
import net.sf.picard.reference.ReferenceSequence;
import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.gatk.io.StingSAMFileWriter;
@ -41,6 +42,7 @@ import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.io.File;
import java.io.PrintStream;
import net.sf.samtools.util.StringUtil;
@ -50,6 +52,9 @@ import net.sf.samtools.util.StringUtil;
*/
@Requires({DataSource.READS})
public class ClipReadsWalker extends ReadWalker<ClipReadsWalker.ReadClipper, ClipReadsWalker.ClippingData> {
@Output
PrintStream out;
/**
* an optional argument to dump the reads out to a BAM file
*/

View File

@ -3,9 +3,11 @@ package org.broadinstitute.sting.gatk.walkers;
import net.sf.samtools.SAMRecord;
import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Output;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.io.PrintStream;
/*
@ -41,6 +43,9 @@ import java.text.NumberFormat;
*/
@Requires({DataSource.READS})
public class FlagStatWalker extends ReadWalker<Integer, Integer> {
@Output
PrintStream out;
// what comes out of the flagstat
static class FlagStat {
long readCount = 0L;

View File

@ -0,0 +1,43 @@
/*
* Copyright (c) 2010, 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 java.lang.annotation.*;
/**
* Indicates that the class should be multiplexed according to the rules
* specified in the multiplexer.
*
* @author mhanna
* @version 0.1
*/
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface Multiplex {
public Class<? extends Multiplexer> value();
public String[] arguments() default {};
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2010, 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 java.util.Collection;
/**
* An interface for multiplexing output streams.
*
* @author mhanna
* @version 0.1
*/
public interface Multiplexer<T> {
/**
* Generate a list of the potential outputs that can be created as a function of the other
* command-line arguments in this class.
* @return A collection of unique identifiers for the file multiplex.
*/
public Collection<T> multiplex();
/**
* Transform the given command-line argument into a suitable form specific to this filename.
* @param multiplexedEntry Identifies the individual component of the multiplex. Will be a value in the collection
* passed back by multiplex().
* @param argument The actual command-line argument, supplied for transformation.
* @return A transformed representation of the command-line argument.
*/
public String transformArgument(final T multiplexedEntry, final String argument);
}

View File

@ -35,11 +35,13 @@ import org.broadinstitute.sting.gatk.refdata.utils.helpers.DbSNPHelper;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.pileup.ReadBackedExtendedEventPileup;
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
import java.util.ArrayList;
import java.util.List;
import java.io.PrintStream;
/**
* Prints the alignment in the pileup format. In the pileup format, each line represents a genomic position,
@ -60,6 +62,9 @@ import java.util.List;
* samtools pileup [-f in.ref.fasta] [-t in.ref_list] [-l in.site_list] [-iscg] [-T theta] [-N nHap] [-r pairDiffRate] <in.alignment>
*/
public class PileupWalker extends LocusWalker<Integer, Integer> implements TreeReducible<Integer> {
@Output
PrintStream out;
@Argument(fullName="alwaysShowSecondBase",doc="If true, prints dummy bases for the second bases in the BAM file where they are missing",required=false)
public boolean alwaysShowSecondBase = false;
@ -160,4 +165,11 @@ public class PileupWalker extends LocusWalker<Integer, Integer> implements TreeR
return rodString;
}
@Override
public void onTraversalDone(Integer result) {
// Double check traversal result to make count is the same.
// TODO: Is this check necessary?
out.println("[REDUCE RESULT] Traversal result is: " + result);
}
}

View File

@ -30,14 +30,18 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.refdata.VariantContextAdaptors;
import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature;
import org.broadinstitute.sting.commandline.Output;
import java.util.Iterator;
import java.io.PrintStream;
/**
* Prints out all of the RODs in the input data set. Data is rendered using the toString() method
* of the given ROD.
*/
public class PrintRODsWalker extends RodWalker<Integer, Integer> {
@Output
PrintStream out;
/**
* Initialize the number of loci processed to zero.

View File

@ -33,6 +33,8 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.io.PrintStream;
/**
* Renders, in SAM/BAM format, all reads from the input data set in the order in which they appear
* in the input file. It can dynamically merge the contents of multiple input BAM files, resulting
@ -41,10 +43,9 @@ import org.broadinstitute.sting.commandline.Output;
*/
@Requires({DataSource.READS, DataSource.REFERENCE})
public class PrintReadsWalker extends ReadWalker<SAMRecord, SAMFileWriter> {
/** an optional argument to dump the reads out to a BAM file */
@Output(fullName = "outputBamFile", shortName = "of", doc = "Write output to this BAM filename instead of STDOUT", required = false)
SAMFileWriter outputBamFile = null;
@Output(doc="Write output to this BAM filename instead of STDOUT",required=false)
SAMFileWriter out;
@Argument(fullName = "readGroup", shortName = "readGroup", doc="Discard reads not belonging to the specified read group", required = false)
String readGroup = null;
@Argument(fullName = "platform", shortName = "platform", doc="Discard reads not generated by the specified platform", required = false)
@ -103,7 +104,7 @@ public class PrintReadsWalker extends ReadWalker<SAMRecord, SAMFileWriter> {
* @return SAMFileWriter, set to the BAM output file if the command line option was set, null otherwise
*/
public SAMFileWriter reduceInit() {
return outputBamFile;
return out;
}
/**
@ -113,12 +114,7 @@ public class PrintReadsWalker extends ReadWalker<SAMRecord, SAMFileWriter> {
* @return the SAMFileWriter, so that the next reduce can emit to the same source
*/
public SAMFileWriter reduce( SAMRecord read, SAMFileWriter output ) {
if (output != null) {
output.addAlignment(read);
} else {
out.println(read.format());
}
out.addAlignment(read);
return output;
}

View File

@ -35,6 +35,7 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils;
import org.broadinstitute.sting.gatk.refdata.*;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.refdata.utils.helpers.DbSNPHelper;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import org.broadinstitute.sting.utils.genotype.vcf.*;
@ -42,6 +43,7 @@ import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.SampleUtils;
import java.util.*;
import java.io.PrintStream;
/**
* Converts variants from other file formats to VCF format.
@ -49,6 +51,8 @@ import java.util.*;
@Requires(value={},referenceMetaData=@RMD(name=VariantsToVCF.INPUT_ROD_NAME,type= ReferenceOrderedDatum.class))
@Reference(window=@Window(start=0,stop=40))
public class VariantsToVCF extends RodWalker<Integer, Integer> {
@Output
private PrintStream out;
public static final String INPUT_ROD_NAME = "variant";
@ -126,7 +130,7 @@ public class VariantsToVCF extends RodWalker<Integer, Integer> {
}
}
vcfwriter = new VCFWriterImpl(out);
vcfwriter = new StandardVCFWriter(out);
vcfwriter.writeHeader(new VCFHeader(hInfo, samples));
}

View File

@ -25,16 +25,13 @@
package org.broadinstitute.sting.gatk.walkers;
import java.io.PrintStream;
import java.util.List;
import java.util.ArrayList;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.sting.gatk.filters.MalformedReadFilter;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.collections.Pair;
import org.apache.log4j.Logger;
import net.sf.picard.filter.SamRecordFilter;
/**
* Created by IntelliJ IDEA.
@ -47,16 +44,6 @@ import net.sf.picard.filter.SamRecordFilter;
public abstract class Walker<MapType, ReduceType> {
final protected static Logger logger = Logger.getLogger(Walker.class);
/**
* A stream for writing normal (non-error) output. System.out by default.
*/
protected PrintStream out = null;
/**
* A stream for writing error output. System.err by default.
*/
protected PrintStream err = null;
protected Walker() {
}
@ -134,7 +121,7 @@ public abstract class Walker<MapType, ReduceType> {
public abstract ReduceType reduce(MapType value, ReduceType sum);
public void onTraversalDone(ReduceType result) {
out.println("[REDUCE RESULT] Traversal result is: " + result);
logger.info("[REDUCE RESULT] Traversal result is: " + result);
}
/**
@ -143,7 +130,7 @@ public abstract class Walker<MapType, ReduceType> {
*/
public void onTraversalDone(List<Pair<GenomeLoc, ReduceType>> results) {
for ( Pair<GenomeLoc, ReduceType> result : results ) {
out.printf("[INTERVAL REDUCE RESULT] at %s ", result.getFirst());
logger.info(String.format("[INTERVAL REDUCE RESULT] at %s ", result.getFirst()));
this.onTraversalDone(result.getSecond());
}
}

View File

@ -44,11 +44,13 @@ import org.broadinstitute.sting.utils.classloader.PackageUtils;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.CommandLineUtils;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriter;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriterImpl;
import org.broadinstitute.sting.utils.genotype.vcf.StandardVCFWriter;
import java.util.*;
import java.io.PrintStream;
/**
@ -59,6 +61,8 @@ import java.util.*;
@Reference(window=@Window(start=-50,stop=50))
@By(DataSource.REFERENCE)
public class VariantAnnotator extends RodWalker<Integer, Integer> {
@Output
protected PrintStream out;
@Argument(fullName="sampleName", shortName="sample", doc="The sample (NA-ID) corresponding to the variant input (for non-VCF input only)", required=false)
protected String sampleName = null;
@ -154,7 +158,7 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
hInfo.add(new VCFHeaderLine("VariantAnnotator", "\"" + CommandLineUtils.createApproximateCommandLineArgumentString(getToolkit(), args, getClass()) + "\""));
}
vcfWriter = new VCFWriterImpl(out);
vcfWriter = new StandardVCFWriter(out);
VCFHeader vcfHeader = new VCFHeader(hInfo, samples);
vcfWriter.writeHeader(vcfHeader);

View File

@ -31,6 +31,7 @@ import org.broadinstitute.sting.gatk.walkers.LocusWalker;
import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.pileup.PileupElement;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.util.EnumMap;
import java.util.Map;
@ -47,6 +48,9 @@ import java.io.FileNotFoundException;
*/
@By(DataSource.REFERENCE)
public class CallableLociWalker extends LocusWalker<CallableLociWalker.CallableBaseState, CallableLociWalker.Integrator> {
@Output
PrintStream out;
@Argument(fullName = "maxLowMAPQ", shortName = "mlmq", doc = "Maximum value for MAPQ to be considered a problematic mapped read. The gap between this value and mmq are reads that are not sufficiently well mapped for calling but aren't indicative of mapping problems.", required = false)
byte maxLowMAPQ = 1;

View File

@ -31,6 +31,9 @@ import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.io.PrintStream;
/**
* Computes the coverage per every <granularity> bases on the reference, or on the subset of the reference
@ -38,6 +41,8 @@ import org.broadinstitute.sting.commandline.Argument;
* count anew, even if the count of bases in the last chunk on the previous contig did not reach specified <granularity>.
*/
public class CoarseCoverageWalker extends ReadWalker<Integer,Integer> {
@Output
public PrintStream out;
@Argument(fullName="granularity", shortName="G", doc="Granularity", required=true)
public Integer N;

View File

@ -30,14 +30,19 @@ import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broad.tribble.bed.FullBEDFeature;
import java.util.*;
import java.io.PrintStream;
/**
* Test routine for new VariantContext object
*/
public class CompareCallableLociWalker extends RodWalker<List<CallableLociWalker.CallableBaseState>, long[][]> {
@Output
protected PrintStream out;
@Argument(shortName="comp1", doc="First comparison track name", required=false)
protected String COMP1 = "comp1";

View File

@ -7,10 +7,7 @@ import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.pileup.PileupElement;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
/**
* IF THERE IS NO JAVADOC RIGHT HERE, YELL AT chartl
@ -41,24 +38,24 @@ public class CoverageUtils {
return counts;
}
public static String getTypeID( SAMReadGroupRecord r, CoverageAggregator.AggregationType type ) {
if ( type == CoverageAggregator.AggregationType.SAMPLE ) {
public static String getTypeID( SAMReadGroupRecord r, DoCOutputType.Partition type ) {
if ( type == DoCOutputType.Partition.sample ) {
return r.getSample();
} else if ( type == CoverageAggregator.AggregationType.READGROUP ) {
} else if ( type == DoCOutputType.Partition.readgroup ) {
return String.format("%s_rg_%s",r.getSample(),r.getReadGroupId());
} else if ( type == CoverageAggregator.AggregationType.LIBRARY ) {
} else if ( type == DoCOutputType.Partition.library ) {
return r.getLibrary();
} else {
throw new StingException("Invalid type ID sent to getTypeID. This is a BUG!");
}
}
public static Map<CoverageAggregator.AggregationType,Map<String,int[]>>
getBaseCountsByPartition(AlignmentContext context, int minMapQ, int maxMapQ, byte minBaseQ, byte maxBaseQ, List<CoverageAggregator.AggregationType> types) {
public static Map<DoCOutputType.Partition,Map<String,int[]>>
getBaseCountsByPartition(AlignmentContext context, int minMapQ, int maxMapQ, byte minBaseQ, byte maxBaseQ, Collection<DoCOutputType.Partition> types) {
Map<CoverageAggregator.AggregationType,Map<String,int[]>> countsByIDByType = new HashMap<CoverageAggregator.AggregationType,Map<String,int[]>>();
Map<DoCOutputType.Partition,Map<String,int[]>> countsByIDByType = new HashMap<DoCOutputType.Partition,Map<String,int[]>>();
Map<SAMReadGroupRecord,int[]> countsByRG = getBaseCountsByReadGroup(context,minMapQ,maxMapQ,minBaseQ,maxBaseQ);
for (CoverageAggregator.AggregationType t : types ) {
for (DoCOutputType.Partition t : types ) {
// iterate through the read group counts and build the type associations
for ( Map.Entry<SAMReadGroupRecord,int[]> readGroupCountEntry : countsByRG.entrySet() ) {
String typeID = getTypeID(readGroupCountEntry.getKey(),t);

View File

@ -30,21 +30,18 @@ import org.broad.tribble.FeatureSource;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedData;
import org.broadinstitute.sting.gatk.refdata.SeekableRODIterator;
import org.broadinstitute.sting.gatk.refdata.features.refseq.RefSeqCodec;
import org.broadinstitute.sting.gatk.refdata.features.refseq.RefSeqFeature;
import org.broadinstitute.sting.gatk.refdata.tracks.builders.TribbleRMDTrackBuilder;
import org.broadinstitute.sting.gatk.refdata.utils.*;
import org.broadinstitute.sting.gatk.walkers.By;
import org.broadinstitute.sting.gatk.walkers.DataSource;
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
import org.broadinstitute.sting.gatk.walkers.TreeReducible;
import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.io.File;
import java.io.IOException;
@ -67,7 +64,11 @@ import java.util.*;
// todo -- allow for user to set linear binning (default is logarithmic)
// todo -- formatting --> do something special for end bins in getQuantile(int[] foo), this gets mushed into the end+-1 bins for now
@By(DataSource.REFERENCE)
public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.AggregationType,Map<String,int[]>>, CoverageAggregator> implements TreeReducible<CoverageAggregator> {
public class DepthOfCoverageWalker extends LocusWalker<Map<DoCOutputType.Partition,Map<String,int[]>>, CoveragePartitioner> implements TreeReducible<CoveragePartitioner> {
@Output
@Multiplex(value=DoCOutputMultiplexer.class,arguments={"partitionTypes","refSeqGeneList","omitDepthOutput","omitIntervals","omitSampleSummary","omitLocusTable"})
Map<DoCOutputType,PrintStream> out;
@Argument(fullName = "start", doc = "Starting (left endpoint) for granular binning", required = false)
int start = 1;
@Argument(fullName = "stop", doc = "Ending (right endpoint) for granular binning", required = false)
@ -95,7 +96,7 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
@Argument(fullName = "omitPerSampleStats", shortName = "omitSampleSummary", doc = "Omits the summary files per-sample. These statistics are still calculated, so this argument will not improve runtime.", required = false)
boolean omitSampleSummary = false;
@Argument(fullName = "partitionType", shortName = "pt", doc = "Partition type for depth of coverage. Defaults to sample. Can be any combination of sample, readgroup, library.", required = false)
String[] partitionTypes = new String[] {"sample"};
Set<DoCOutputType.Partition> partitionTypes = EnumSet.of(DoCOutputType.Partition.sample);
@Argument(fullName = "includeDeletions", shortName = "dels", doc = "Include information on deletions", required = false)
boolean includeDeletions = false;
@Argument(fullName = "ignoreDeletionSites", doc = "Ignore sites consisting only of deletions", required = false)
@ -108,10 +109,8 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
int[] coverageThresholds = {15};
String[] OUTPUT_FORMATS = {"table","rtable","csv"};
String[] PARTITION_TYPES = {"sample","readgroup","library"};
String separator = "\t";
List<CoverageAggregator.AggregationType> aggregationTypes = new ArrayList<CoverageAggregator.AggregationType>();
Map<CoverageAggregator.AggregationType,List<String>> orderCheck = new HashMap<CoverageAggregator.AggregationType,List<String>>();
Map<DoCOutputType.Partition,List<String>> orderCheck = new HashMap<DoCOutputType.Partition,List<String>>();
////////////////////////////////////////////////////////////////////////////////////
// STANDARD WALKER METHODS
@ -145,33 +144,17 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
separator = ",";
}
// Check the partition types
for ( String t : partitionTypes ) {
boolean valid = false;
for ( String s : PARTITION_TYPES ) {
if ( s.equalsIgnoreCase(t) ) {
valid = true;
}
}
if ( ! valid ) {
throw new StingException("The partition type '"+t+"' is not a valid partition type. Please use any combination of 'sample','readgroup','library'.");
} else {
aggregationTypes.add(CoverageAggregator.typeStringToAggregationType(t));
}
}
if ( getToolkit().getArguments().outFileName == null ) {
logger.warn("This walker creates many output files from one input file; you may wish to specify an input file rather "+
"than defaulting all output to stdout.");
}
if ( ! omitDepthOutput ) { // print header
PrintStream out = getCorrectStream(null, DoCOutputType.Aggregation.locus, DoCOutputType.FileType.summary);
out.printf("%s\t%s","Locus","Total_Depth");
for (CoverageAggregator.AggregationType type : aggregationTypes ) {
out.printf("\t%s_%s","Average_Depth",agTypeToString(type));
for (DoCOutputType.Partition type : partitionTypes ) {
// mhanna 22 Aug 2010 - Deliberately force this header replacement to make sure integration tests pass.
// TODO: Update integration tests and get rid of this.
String typeName = (type == DoCOutputType.Partition.readgroup ? "read_group" : type.toString());
out.printf("\t%s_%s","Average_Depth",typeName);
}
// get all the samples
HashSet<String> allSamples = getSamplesFromToolKit(aggregationTypes);
HashSet<String> allSamples = getSamplesFromToolKit(partitionTypes);
for ( String s : allSamples) {
out.printf("\t%s_%s","Depth_for",s);
@ -183,10 +166,10 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
out.printf("%n");
} else {
out.printf("Per-Locus Depth of Coverage output was omitted");
logger.info("Per-Locus Depth of Coverage output was omitted");
}
for (CoverageAggregator.AggregationType type : aggregationTypes ) {
for (DoCOutputType.Partition type : partitionTypes ) {
orderCheck.put(type,new ArrayList<String>());
for ( String id : getSamplesFromToolKit(type) ) {
orderCheck.get(type).add(id);
@ -195,28 +178,28 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
}
}
private HashSet<String> getSamplesFromToolKit( List<CoverageAggregator.AggregationType> types ) {
private HashSet<String> getSamplesFromToolKit( Collection<DoCOutputType.Partition> types ) {
HashSet<String> partitions = new HashSet<String>(); // since the DOCS object uses a HashMap, this will be in the same order
for (CoverageAggregator.AggregationType t : types ) {
for (DoCOutputType.Partition t : types ) {
partitions.addAll(getSamplesFromToolKit(t));
}
return partitions;
}
private HashSet<String> getSamplesFromToolKit(CoverageAggregator.AggregationType type) {
private HashSet<String> getSamplesFromToolKit(DoCOutputType.Partition type) {
HashSet<String> partition = new HashSet<String>();
if ( type == CoverageAggregator.AggregationType.SAMPLE ) {
if ( type == DoCOutputType.Partition.sample ) {
for ( Set<String> sampleSet : getToolkit().getSamplesByReaders() ) {
for ( String s : sampleSet ) {
partition.add(s);
}
}
} else if ( type == CoverageAggregator.AggregationType.READGROUP ) {
} else if ( type == DoCOutputType.Partition.readgroup ) {
for ( SAMReadGroupRecord rg : getToolkit().getSAMFileHeader().getReadGroups() ) {
partition.add(rg.getSample()+"_rg_"+rg.getReadGroupId());
}
} else if ( type == CoverageAggregator.AggregationType.LIBRARY ) {
} else if ( type == DoCOutputType.Partition.library ) {
for ( Set<String> libraries : getToolkit().getLibrariesByReaders() ) {
for ( String l : libraries ) {
partition.add(l);
@ -233,9 +216,9 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
return ( ! omitIntervals );
}
public CoverageAggregator reduceInit() {
CoverageAggregator aggro = new CoverageAggregator(aggregationTypes,start,stop,nBins);
for (CoverageAggregator.AggregationType t : aggregationTypes ) {
public CoveragePartitioner reduceInit() {
CoveragePartitioner aggro = new CoveragePartitioner(partitionTypes,start,stop,nBins);
for (DoCOutputType.Partition t : partitionTypes ) {
aggro.addIdentifiers(t,getSamplesFromToolKit(t));
}
aggro.initialize(includeDeletions,omitLocusTable);
@ -243,19 +226,19 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
return aggro;
}
public Map<CoverageAggregator.AggregationType,Map<String,int[]>> map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
public Map<DoCOutputType.Partition,Map<String,int[]>> map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
if ( ! omitDepthOutput ) {
out.printf("%s",ref.getLocus()); // yes: print locus in map, and the rest of the info in reduce (for eventual cumulatives)
getCorrectStream(null, DoCOutputType.Aggregation.locus, DoCOutputType.FileType.summary).printf("%s",ref.getLocus()); // yes: print locus in map, and the rest of the info in reduce (for eventual cumulatives)
//System.out.printf("\t[log]\t%s",ref.getLocus());
}
return CoverageUtils.getBaseCountsByPartition(context,minMappingQuality,maxMappingQuality,minBaseQuality,maxBaseQuality,aggregationTypes);
return CoverageUtils.getBaseCountsByPartition(context,minMappingQuality,maxMappingQuality,minBaseQuality,maxBaseQuality,partitionTypes);
}
public CoverageAggregator reduce(Map<CoverageAggregator.AggregationType,Map<String,int[]>> thisMap, CoverageAggregator prevReduce) {
public CoveragePartitioner reduce(Map<DoCOutputType.Partition,Map<String,int[]>> thisMap, CoveragePartitioner prevReduce) {
if ( ! omitDepthOutput ) {
printDepths(out,thisMap, prevReduce.getIdentifiersByType());
printDepths(getCorrectStream(null, DoCOutputType.Aggregation.locus, DoCOutputType.FileType.summary),thisMap,prevReduce.getIdentifiersByType());
// this is an additional iteration through thisMap, plus dealing with IO, so should be much slower without
// turning on omit
}
@ -265,7 +248,7 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
return prevReduce;
}
public CoverageAggregator treeReduce(CoverageAggregator left, CoverageAggregator right) {
public CoveragePartitioner treeReduce(CoveragePartitioner left, CoveragePartitioner right) {
left.merge(right);
return left;
}
@ -274,55 +257,34 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
// INTERVAL ON TRAVERSAL DONE
////////////////////////////////////////////////////////////////////////////////////
public void onTraversalDone( List<Pair<GenomeLoc,CoverageAggregator>> statsByInterval ) {
if ( refSeqGeneList != null && aggregationTypes.contains(CoverageAggregator.AggregationType.SAMPLE ) ) {
public void onTraversalDone( List<Pair<GenomeLoc, CoveragePartitioner>> statsByInterval ) {
if ( refSeqGeneList != null && partitionTypes.contains(DoCOutputType.Partition.sample) ) {
printGeneStats(statsByInterval);
}
if ( aggregationTypes.contains(CoverageAggregator.AggregationType.SAMPLE) ) {
File intervalStatisticsFile = deriveFromStream("sample_interval_statistics");
File intervalSummaryFile = deriveFromStream("sample_interval_summary");
printIntervalStats(statsByInterval,intervalSummaryFile, intervalStatisticsFile, CoverageAggregator.AggregationType.SAMPLE );
}
if ( aggregationTypes.contains(CoverageAggregator.AggregationType.READGROUP ) ) {
File intervalStatisticsFile = deriveFromStream("read_group_interval_statistics");
File intervalSummaryFile = deriveFromStream("read_group_interval_summary");
printIntervalStats(statsByInterval,intervalSummaryFile, intervalStatisticsFile, CoverageAggregator.AggregationType.READGROUP);
}
if ( aggregationTypes.contains(CoverageAggregator.AggregationType.LIBRARY) ) {
File intervalStatisticsFile = deriveFromStream("library_interval_statistics");
File intervalSummaryFile = deriveFromStream("library_interval_summary");
printIntervalStats(statsByInterval,intervalSummaryFile,intervalStatisticsFile,CoverageAggregator.AggregationType.LIBRARY);
for(DoCOutputType.Partition partition: partitionTypes) {
printIntervalStats(statsByInterval,
getCorrectStream(partition, DoCOutputType.Aggregation.interval, DoCOutputType.FileType.summary),
getCorrectStream(partition, DoCOutputType.Aggregation.interval, DoCOutputType.FileType.statistics),
partition);
}
onTraversalDone(mergeAll(statsByInterval));
}
public CoverageAggregator mergeAll(List<Pair<GenomeLoc,CoverageAggregator>> stats) {
CoverageAggregator first = stats.remove(0).second;
for ( Pair<GenomeLoc,CoverageAggregator> iStat : stats ) {
public CoveragePartitioner mergeAll(List<Pair<GenomeLoc, CoveragePartitioner>> stats) {
CoveragePartitioner first = stats.remove(0).second;
for ( Pair<GenomeLoc, CoveragePartitioner> iStat : stats ) {
treeReduce(first,iStat.second);
}
return first;
}
private DepthOfCoverageStats printIntervalStats(List<Pair<GenomeLoc,CoverageAggregator>> statsByInterval, File summaryFile, File statsFile, CoverageAggregator.AggregationType type) {
PrintStream summaryOut;
PrintStream statsOut;
try {
summaryOut = summaryFile == null ? out : new PrintStream(summaryFile);
statsOut = statsFile == null ? out : new PrintStream(statsFile);
} catch ( IOException e ) {
throw new StingException("Unable to open interval file on reduce", e);
}
Pair<GenomeLoc,CoverageAggregator> firstPair = statsByInterval.get(0);
CoverageAggregator firstAggregator = firstPair.second;
private DepthOfCoverageStats printIntervalStats(List<Pair<GenomeLoc, CoveragePartitioner>> statsByInterval, PrintStream summaryOut, PrintStream statsOut, DoCOutputType.Partition type) {
Pair<GenomeLoc, CoveragePartitioner> firstPair = statsByInterval.get(0);
CoveragePartitioner firstAggregator = firstPair.second;
DepthOfCoverageStats firstStats = firstAggregator.getCoverageByAggregationType(type);
StringBuilder summaryHeader = new StringBuilder();
@ -360,7 +322,7 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
int[][] nTargetsByAvgCvgBySample = new int[firstStats.getHistograms().size()][firstStats.getEndpoints().length+1];
for ( Pair<GenomeLoc,CoverageAggregator> targetAggregator : statsByInterval ) {
for ( Pair<GenomeLoc, CoveragePartitioner> targetAggregator : statsByInterval ) {
Pair<GenomeLoc,DepthOfCoverageStats> targetStats = new Pair<GenomeLoc,DepthOfCoverageStats>(
targetAggregator.first, targetAggregator.second.getCoverageByAggregationType(type));
@ -370,39 +332,29 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
printIntervalTable(statsOut,nTargetsByAvgCvgBySample,firstStats.getEndpoints());
if ( getToolkit().getArguments().outErrFileName != null && ! getToolkit().getArguments().outFileName.contains("stdout")) {
summaryOut.close();
statsOut.close();
}
return firstStats;
}
private void printGeneStats(List<Pair<GenomeLoc,CoverageAggregator>> statsByTarget) {
private void printGeneStats(List<Pair<GenomeLoc, CoveragePartitioner>> statsByTarget) {
LocationAwareSeekableRODIterator refseqIterator = initializeRefSeq();
List<Pair<String,DepthOfCoverageStats>> statsByGene = new ArrayList<Pair<String,DepthOfCoverageStats>>();// maintains order
Map<String,DepthOfCoverageStats> geneNamesToStats = new HashMap<String,DepthOfCoverageStats>(); // allows indirect updating of objects in list
for ( Pair<GenomeLoc,CoverageAggregator> targetStats : statsByTarget ) {
for ( Pair<GenomeLoc, CoveragePartitioner> targetStats : statsByTarget ) {
String gene = getGeneName(targetStats.first,refseqIterator);
if ( geneNamesToStats.keySet().contains(gene) ) {
geneNamesToStats.get(gene).merge(targetStats.second.getCoverageByAggregationType(CoverageAggregator.AggregationType.SAMPLE));
geneNamesToStats.get(gene).merge(targetStats.second.getCoverageByAggregationType(DoCOutputType.Partition.sample));
} else {
geneNamesToStats.put(gene,new DepthOfCoverageStats(targetStats.second.getCoverageByAggregationType(CoverageAggregator.AggregationType.SAMPLE)));
statsByGene.add(new Pair<String,DepthOfCoverageStats>(gene,new DepthOfCoverageStats(targetStats.second.getCoverageByAggregationType(CoverageAggregator.AggregationType.SAMPLE))));
geneNamesToStats.put(gene,new DepthOfCoverageStats(targetStats.second.getCoverageByAggregationType(DoCOutputType.Partition.sample)));
statsByGene.add(new Pair<String,DepthOfCoverageStats>(gene,new DepthOfCoverageStats(targetStats.second.getCoverageByAggregationType(DoCOutputType.Partition.sample))));
}
}
PrintStream geneSummaryOut = getCorrectStream(out,deriveFromStream("gene_summary"));
PrintStream geneSummaryOut = getCorrectStream(DoCOutputType.Partition.sample, DoCOutputType.Aggregation.gene, DoCOutputType.FileType.summary);
for ( Pair<String,DepthOfCoverageStats> geneStats : statsByGene ) {
printTargetSummary(geneSummaryOut,geneStats);
}
if ( ! getToolkit().getArguments().outFileName.contains("stdout")) {
geneSummaryOut.close();
}
}
//blatantly stolen from Andrew Kernytsky
@ -530,66 +482,42 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
// FINAL ON TRAVERSAL DONE
////////////////////////////////////////////////////////////////////////////////////
public void onTraversalDone(CoverageAggregator coverageProfiles) {
public void onTraversalDone(CoveragePartitioner coverageProfiles) {
///////////////////
// OPTIONAL OUTPUTS
//////////////////
if ( ! omitSampleSummary ) {
logger.info("Printing summary info");
for (CoverageAggregator.AggregationType type : aggregationTypes ) {
for (DoCOutputType.Partition type : partitionTypes ) {
outputSummaryFiles(coverageProfiles,type);
}
}
if ( ! omitLocusTable ) {
logger.info("Printing locus summary");
for (CoverageAggregator.AggregationType type : aggregationTypes ) {
for (DoCOutputType.Partition type : partitionTypes ) {
outputLocusFiles(coverageProfiles,type);
}
}
}
private String agTypeToString(CoverageAggregator.AggregationType type) {
if ( type == CoverageAggregator.AggregationType.SAMPLE ) {
return "sample";
} else if ( type == CoverageAggregator.AggregationType.READGROUP ) {
return "read_group";
} else if ( type == CoverageAggregator.AggregationType.LIBRARY ) {
return "library";
} else {
throw new StingException("Invalid aggregation type "+type+" sent to agTypeToString. This is a BUG!");
}
private void outputLocusFiles(CoveragePartitioner coverageProfiles, DoCOutputType.Partition type ) {
printPerLocus(getCorrectStream(type, DoCOutputType.Aggregation.cumulative, DoCOutputType.FileType.coverage_counts),
getCorrectStream(type, DoCOutputType.Aggregation.cumulative, DoCOutputType.FileType.coverage_proportions),
coverageProfiles.getCoverageByAggregationType(type),type);
}
private void outputLocusFiles(CoverageAggregator coverageProfiles, CoverageAggregator.AggregationType type ) {
File locusStats = deriveFromStream(agTypeToString(type)+"_cumulative_coverage_counts");
File coverageStats = deriveFromStream(agTypeToString(type)+"_cumulative_coverage_proportions");
printPerLocus(locusStats,coverageStats,coverageProfiles.getCoverageByAggregationType(type),agTypeToString(type));
}
private void outputSummaryFiles(CoverageAggregator coverageProfiles, CoverageAggregator.AggregationType type ) {
File summaryFile = deriveFromStream(agTypeToString(type)+"_summary");
File statsFile = deriveFromStream(agTypeToString(type)+"_statistics");
printPerSample(out,statsFile,coverageProfiles.getCoverageByAggregationType(type));
printSummary(out,summaryFile,coverageProfiles.getCoverageByAggregationType(type));
}
public File deriveFromStream(String append) {
String name = getToolkit().getArguments().outFileName;
if ( name == null || name.contains("stdout") || name.contains("Stdout") || name.contains("STDOUT")) {
return null;
} else {
return new File(name+"."+append);
}
private void outputSummaryFiles(CoveragePartitioner coverageProfiles, DoCOutputType.Partition type ) {
printPerSample(getCorrectStream(type, DoCOutputType.Aggregation.cumulative, DoCOutputType.FileType.statistics),coverageProfiles.getCoverageByAggregationType(type));
printSummary(getCorrectStream(type, DoCOutputType.Aggregation.cumulative, DoCOutputType.FileType.summary),coverageProfiles.getCoverageByAggregationType(type));
}
////////////////////////////////////////////////////////////////////////////////////
// HELPER OUTPUT METHODS
////////////////////////////////////////////////////////////////////////////////////
private void printPerSample(PrintStream out, File optionalFile, DepthOfCoverageStats stats) {
PrintStream output = getCorrectStream(out,optionalFile);
private void printPerSample(PrintStream output,DepthOfCoverageStats stats) {
int[] leftEnds = stats.getEndpoints();
StringBuilder hBuilder = new StringBuilder();
@ -615,13 +543,7 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
}
}
private void printPerLocus(File locusFile, File coverageFile, DepthOfCoverageStats stats, String partitionType) {
PrintStream output = getCorrectStream(out,locusFile);
PrintStream coverageOut = getCorrectStream(out,coverageFile);
if ( output == null ) {
return;
}
private void printPerLocus(PrintStream output, PrintStream coverageOut, DepthOfCoverageStats stats, DoCOutputType.Partition partitionType) {
int[] endpoints = stats.getEndpoints();
int samples = stats.getHistograms().size();
@ -634,7 +556,9 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
StringBuilder header = new StringBuilder();
if ( printSampleColumnHeader ) {
header.append(partitionType);
// mhanna 22 Aug 2010 - Deliberately force this header replacement to make sure integration tests pass.
// TODO: Update integration tests and get rid of this.
header.append(partitionType == DoCOutputType.Partition.readgroup ? "read_group" : partitionType.toString());
}
header.append(String.format("%sgte_0",separator));
for ( int d : endpoints ) {
@ -663,24 +587,14 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
}
}
private PrintStream getCorrectStream(PrintStream out, File optionalFile) {
PrintStream output;
if ( optionalFile == null ) {
output = out;
} else {
try {
output = new PrintStream(optionalFile);
} catch ( IOException e ) {
logger.warn("Error opening the output file "+optionalFile.getAbsolutePath()+". Defaulting to stdout");
output = out;
}
}
return output;
private PrintStream getCorrectStream(DoCOutputType.Partition partition, DoCOutputType.Aggregation aggregation, DoCOutputType.FileType fileType) {
DoCOutputType outputType = new DoCOutputType(partition,aggregation,fileType);
if(!out.containsKey(outputType))
throw new StingException(String.format("Unable to find appropriate stream for partition = %s, aggregation = %s, file type = %s",partition,aggregation,fileType));
return out.get(outputType);
}
private void printSummary(PrintStream out, File optionalFile, DepthOfCoverageStats stats) {
PrintStream output = getCorrectStream(out,optionalFile);
private void printSummary(PrintStream output, DepthOfCoverageStats stats) {
if ( ! outputFormat.equals("csv") ) {
output.printf("%s\t%s\t%s\t%s\t%s\t%s","sample_id","total","mean","granular_third_quartile","granular_median","granular_first_quartile");
} else {
@ -759,12 +673,12 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
return 100*( (double) above )/( above + below );
}
private void printDepths(PrintStream stream, Map<CoverageAggregator.AggregationType,Map<String,int[]>> countsBySampleByType, Map<CoverageAggregator.AggregationType,List<String>> identifiersByType) {
private void printDepths(PrintStream stream, Map<DoCOutputType.Partition,Map<String,int[]>> countsBySampleByType, Map<DoCOutputType.Partition,List<String>> identifiersByType) {
// get the depths per sample and build up the output string while tabulating total and average coverage
StringBuilder perSampleOutput = new StringBuilder();
int tDepth = 0;
boolean depthCounted = false;
for (CoverageAggregator.AggregationType type : aggregationTypes ) {
for (DoCOutputType.Partition type : partitionTypes ) {
Map<String,int[]> countsByID = countsBySampleByType.get(type);
for ( String s : identifiersByType.get(type) ) {
perSampleOutput.append(separator);
@ -783,7 +697,7 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
// remember -- genome locus was printed in map()
stream.printf("%s%d",separator,tDepth);
for (CoverageAggregator.AggregationType type : aggregationTypes ) {
for (DoCOutputType.Partition type : partitionTypes ) {
stream.printf("%s%.2f",separator, ( (double) tDepth / identifiersByType.get(type).size() ) );
}
stream.printf("%s%n",perSampleOutput);
@ -818,8 +732,8 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
return s.toString();
}
private void checkOrder(CoverageAggregator ag) {
for (CoverageAggregator.AggregationType t : aggregationTypes ) {
private void checkOrder(CoveragePartitioner ag) {
for (DoCOutputType.Partition t : partitionTypes ) {
List<String> order = orderCheck.get(t);
List<String> namesInAg = ag.getIdentifiersByType().get(t);
@ -834,38 +748,105 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<CoverageAggregator.Ag
}
}
}
}
class CoverageAggregator {
class DoCOutputMultiplexer implements Multiplexer<DoCOutputType> {
private final Set<DoCOutputType.Partition> partitions;
private final File refSeqGeneList;
private final boolean omitDepthOutput;
private final boolean omitIntervals;
private final boolean omitSampleSummary;
private final boolean omitLocusTable;
enum AggregationType { READGROUP, SAMPLE, LIBRARY }
/**
* Create a new multiplexer type using the values of all variable fields.
* @param partitions
* @param refSeqGeneList
* @param omitDepthOutput
* @param omitIntervals
* @param omitSampleSummary
* @param omitLocusTable
*/
public DoCOutputMultiplexer(final Set<DoCOutputType.Partition> partitions,
final File refSeqGeneList,
final boolean omitDepthOutput,
final boolean omitIntervals,
final boolean omitSampleSummary,
final boolean omitLocusTable) {
this.partitions = partitions;
this.refSeqGeneList = refSeqGeneList;
this.omitDepthOutput = omitDepthOutput;
this.omitIntervals = omitIntervals;
this.omitSampleSummary = omitSampleSummary;
this.omitLocusTable = omitLocusTable;
}
private List<AggregationType> types;
private Map<AggregationType,DepthOfCoverageStats> coverageProfiles;
private Map<AggregationType,List<String>> identifiersByType;
public Collection<DoCOutputType> multiplex() {
List<DoCOutputType> outputs = new ArrayList<DoCOutputType>();
if(!omitDepthOutput) outputs.add(new DoCOutputType(null, DoCOutputType.Aggregation.locus, DoCOutputType.FileType.summary));
if(!omitIntervals) {
for(DoCOutputType.Partition partition: partitions) {
outputs.add(new DoCOutputType(partition, DoCOutputType.Aggregation.interval, DoCOutputType.FileType.summary));
outputs.add(new DoCOutputType(partition, DoCOutputType.Aggregation.interval, DoCOutputType.FileType.statistics));
}
}
if(refSeqGeneList != null && partitions.contains(DoCOutputType.Partition.sample)) {
DoCOutputType geneSummaryOut = new DoCOutputType(DoCOutputType.Partition.sample, DoCOutputType.Aggregation.gene, DoCOutputType.FileType.summary);
outputs.add(geneSummaryOut);
}
if(!omitSampleSummary) {
for(DoCOutputType.Partition partition: partitions) {
outputs.add(new DoCOutputType(partition, DoCOutputType.Aggregation.cumulative, DoCOutputType.FileType.summary));
outputs.add(new DoCOutputType(partition, DoCOutputType.Aggregation.cumulative, DoCOutputType.FileType.statistics));
}
}
if(!omitLocusTable) {
for(DoCOutputType.Partition partition: partitions) {
outputs.add(new DoCOutputType(partition, DoCOutputType.Aggregation.cumulative, DoCOutputType.FileType.coverage_counts));
outputs.add(new DoCOutputType(partition, DoCOutputType.Aggregation.cumulative, DoCOutputType.FileType.coverage_proportions));
}
}
return outputs;
}
public String transformArgument(final DoCOutputType outputType, final String argument) {
return outputType.getFileName(argument);
}
}
class CoveragePartitioner {
private Collection<DoCOutputType.Partition> types;
private Map<DoCOutputType.Partition,DepthOfCoverageStats> coverageProfiles;
private Map<DoCOutputType.Partition,List<String>> identifiersByType;
private Set<String> allIdentifiers;
public CoverageAggregator(List<AggregationType> typesToUse, int start, int stop, int nBins) {
coverageProfiles = new HashMap<AggregationType,DepthOfCoverageStats>();
identifiersByType = new HashMap<AggregationType,List<String>>();
public CoveragePartitioner(Collection<DoCOutputType.Partition> typesToUse, int start, int stop, int nBins) {
coverageProfiles = new HashMap<DoCOutputType.Partition,DepthOfCoverageStats>();
identifiersByType = new HashMap<DoCOutputType.Partition,List<String>>();
types = typesToUse;
for ( AggregationType type : types ) {
for ( DoCOutputType.Partition type : types ) {
coverageProfiles.put(type,new DepthOfCoverageStats(DepthOfCoverageStats.calculateBinEndpoints(start,stop,nBins)));
identifiersByType.put(type,new ArrayList<String>());
}
allIdentifiers = new HashSet<String>();
}
public void merge(CoverageAggregator otherAggregator) {
for ( AggregationType type : types ) {
public void merge(CoveragePartitioner otherAggregator) {
for ( DoCOutputType.Partition type : types ) {
this.coverageProfiles.get(type).merge(otherAggregator.coverageProfiles.get(type));
}
}
public DepthOfCoverageStats getCoverageByAggregationType(AggregationType t) {
public DepthOfCoverageStats getCoverageByAggregationType(DoCOutputType.Partition t) {
return coverageProfiles.get(t);
}
public void addIdentifiers(AggregationType t, Set<String> ids) {
public void addIdentifiers(DoCOutputType.Partition t, Set<String> ids) {
for ( String s : ids ) {
coverageProfiles.get(t).addSample(s);
identifiersByType.get(t).add(s);
@ -875,7 +856,7 @@ class CoverageAggregator {
}
public void initialize(boolean useDels, boolean omitLocusTable) {
for ( AggregationType t : types ) {
for ( DoCOutputType.Partition t : types ) {
if ( useDels ) {
coverageProfiles.get(t).initializeDeletions();
}
@ -885,8 +866,8 @@ class CoverageAggregator {
}
}
public void update(Map<AggregationType,Map<String,int[]>> countsByIdentifierByType) {
for ( AggregationType t : types ) {
public void update(Map<DoCOutputType.Partition,Map<String,int[]>> countsByIdentifierByType) {
for ( DoCOutputType.Partition t : types ) {
coverageProfiles.get(t).update(countsByIdentifierByType.get(t));
}
}
@ -895,23 +876,7 @@ class CoverageAggregator {
return allIdentifiers;
}
public Map<AggregationType,List<String>> getIdentifiersByType() {
public Map<DoCOutputType.Partition,List<String>> getIdentifiersByType() {
return identifiersByType;
}
public static AggregationType typeStringToAggregationType(String type) {
if ( type.equals("sample") ) {
return AggregationType.SAMPLE;
}
if ( type.equals("library") ) {
return AggregationType.LIBRARY;
}
if ( type.equals("readgroup") ) {
return AggregationType.READGROUP;
}
throw new StingException("Valid partition type string "+type+" is not associated with an aggregation type. This is a BUG!");
}
}

View File

@ -0,0 +1,85 @@
/*
* Copyright (c) 2010, 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.coverage;
/**
* Models a single output file in the DoC walker.
*
* @author mhanna
* @version 0.1
*/
public class DoCOutputType {
public enum Partition { readgroup, sample, library }
public enum Aggregation { locus, interval, gene, cumulative }
public enum FileType { summary, statistics, coverage_counts, coverage_proportions }
private final Partition partition;
private final Aggregation aggregation;
private final FileType fileType;
public DoCOutputType(final Partition partition,
final Aggregation aggregation,
final FileType fileType) {
this.partition = partition;
this.aggregation = aggregation;
this.fileType = fileType;
}
public String getFileName(final String baseName) {
// main output
if(partition == null)
return baseName;
// mhanna 22 Aug 2010 - Deliberately force this header replacement to make sure integration tests pass.
// TODO: Update integration tests and get rid of this.
String partitionType = (partition == DoCOutputType.Partition.readgroup ? "read_group" : partition.toString());
if(fileType == FileType.coverage_counts || fileType == FileType.coverage_proportions) {
// coverage counts / proportions files always include aggregation.
return baseName + "." +
partitionType + "_" +
aggregation + "_" +
fileType;
}
return baseName + "." +
partitionType + "_" +
(aggregation == Aggregation.interval || aggregation == Aggregation.gene ? aggregation + "_" : "") +
fileType;
}
public int hashCode() {
return (partition!=null?partition.ordinal()+1:0) * aggregation.ordinal() * fileType.ordinal();
}
public boolean equals(Object other) {
if(!(other instanceof DoCOutputType))
return false;
DoCOutputType otherOutputType = (DoCOutputType)other;
return partition == otherOutputType.partition &&
aggregation == otherOutputType.aggregation &&
fileType == otherOutputType.fileType;
}
}

View File

@ -32,6 +32,7 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import net.sf.samtools.SAMRecord;
import java.io.*;
@ -42,6 +43,8 @@ import java.io.*;
*/
@WalkerName("BamToFastq")
public class BamToFastqWalker extends ReadWalker<Integer, Integer> {
@Output
private PrintStream out;
@Argument(fullName="re_reverse", shortName="reverse", doc="re-reverse bases and quals of reads from the negative strand", required=false)
private Boolean RE_REVERSE = false;

View File

@ -34,6 +34,9 @@ import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.io.PrintStream;
/**
* Renders a new reference in FASTA format consisting of only those loci provided in the input data set. Has optional
@ -41,6 +44,7 @@ import org.broadinstitute.sting.commandline.Argument;
*/
@WalkerName("FastaReferenceMaker")
public class FastaReferenceWalker extends RefWalker<Pair<GenomeLoc, String>, GenomeLoc> {
@Output PrintStream out;
@Argument(fullName="lineWidth", shortName="lw", doc="Maximum length of sequence to write per line", required=false) public int fastaLineWidth=60;
@Argument(fullName="rawOnelineSeq", shortName="raw", doc="Print sequences with no FASTA header lines, one line per interval (i.e. lineWidth = infinity) - CAUTION: adjacent intervals will automatically be merged", required=false) public boolean fastaRawSeqs=false;

View File

@ -38,11 +38,13 @@ import org.broadinstitute.sting.gatk.refdata.VariantContextAdaptors;
import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.CommandLineUtils;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriter;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriterImpl;
import org.broadinstitute.sting.utils.genotype.vcf.StandardVCFWriter;
import java.util.*;
import java.io.PrintStream;
/**
@ -51,6 +53,8 @@ import java.util.*;
@Requires(value={},referenceMetaData=@RMD(name="variant", type=ReferenceOrderedDatum.class))
@Reference(window=@Window(start=-50,stop=50))
public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
@Output
protected PrintStream out;
@Argument(fullName="filterExpression", shortName="filter", doc="One or more expression used with INFO fields to filter (see wiki docs for more info)", required=false)
protected ArrayList<String> FILTER_EXPS = new ArrayList<String>();
@ -119,7 +123,7 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
hInfo.add(new VCFHeaderLine("VariantFiltration", "\"" + CommandLineUtils.createApproximateCommandLineArgumentString(getToolkit(), args, getClass()) + "\""));
}
writer = new VCFWriterImpl(out);
writer = new StandardVCFWriter(out);
writer.writeHeader(new VCFHeader(hInfo, new TreeSet<String>(vc.getSampleNames())));
}

View File

@ -29,6 +29,7 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.commandline.Output;
import java.util.Collection;
import java.io.PrintWriter;
@ -37,13 +38,9 @@ import java.io.PrintWriter;
* Creates a bed-format trigger-track for the Unified Genotyper based on input variant files.
*/
public class CreateTriggerTrack extends RodWalker<Integer, Integer> {
@Output
private PrintWriter writer;
public void initialize() {
writer = new PrintWriter(out);
}
public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
if ( tracker == null )
return 0;

View File

@ -38,6 +38,8 @@ import org.broadinstitute.sting.utils.genotype.vcf.*;
import java.util.*;
import java.io.PrintStream;
import java.io.File;
import java.io.FileNotFoundException;
/**
@ -54,10 +56,10 @@ public class UnifiedGenotyper extends LocusWalker<VariantCallContext, UnifiedGen
public VCFWriter writer = null;
@Argument(fullName = "verbose_mode", shortName = "verbose", doc = "File to print all of the annotated and detailed debugging output", required = false)
protected PrintStream verboseWriter = null;
protected File verboseFile = null;
@Argument(fullName = "metrics_file", shortName = "metrics", doc = "File to print any relevant callability metrics output", required = false)
protected PrintStream metricsWriter = null;
protected File metricsFile = null;
@Argument(fullName="annotation", shortName="A", doc="One or more specific annotations to apply to variant calls", required=false)
protected List<String> annotationsToUse = new ArrayList<String>();
@ -81,6 +83,9 @@ public class UnifiedGenotyper extends LocusWalker<VariantCallContext, UnifiedGen
// enable extended events for indels
public boolean generateExtendedEvents() { return UAC.genotypeModel == GenotypeCalculationModel.Model.INDELS; }
private PrintStream verboseWriter;
private PrintStream metricsWriter;
/**
* Inner class for collecting output statistics from the UG
*/
@ -110,6 +115,18 @@ public class UnifiedGenotyper extends LocusWalker<VariantCallContext, UnifiedGen
*
**/
public void initialize() {
try {
if(verboseWriter != null) verboseWriter = new PrintStream(verboseFile);
}
catch(FileNotFoundException ex) {
throw new StingException("Unable to create verbose writer from provided file "+verboseFile,ex);
}
try {
if(metricsWriter != null) metricsWriter = new PrintStream(metricsFile);
}
catch(FileNotFoundException ex) {
throw new StingException("Unable to create metrics writer from provided file "+metricsFile,ex);
}
annotationEngine = new VariantAnnotatorEngine(getToolkit(), Arrays.asList(annotationClassesToUse), annotationsToUse);
UG_engine = new UnifiedGenotyperEngine(getToolkit(), UAC, logger, writer, verboseWriter, annotationEngine);

View File

@ -52,6 +52,7 @@ import org.broadinstitute.sting.utils.sam.AlignmentUtils;
import org.broadinstitute.sting.utils.collections.CircularArray;
import org.broadinstitute.sting.utils.collections.PrimitivePair;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.io.File;
import java.io.IOException;
@ -70,6 +71,9 @@ import java.util.*;
*/
@ReadFilters({Platform454Filter.class, ZeroMappingQualityReadFilter.class, PlatformUnitFilter.class})
public class IndelGenotyperV2Walker extends ReadWalker<Integer,Integer> {
@Output
PrintStream out;
@Argument(fullName="outputFile", shortName="O", doc="output file name (defaults to BED format)", required=true)
java.io.File bed_file;

View File

@ -46,6 +46,7 @@ import org.broadinstitute.sting.utils.collections.Pair;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintStream;
import java.util.*;
/**
@ -69,6 +70,12 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
@Argument(fullName="entropyThreshold", shortName="entropy", doc="percentage of mismatches at a locus to be considered having high entropy", required=false)
protected double MISMATCH_THRESHOLD = 0.15;
@Output
protected PrintStream out;
@Output(fullName = "err", shortName = "e", doc = "An error output file presented to the walker. Will overwrite contents if file exists.", required = false)
protected PrintStream err;
@Output(fullName="output", shortName="O", required=false, doc="Output bam")
protected String writerFilename = null;

View File

@ -37,12 +37,14 @@ import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.pileup.ExtendedEventPileupElement;
import org.broadinstitute.sting.utils.pileup.PileupElement;
import org.broadinstitute.sting.utils.pileup.ReadBackedExtendedEventPileup;
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
import java.util.ArrayList;
import java.io.PrintStream;
/**
* Emits intervals for the Local Indel Realigner to target for cleaning. Ignores 454 and MQ0 reads.
@ -52,6 +54,8 @@ import java.util.ArrayList;
@Allows(value={DataSource.READS, DataSource.REFERENCE})
@By(DataSource.REFERENCE)
public class RealignerTargetCreator extends RodWalker<RealignerTargetCreator.Event, RealignerTargetCreator.Event> {
@Output
protected PrintStream out;
// mismatch/entropy/SNP arguments
@Argument(fullName="windowSize", shortName="window", doc="window size for calculating entropy or SNP clusters", required=false)

View File

@ -29,7 +29,6 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.RefWalker;
import org.broadinstitute.sting.utils.classloader.JVMUtils;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.commandline.Argument;
@ -50,8 +49,6 @@ public class CountRodByRefWalker extends RefWalker<CountRodWalker.Datum, Pair<Ex
public void initialize() {
crw.verbose = verbose;
crw.showSkipped = showSkipped;
JVMUtils.setFieldValue(JVMUtils.findField(CountRodWalker.class,"out"),crw,out);
JVMUtils.setFieldValue(JVMUtils.findField(CountRodWalker.class,"err"),crw,err);
}
public CountRodWalker.Datum map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {

View File

@ -35,17 +35,22 @@ import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.util.ArrayList;
import java.util.List;
import java.util.Collection;
import java.util.LinkedList;
import java.io.PrintStream;
/**
* Prints out counts of the number of reference ordered data objects are
* each locus for debugging RodWalkers.
*/
public class CountRodWalker extends RodWalker<CountRodWalker.Datum, Pair<ExpandingArrayList<Long>, Long>> implements TreeReducible<Pair<ExpandingArrayList<Long>, Long>> {
@Output
public PrintStream out;
@Argument(fullName = "verbose", shortName = "v", doc="If true, Countrod will print out detailed information about the rods it finds and locations", required = false)
public boolean verbose = false;

View File

@ -34,14 +34,12 @@ import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.collections.PrimitivePair;
import org.broadinstitute.sting.utils.sam.AlignmentUtils;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import net.sf.samtools.SAMRecord;
import net.sf.samtools.SAMReadGroupRecord;
import java.util.*;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.BufferedWriter;
import java.io.*;
/**
* Created by IntelliJ IDEA.
@ -58,6 +56,9 @@ import java.io.BufferedWriter;
*/
@Requires({DataSource.READS})
public class CycleQualityWalker extends ReadWalker<Integer,Integer> {
@Output
protected PrintStream out;
@Argument(fullName="mappedOnly", shortName="mo", doc="when this flag is set (default), statistics will be collected "+
"on mapped reads only, while unmapped reads will be discarded", required=false)
protected boolean MAPPED_ONLY = true;

View File

@ -4,9 +4,11 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.commandline.Output;
import java.util.List;
import java.util.Arrays;
import java.io.PrintStream;
import net.sf.samtools.SAMRecord;
@ -15,6 +17,9 @@ import net.sf.samtools.SAMRecord;
* all aligning reads in a compact but human-readable form.
*/
public class PrintLocusContextWalker extends LocusWalker<AlignmentContext, Integer> implements TreeReducible<Integer> {
@Output
private PrintStream out;
public AlignmentContext map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
out.printf( "In map: ref = %s, loc = %s, reads = %s%n", ref.getBaseAsChar(),
context.getLocation(),

View File

@ -32,13 +32,11 @@ import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.utils.MathUtils;
import org.broadinstitute.sting.utils.sam.AlignmentUtils;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import net.sf.samtools.*;
import java.util.*;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.BufferedWriter;
import java.io.*;
/**
* User: depristo
@ -52,6 +50,9 @@ import java.io.BufferedWriter;
*/
@Requires({DataSource.READS})
public class ReadClippingStatsWalker extends ReadWalker<ReadClippingStatsWalker.ReadClippingInfo,Integer> {
@Output
protected PrintStream out;
@Argument(fullName="mappedOnly", shortName="mo", doc="when this flag is set (default), statistics will be collected "+
"on mapped reads only, while unmapped reads will be discarded", required=false)
protected boolean MAPPED_ONLY = true;

View File

@ -35,9 +35,11 @@ import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
import java.util.Arrays;
import java.io.PrintStream;
/**
* At every locus in the input set, compares the pileup data (reference base, aligned base from
@ -46,6 +48,9 @@ import java.util.Arrays;
*/
@Requires(value={DataSource.READS,DataSource.REFERENCE},referenceMetaData=@RMD(name="pileup",type=SAMPileupFeature.class))
public class ValidatingPileupWalker extends LocusWalker<Integer, ValidationStats> implements TreeReducible<ValidationStats> {
@Output
private PrintStream out;
@Argument(fullName="continue_after_error",doc="Continue after an error",required=false)
public boolean CONTINUE_AFTER_AN_ERROR = false;

View File

@ -83,6 +83,9 @@ public class CovariateCounterWalker extends LocusWalker<CovariateCounterWalker.C
/////////////////////////////
@ArgumentCollection private RecalibrationArgumentCollection RAC = new RecalibrationArgumentCollection();
@Output
PrintStream out;
/////////////////////////////
// Command Line Arguments
/////////////////////////////

View File

@ -27,6 +27,7 @@ package org.broadinstitute.sting.gatk.walkers.recalibration;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.*;
import java.util.regex.Pattern;
@ -81,6 +82,9 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
@Input(fullName="recal_file", shortName="recalFile", required=false, doc="Filename for the input covariates table recalibration .csv file")
public File RECAL_FILE = new File("output.recal_data.csv");
@Output
private PrintStream out;
/////////////////////////////
// Command Line Arguments
/////////////////////////////

View File

@ -5,11 +5,16 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.commandline.Output;
import java.io.PrintStream;
/**
* Create a mask for use with the PickSequenomProbes walker.
*/
public class CreateSequenomMask extends RodWalker<Integer, Integer> {
@Output
PrintStream out;
public void initialize() {}

View File

@ -43,10 +43,12 @@ import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Collection;
import java.io.PrintStream;
/**
@ -57,6 +59,9 @@ import java.util.Collection;
@Requires(value={DataSource.REFERENCE})
@Reference(window=@Window(start=-200,stop=200))
public class PickSequenomProbes extends RodWalker<String, String> {
@Output
PrintStream out;
@Argument(required=false, shortName="snp_mask", doc="positions to be masked with N's")
protected String SNP_MASK = null;
@Argument(required=false, shortName="project_id",doc="If specified, all probenames will be prepended with 'project_id|'")

View File

@ -39,10 +39,12 @@ import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.utils.QualityUtils;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriter;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriterImpl;
import org.broadinstitute.sting.utils.genotype.vcf.StandardVCFWriter;
import java.util.*;
import java.io.PrintStream;
/**
* Converts Sequenom files to a VCF annotated with QC metrics (HW-equilibrium, % failed probes)
@ -50,6 +52,9 @@ import java.util.*;
@Reference(window=@Window(start=0,stop=40))
@Requires(value={},referenceMetaData=@RMD(name="sequenom",type= ReferenceOrderedDatum.class))
public class SequenomValidationConverter extends RodWalker<Pair<VariantContext, Byte>,Integer> {
@Output
protected PrintStream out;
@Argument(fullName="maxHardy", doc="Maximum phred-scaled Hardy-Weinberg violation pvalue to consider an assay valid [default:20]", required=false)
protected double maxHardy = 20.0;
@Argument(fullName="maxNoCall", doc="Maximum no-call rate (as a fraction) to consider an assay valid [default:0.05]", required=false)
@ -119,7 +124,7 @@ public class SequenomValidationConverter extends RodWalker<Pair<VariantContext,
if ( sampleNames == null )
sampleNames = new TreeSet<String>();
VCFWriter vcfWriter = new VCFWriterImpl(out);
VCFWriter vcfWriter = new StandardVCFWriter(out);
// set up the info and filter headers
Set<VCFHeaderLine> hInfo = new HashSet<VCFHeaderLine>();

View File

@ -47,8 +47,9 @@ import org.broadinstitute.sting.utils.classloader.PackageUtils;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriter;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriterImpl;
import org.broadinstitute.sting.utils.genotype.vcf.StandardVCFWriter;
import org.broadinstitute.sting.utils.text.XReadLines;
import java.io.File;
@ -110,6 +111,9 @@ import java.util.*;
*/
@Reference(window=@Window(start=-50,stop=50))
public class VariantEvalWalker extends RodWalker<Integer, Integer> {
@Output
protected PrintStream out;
// --------------------------------------------------------------------------------------------------------------
//
// walker arguments
@ -341,7 +345,7 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
determineContextNamePartSizes();
if ( outputVCF != null )
writer = new VCFWriterImpl(new File(outputVCF));
writer = new StandardVCFWriter(new File(outputVCF));
if ( rsIDFile != null ) {
if ( maxRsIDBuild == Integer.MAX_VALUE )

View File

@ -37,7 +37,7 @@ import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriter;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriterImpl;
import org.broadinstitute.sting.utils.genotype.vcf.StandardVCFWriter;
import org.broadinstitute.sting.utils.text.XReadLines;
import java.io.File;
@ -157,7 +157,7 @@ public class ApplyVariantCuts extends RodWalker<Integer, Integer> {
hInfo.addAll(VCFUtils.getHeaderFields(getToolkit()));
hInfo.add(new VCFInfoHeaderLine("OQ", 1, VCFHeaderLineType.Float, "The original variant quality score"));
hInfo.add(new VCFHeaderLine("source", "VariantOptimizer"));
vcfWriter = new VCFWriterImpl( new File(OUTPUT_FILENAME) );
vcfWriter = new StandardVCFWriter( new File(OUTPUT_FILENAME) );
final TreeSet<String> samples = new TreeSet<String>();
samples.addAll(SampleUtils.getSampleListWithVCFHeader(getToolkit(), null));

View File

@ -41,7 +41,7 @@ import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriter;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriterImpl;
import org.broadinstitute.sting.utils.genotype.vcf.StandardVCFWriter;
import java.io.File;
import java.io.IOException;
@ -138,7 +138,7 @@ public class VariantRecalibrator extends RodWalker<ExpandingArrayList<VariantDat
hInfo.add(new VCFHeaderLine("source", "VariantOptimizer"));
samples.addAll(SampleUtils.getUniqueSamplesFromRods(getToolkit()));
vcfWriter = new VCFWriterImpl( new File(OUTPUT_PREFIX + ".vcf") );
vcfWriter = new StandardVCFWriter( new File(OUTPUT_PREFIX + ".vcf") );
final VCFHeader vcfHeader = new VCFHeader(hInfo, samples);
vcfWriter.writeHeader(vcfHeader);

View File

@ -39,10 +39,12 @@ import org.broadinstitute.sting.gatk.walkers.annotator.VariantAnnotatorEngine;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import org.broadinstitute.sting.utils.genotype.vcf.*;
import java.util.*;
import java.io.PrintStream;
/**
* Combines VCF records from different sources; supports both full merges and set unions.
@ -53,6 +55,9 @@ import java.util.*;
@Reference(window=@Window(start=-50,stop=50))
@Requires(value={})
public class CombineVariants extends RodWalker<Integer, Integer> {
@Output
private PrintStream out;
// the types of combinations we currently allow
@Argument(shortName="genotypeMergeOptions", doc="How should we merge genotype records for samples shared across the ROD files?", required=false)
public VariantContextUtils.GenotypeMergeType genotypeMergeOption = VariantContextUtils.GenotypeMergeType.PRIORITIZE;
@ -81,7 +86,7 @@ public class CombineVariants extends RodWalker<Integer, Integer> {
private VariantAnnotatorEngine engine;
public void initialize() {
vcfWriter = new VCFWriterImpl(out);
vcfWriter = new StandardVCFWriter(out);
validateAnnotateUnionArguments();
Map<String, VCFHeader> vcfRods = VCFUtils.getVCFHeadersFromRods(getToolkit(), null);

View File

@ -26,7 +26,7 @@ package org.broadinstitute.sting.gatk.walkers.variantutils;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriter;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriterImpl;
import org.broadinstitute.sting.utils.genotype.vcf.StandardVCFWriter;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
@ -34,15 +34,19 @@ import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum;
import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.commandline.Output;
import org.broad.tribble.vcf.VCFHeader;
import java.util.*;
import java.io.PrintStream;
/**
* Filters a lifted-over VCF file for ref bases that have been changed.
*/
@Requires(value={},referenceMetaData=@RMD(name="variant",type= ReferenceOrderedDatum.class))
public class FilterLiftedVariants extends RodWalker<Integer, Integer> {
@Output
PrintStream out;
private VCFWriter writer;
@ -52,7 +56,7 @@ public class FilterLiftedVariants extends RodWalker<Integer, Integer> {
Set<String> samples = SampleUtils.getSampleListWithVCFHeader(getToolkit(), Arrays.asList("variant"));
Map<String, VCFHeader> vcfHeaders = VCFUtils.getVCFHeadersFromRods(getToolkit(), Arrays.asList("variant"));
writer = new VCFWriterImpl(out);
writer = new StandardVCFWriter(out);
final VCFHeader vcfHeader = new VCFHeader(vcfHeaders.containsKey("variant") ? vcfHeaders.get("variant").getMetaData() : null, samples);
writer.writeHeader(vcfHeader);
}

View File

@ -26,9 +26,10 @@ package org.broadinstitute.sting.gatk.walkers.variantutils;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriter;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriterImpl;
import org.broadinstitute.sting.utils.genotype.vcf.StandardVCFWriter;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
@ -40,6 +41,7 @@ import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils
import org.broad.tribble.vcf.VCFHeader;
import java.io.File;
import java.io.PrintStream;
import java.util.*;
import net.sf.picard.liftover.LiftOver;
@ -52,6 +54,8 @@ import net.sf.samtools.SAMFileReader;
*/
@Requires(value={},referenceMetaData=@RMD(name="variant", type=ReferenceOrderedDatum.class))
public class LiftoverVariants extends RodWalker<Integer, Integer> {
@Output
protected PrintStream out;
@Argument(fullName="chain", shortName="chain", doc="Chain file", required=true)
protected File CHAIN = null;
@ -75,7 +79,7 @@ public class LiftoverVariants extends RodWalker<Integer, Integer> {
Set<String> samples = SampleUtils.getSampleListWithVCFHeader(getToolkit(), Arrays.asList("variant"));
Map<String, VCFHeader> vcfHeaders = VCFUtils.getVCFHeadersFromRods(getToolkit(), Arrays.asList("variant"));
writer = new VCFWriterImpl(out);
writer = new StandardVCFWriter(out);
final VCFHeader vcfHeader = new VCFHeader(vcfHeaders.containsKey("variant") ? vcfHeaders.get("variant").getMetaData() : null, samples);
writer.writeHeader(vcfHeader);
}

View File

@ -28,9 +28,8 @@ import org.broad.tribble.util.variantcontext.Genotype;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broad.tribble.vcf.VCFHeader;
import org.broad.tribble.vcf.VCFHeaderLine;
import org.broad.tribble.vcf.VCFHeaderLineType;
import org.broad.tribble.vcf.VCFInfoHeaderLine;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils;
@ -40,15 +39,15 @@ import org.broadinstitute.sting.gatk.walkers.RMD;
import org.broadinstitute.sting.gatk.walkers.Requires;
import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.text.XReadLines;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriter;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriterImpl;
import org.broadinstitute.sting.utils.genotype.vcf.StandardVCFWriter;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.io.PrintStream;
import java.io.File;
import java.io.FileNotFoundException;
@ -58,6 +57,9 @@ import java.io.FileNotFoundException;
*/
@Requires(value={},referenceMetaData=@RMD(name="variant", type=ReferenceOrderedDatum.class))
public class SelectVariants extends RodWalker<Integer, Integer> {
@Output
private PrintStream out;
@Argument(fullName="sample", shortName="sn", doc="Sample(s) to include. Can be a single sample, specified multiple times for many samples, a file containing sample names, a regular expression to select many samples, or any combination thereof.", required=false)
public Set<String> SAMPLE_EXPRESSIONS;
@ -83,7 +85,7 @@ public class SelectVariants extends RodWalker<Integer, Integer> {
* Set up the VCF writer, the sample expressions and regexs, and the JEXL matcher
*/
public void initialize() {
vcfWriter = new VCFWriterImpl(out);
vcfWriter = new StandardVCFWriter(out);
ArrayList<String> rodNames = new ArrayList<String>();
rodNames.add("variant");

View File

@ -5,6 +5,9 @@ import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
import org.broadinstitute.sting.gatk.walkers.WalkerName;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Output;
import java.io.PrintStream;
/**
* Created by IntelliJ IDEA.
@ -15,6 +18,9 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
*/
@WalkerName("Aligned_Reads_Histogram")
public class AlignedReadsHistoWalker extends ReadWalker<Integer, Integer> {
@Output
PrintStream out;
long[] alignCounts = new long[51];
public void initialize() {

View File

@ -12,8 +12,10 @@ import org.broadinstitute.sting.gatk.walkers.RMD;
import org.broadinstitute.sting.gatk.walkers.Requires;
import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.pileup.PileupElement;
import org.broadinstitute.sting.commandline.Output;
import java.util.*;
import java.io.PrintStream;
/**
* Created by IntelliJ IDEA.
@ -24,7 +26,8 @@ import java.util.*;
*/
@Requires(value= DataSource.REFERENCE,referenceMetaData = {@RMD(name="variants",type=ReferenceOrderedDatum.class)})
public class AlleleBalanceHistogramWalker extends LocusWalker<Map<String,Double>, Map<String,Set<Double>>> {
@Output
PrintStream out;
public Map<String,Set<Double>> reduceInit() {
return new HashMap<String,Set<Double>>();

View File

@ -31,6 +31,7 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
@ -50,6 +51,9 @@ import net.sf.samtools.SAMRecord;
@By(DataSource.REFERENCE)
@Reference(window=@Window(start=-3,stop=3))
public class BaseTransitionTableCalculatorJavaWalker extends LocusWalker<Set<BaseTransitionTable>,Set<BaseTransitionTable>> implements TreeReducible<Set<BaseTransitionTable>> {
@Output
PrintStream out;
@Argument(fullName="usePreviousBases", doc="Use previous bases of the reference as part of the calculation, uses the specified number, defaults to 0", required=false)
int nPreviousBases = 0;
@Argument(fullName="useSecondaryBase",doc="Use the secondary base of a read as part of the calculation", required=false)

View File

@ -30,6 +30,7 @@ import org.broad.tribble.util.variantcontext.Genotype;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broad.tribble.vcf.VCFConstants;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
@ -55,6 +56,9 @@ public class BeagleOutputByDepthWalker extends RodWalker<Integer, Integer> {
private boolean newLine = true;
@Output
public PrintStream out;
@Argument(fullName = "output_file", shortName = "output", doc = "File to output results", required = true)
public PrintStream outputWriter = null;

View File

@ -1,6 +1,7 @@
package org.broadinstitute.sting.oneoffprojects.walkers;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
@ -12,6 +13,7 @@ import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.collections.Pair;
import java.util.List;
import java.io.PrintStream;
/**
* Counts the number of contiguous regions the walker traverses over. Slower than it needs to be, but
@ -19,6 +21,9 @@ import java.util.List;
* This was its very first use.
*/
public class CountIntervals extends RefWalker<Long, Long> {
@Output
PrintStream out;
@Argument(fullName="numOverlaps",shortName="no",doc="Count all occurrences of X or more overlapping intervals; defaults to 2", required=false)
int numOverlaps = 2;

View File

@ -2,6 +2,7 @@ package org.broadinstitute.sting.oneoffprojects.walkers;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils;
@ -11,6 +12,7 @@ import org.broadinstitute.sting.utils.wiggle.WiggleHeader;
import org.broadinstitute.sting.utils.wiggle.WiggleWriter;
import java.util.ArrayList;
import java.io.PrintStream;
/**
* IF THERE IS NO JAVADOC RIGHT HERE, YELL AT chartl
@ -19,6 +21,9 @@ import java.util.ArrayList;
* @Date Jul 21, 2010
*/
public class CreateTiTvTrack extends RodWalker<VariantContext,TiTvWindow> {
@Output
PrintStream out;
@Argument(shortName="size",doc="Size of the window",required = true)
int size = -1;

View File

@ -29,11 +29,13 @@ import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.sam.AlignmentUtils;
import net.sf.samtools.SAMRecord;
import java.util.*;
import java.io.PrintStream;
/**
* Created by IntelliJ IDEA.
@ -43,6 +45,8 @@ import java.util.*;
* To change this template use File | Settings | File Templates.
*/
public class DSBWalkerV3 extends ReadWalker<Integer,Integer> {
@Output
PrintStream out;
@Argument(fullName="windowSize",shortName="W",doc="Size of the sliding window",required=true)
int WINDOW_SIZE = 100;

View File

@ -7,6 +7,7 @@ import org.broad.tribble.dbsnp.DbSNPCodec;
import org.broad.tribble.dbsnp.DbSNPFeature;
import org.broad.tribble.iterators.CloseableTribbleIterator;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
@ -20,6 +21,7 @@ import org.broadinstitute.sting.utils.StingException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
/**
* DbSNPWindowCounter
@ -36,6 +38,9 @@ public class DbSNPWindowCounter extends LocusWalker<Integer, Long> {
// what we read in new tracks with
private FeatureSource reader;
@Output
private PrintStream out;
@Argument(fullName = "dbSNPFile", shortName = "db", doc="The dbsnp file to search upstream and downstream for nearby snps", required = true)
private File myDbSNPFile;

View File

@ -10,8 +10,10 @@ import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.commandline.Output;
import java.util.*;
import java.io.PrintStream;
/**
* Takes an interval list and annotates intervals with genes and exons falling within that interval
@ -28,6 +30,9 @@ public class DesignFileGeneratorWalker extends RodWalker<Long,Long> {
private HashSet<RefSeqFeature> refseqBuffer = new HashSet<RefSeqFeature>();
private HashMap<String,BEDFeature> currentBedFeatures = new HashMap<String,BEDFeature>();
@Output
PrintStream out;
public Long map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
// three items to look up: interval_list, refseq, gene*
if ( tracker == null ) {

View File

@ -6,10 +6,12 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.util.List;
import java.util.HashMap;
import java.util.HashSet;
import java.io.PrintStream;
import net.sf.samtools.SAMRecord;
import net.sf.samtools.SAMReadGroupRecord;
@ -18,6 +20,7 @@ import net.sf.samtools.SAMReadGroupRecord;
* Computes the read error rate per position in read (in the original 5'->3' orientation that the read had coming off the machine)
*/
public class ErrorRatePerReadPosition extends LocusWalker<Integer, Integer> {
@Output PrintStream out;
@Argument(fullName="min_base_quality_score", shortName="mbq", doc="Minimum base quality required to consider a base for calling (default: 0)", required=false) public Integer MIN_BASE_QUAL = 0;
@Argument(fullName="min_mapping_quality_score", shortName="mmq", doc="Minimum read mapping quality required to consider a read for calling (default: 0)", required=false) public Integer MIN_MAPPING_QUAL = 0;

View File

@ -10,11 +10,13 @@ import org.broadinstitute.sting.gatk.walkers.RefWalker;
import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.commandline.Output;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.io.PrintStream;
/**
* IF THERE IS NO JAVADOC RIGHT HERE, YELL AT chartl
@ -23,6 +25,8 @@ import java.util.Set;
* @Date May 19, 2010
*/
public class GCCalculatorWalker extends RefWalker<Pair<Set<GenomeLoc>,Boolean>, Map<GenomeLoc,Pair<Long,Long>>> {
@Output
PrintStream out;
public Map<GenomeLoc,Pair<Long,Long>> reduceInit() {
return new HashMap<GenomeLoc,Pair<Long,Long>>();

View File

@ -4,6 +4,7 @@ import org.broad.tribble.FeatureSource;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broad.tribble.vcf.*;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils;
@ -21,6 +22,7 @@ import org.broadinstitute.sting.utils.genotype.vcf.*;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.*;
/**
@ -30,6 +32,8 @@ import java.util.*;
* @Date Apr 21, 2010
*/
public class IndelAnnotator extends RodWalker<Integer,Long>{
@Output
PrintStream out;
@Argument(fullName="refseq", shortName="refseq",
doc="Name of RefSeq transcript annotation file. If specified, indels will be annotated with GENOMIC/UTR/INTRON/CODING and with the gene name", required=true)
String RefseqFileName = null;
@ -85,7 +89,7 @@ public class IndelAnnotator extends RodWalker<Integer,Long>{
anno.add(new VCFInfoHeaderLine("type",1, VCFHeaderLineType.String,"Genomic interpretation (according to RefSeq)"));
hInfo.addAll(anno);
vcfWriter = new VCFWriterImpl(out);
vcfWriter = new StandardVCFWriter(out);
VCFHeader vcfHeader = new VCFHeader(hInfo, SampleUtils.getUniqueSamplesFromRods(getToolkit()));
vcfWriter.writeHeader(vcfHeader);
}

View File

@ -4,6 +4,7 @@ import org.broad.tribble.util.variantcontext.VariantContext;
import org.broad.tribble.vcf.VCFHeader;
import org.broad.tribble.vcf.VCFHeaderLine;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils;
@ -17,7 +18,7 @@ import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriter;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriterImpl;
import org.broadinstitute.sting.utils.genotype.vcf.StandardVCFWriter;
import java.io.PrintStream;
import java.util.*;
@ -30,7 +31,8 @@ import java.util.*;
*/
@Reference(window=@Window(start=-40,stop=40))
public class IndelDBRateWalker extends RodWalker<OverlapTable,OverlapTabulator> {
@Output
PrintStream out;
@Argument(fullName="indelWindow",doc="size of the window in which to look for indels; max 40",required=false)
int indelWindow = 10;
@Argument(fullName="writeVCF",doc="Writes \"overlapping\" variants to this vcf",required=false)
@ -47,7 +49,7 @@ public class IndelDBRateWalker extends RodWalker<OverlapTable,OverlapTabulator>
}
if ( outVCF != null ) {
vcfWriter = new VCFWriterImpl(outVCF);
vcfWriter = new StandardVCFWriter(outVCF);
Set<VCFHeaderLine> header = new HashSet<VCFHeaderLine>();
header.addAll(VCFUtils.getHeaderFields(getToolkit()));
VCFHeader vcfHeader = new VCFHeader(header, SampleUtils.getUniqueSamplesFromRods(getToolkit()));

View File

@ -38,10 +38,12 @@ import org.broadinstitute.sting.utils.pileup.ExtendedEventPileupElement;
import org.broadinstitute.sting.utils.pileup.ReadBackedExtendedEventPileup;
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.util.List;
import java.util.LinkedList;
import java.util.Iterator;
import java.io.PrintStream;
/**
* Created by IntelliJ IDEA.
@ -52,6 +54,8 @@ import java.util.Iterator;
*/
@Reference(window=@Window(start=-10,stop=10))
public class IndelErrorRateWalker extends LocusWalker<Integer,Integer> {
@Output
PrintStream out;
@Argument(fullName="minCoverage",shortName="minC",doc="Assess only sites with coverage at or above the specified value.",required=true)
int MIN_COVERAGE = 0;
@Argument(fullName="maxCoverage",shortName="maxC",doc="Assess only sites with coverage at or below the specified value.",required=false)

View File

@ -6,6 +6,7 @@ import org.broad.tribble.util.variantcontext.VariantContext;
import org.broad.tribble.vcf.VCFHeader;
import org.broad.tribble.vcf.VCFHeaderLine;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext;
@ -23,7 +24,7 @@ import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriter;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriterImpl;
import org.broadinstitute.sting.utils.genotype.vcf.StandardVCFWriter;
import org.broadinstitute.sting.utils.pileup.PileupElement;
import java.io.PrintStream;
@ -39,6 +40,8 @@ import java.util.*;
* @Date Jun 8, 2010
*/
public class MendelianViolationClassifier extends LocusWalker<MendelianViolationClassifier.MendelianViolation, VCFWriter> {
@Output
PrintStream out;
@Argument(shortName="f",fullName="familyPattern",required=true,doc="Pattern for the family structure (usage: mom+dad=child)")
String familyStr = null;
@Argument(shortName="ob",fullName="outputBed",required=true,doc="Output file to write the homozygous region information to")
@ -373,7 +376,7 @@ public class MendelianViolationClassifier extends LocusWalker<MendelianViolation
*********** REDUCE INIT
*/
public VCFWriter reduceInit() {
VCFWriter writer = new VCFWriterImpl(out);
VCFWriter writer = new StandardVCFWriter(out);
Set<VCFHeaderLine> hInfo = new HashSet<VCFHeaderLine>();
hInfo.addAll(VCFUtils.getHeaderFields(getToolkit()));
hInfo.add(new VCFHeaderLine("source", "MendelianViolationClassifier"));

View File

@ -6,11 +6,16 @@ import org.broadinstitute.sting.gatk.walkers.ReadWalker;
import org.broadinstitute.sting.gatk.walkers.WalkerName;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.commandline.Output;
import java.util.List;
import java.io.PrintStream;
@WalkerName("CountMismatches")
public class MismatchCounterWalker extends ReadWalker<Integer, Integer> {
@Output
PrintStream out;
public Integer map(ReferenceContext ref, SAMRecord read, ReadMetaDataTracker metaDataTracker) {
int nMismatches = 0;

View File

@ -6,12 +6,16 @@ import org.broadinstitute.sting.gatk.walkers.ReadWalker;
import org.broadinstitute.sting.gatk.walkers.WalkerName;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.commandline.Output;
import java.util.List;
import static java.lang.reflect.Array.*;
import java.io.PrintStream;
@WalkerName("Mismatch_Histogram")
public class MismatchHistoWalker extends ReadWalker<Integer, Integer> {
public class MismatchHistoWalker extends ReadWalker<Integer, Integer> {
@Output
PrintStream out;
protected long[] mismatchCounts = new long[0];
protected final int MIN_TARGET_EDIT_DISTANCE = 5;

View File

@ -4,10 +4,12 @@ import org.broadinstitute.sting.gatk.walkers.LocusWalker;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.commandline.Output;
import net.sf.samtools.SAMRecord;
import java.util.List;
import java.util.Iterator;
import java.io.PrintStream;
/*
* Copyright (c) 2009 The Broad Institute
@ -71,6 +73,8 @@ import java.util.Iterator;
*/
public class NeighborhoodQualityWalker extends LocusWalker<Integer, Long> {
@Output
PrintStream out;
public Integer map( RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context ) {
float neighborhoodQualityScore = 0.0f;

View File

@ -33,8 +33,11 @@ import org.broadinstitute.sting.utils.QualityUtils;
import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import net.sf.samtools.SAMRecord;
import java.io.PrintStream;
/**
* This walker prints out quality score counts for first and second reads of a pair aggregated over all reads
* in the interval.
@ -42,6 +45,9 @@ import net.sf.samtools.SAMRecord;
* @Author: Chris Hartl
*/
public class PairedQualityScoreCountsWalker extends ReadWalker<Pair<byte[],Boolean>,Pair<CycleQualCounts,CycleQualCounts>> {
@Output
public PrintStream out;
@Argument(fullName="readLength", shortName="rl", doc="Length of reads in the bam file", required=true)
public int readLength = -1;

View File

@ -29,6 +29,7 @@ import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.walkers.TreeReducible;
import org.broadinstitute.sting.utils.QualityUtils;
import org.broadinstitute.sting.utils.BaseUtils;
@ -37,6 +38,7 @@ import net.sf.samtools.SAMRecord;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.io.PrintStream;
/**
* ReadErrorRateWalker assesses the error rate per read position ('cycle') by comparing the
@ -48,6 +50,7 @@ import java.util.Random;
* @author Kiran Garimella
*/
public class ReadErrorRateWalker extends ReadWalker<boolean[], ReadErrorRateCollection> implements TreeReducible<ReadErrorRateCollection> {
@Output PrintStream out;
@Argument(fullName="printVisualHits", shortName="v", doc="print visual hits", required=false) public boolean printVisualHits = false;
@Argument(fullName="useNextBestBase", shortName="nb", doc="use next best base", required=false) public boolean useNextBestBase = false;
@Argument(fullName="useNonNextBestBase",shortName="nnb",doc="use nonnext best base",required=false) public boolean useNonNextBestBase = false;

View File

@ -29,16 +29,14 @@ import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.StingException;
import net.sf.samtools.SAMRecord;
import net.sf.samtools.SAMFileWriter;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.*;
/**
* Created by IntelliJ IDEA.
@ -61,6 +59,8 @@ import java.io.IOException;
*/
public class ReadQualityScoreWalker extends ReadWalker<SAMRecord, SAMFileWriter> {
@Output
protected PrintStream out;
@Argument(fullName = "inputQualityFile", shortName = "if", doc = "Input quality score file generated by NeighborhoodQualityWalker", required = true)
protected String inputQualityFile = null;
@Argument(fullName = "outputBamFile", shortName = "of", doc = "Write output to this BAM filename instead of STDOUT", required = false)

View File

@ -29,11 +29,13 @@ import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.collections.Pair;
import net.sf.samtools.*;
import java.util.HashMap;
import java.io.File;
import java.io.PrintStream;
/**
* ReadErrorRateWalker assesses the error rate per read position ('cycle') by comparing the
@ -45,6 +47,9 @@ import java.io.File;
* @author Kiran Garimella
*/
public class ReplaceQuals extends ReadWalker<SAMRecord, SAMFileWriter> {
@Output
public PrintStream out;
@Argument(shortName="inputQualsBAM",doc="BAM files containing qualities to be replaced",required=true)
public String inputQualsBAM;

View File

@ -33,6 +33,7 @@ import org.broadinstitute.sting.alignment.bwa.BWAConfiguration;
import org.broadinstitute.sting.alignment.bwa.c.BWACAligner;
import org.broadinstitute.sting.alignment.Alignment;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
@ -44,6 +45,7 @@ import net.sf.picard.reference.IndexedFastaSequenceFile;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.SortedMap;
@ -60,6 +62,9 @@ public class TestReadFishingWalker extends ReadWalker<Integer,Long> {
*/
private BWAAligner aligner;
@Output
private PrintStream out;
@Argument(fullName="indel_calls",shortName="ic",doc="Indel calls to use to derive custom references",required=true)
private File indelCalls;

View File

@ -32,14 +32,19 @@ import org.broadinstitute.sting.gatk.refdata.*;
import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.genotype.vcf.*;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.util.EnumSet;
import java.io.File;
import java.io.PrintStream;
/**
* Test routine for new VariantContext object
*/
public class TestVariantContextWalker extends RodWalker<Integer, Integer> {
@Output
PrintStream out;
@Argument(fullName="takeFirstOnly", doc="Only take the first second at a locus, as opposed to all", required=false)
boolean takeFirstOnly = false;
@ -60,7 +65,7 @@ public class TestVariantContextWalker extends RodWalker<Integer, Integer> {
public void initialize() {
if ( outputVCF != null )
writer = new VCFWriterImpl(new File(outputVCF));
writer = new StandardVCFWriter(new File(outputVCF));
}
public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
@ -100,4 +105,11 @@ public class TestVariantContextWalker extends RodWalker<Integer, Integer> {
public Integer reduce(Integer point, Integer sum) {
return point + sum;
}
@Override
public void onTraversalDone(Integer result) {
// Double check traversal result to make count is the same.
// TODO: Is this check necessary?
out.println("[REDUCE RESULT] Traversal result is: " + result);
}
}

View File

@ -4,6 +4,7 @@ import org.broad.tribble.readers.AsciiLineReader;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broad.tribble.vcf.*;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.datasources.simpleDataSources.ReferenceOrderedDataSource;
@ -14,11 +15,12 @@ import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriter;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriterImpl;
import org.broadinstitute.sting.utils.genotype.vcf.StandardVCFWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.*;
/*
* Copyright (c) 2009 The Broad Institute
@ -53,6 +55,9 @@ import java.util.*;
public class VCF4WriterTestWalker extends RodWalker<Integer, Integer> {
private VCFWriter vcfWriter;
@Output
private PrintStream out;
@Argument(fullName="output_file", shortName="output", doc="VCF file to which output should be written", required=true)
private String OUTPUT_FILE = null;
@ -80,7 +85,7 @@ public class VCF4WriterTestWalker extends RodWalker<Integer, Integer> {
hInfo.addAll(VCFUtils.getHeaderFields(getToolkit()));
vcfWriter = new VCFWriterImpl(new File(OUTPUT_FILE));
vcfWriter = new StandardVCFWriter(new File(OUTPUT_FILE));
VCFHeader header = null;
for( final ReferenceOrderedDataSource source : dataSources ) {
final RMDTrack rod = source.getReferenceOrderedData();

View File

@ -7,11 +7,13 @@ import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature;
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.commandline.Output;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.io.PrintStream;
/**
* validate the rods for reads
@ -20,6 +22,9 @@ public class ValidateRODForReads extends ReadWalker<Integer, Integer> {
// a mapping of the position to the count of rods
HashMap<GenomeLoc, Integer> map = new LinkedHashMap<GenomeLoc, Integer>();
@Output
private PrintStream out;
@Override
public Integer map(ReferenceContext ref, SAMRecord read, ReadMetaDataTracker tracker) {
if (tracker != null) {

View File

@ -29,6 +29,7 @@ import org.broad.tribble.util.variantcontext.Allele;
import org.broad.tribble.util.variantcontext.Genotype;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.variantcontext.*;
@ -44,7 +45,7 @@ import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriter;
import org.broadinstitute.sting.utils.genotype.vcf.VCFWriterImpl;
import org.broadinstitute.sting.utils.genotype.vcf.StandardVCFWriter;
import org.broad.tribble.vcf.*;
import java.io.*;
@ -65,6 +66,9 @@ public class BeagleOutputToVCFWalker extends RodWalker<Integer, Integer> {
public static final String PROBS_ROD_NAME = "beagleProbs";
public static final String PHASED_ROD_NAME = "beaglePhased";
@Output
private PrintStream out;
@Argument(fullName="output_file", shortName="output", doc="VCF file to which output should be written", required=true)
private String OUTPUT_FILE = null;
@ -93,7 +97,7 @@ public class BeagleOutputToVCFWalker extends RodWalker<Integer, Integer> {
hInfo.add(new VCFHeaderLine("source", "BeagleImputation"));
// Open output file specified by output VCF ROD
vcfWriter = new VCFWriterImpl(new File(OUTPUT_FILE));
vcfWriter = new StandardVCFWriter(new File(OUTPUT_FILE));
final List<ReferenceOrderedDataSource> dataSources = this.getToolkit().getRodDataSources();
for( final ReferenceOrderedDataSource source : dataSources ) {

View File

@ -30,12 +30,14 @@ import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Vector;
import java.util.Collections;
import java.io.PrintStream;
/**
* Calculates likelihood of observing the data given pairs of HLA alleles. NOTE: run CalculateBaseLikelihoods first! Usage: java -jar GenomeAnalysisTK.jar -T CalculateAlleleLikelihoods -I /humgen/gsa-scr1/GSA/sjia/454_HLA/HLA/HLA.nuc.imputed.4digit.bam -R /broad/1KG/reference/human_b36_both.fasta -L /humgen/gsa-scr1/GSA/sjia/454_HLA/HAPMAP270/HLA_exons.interval -bl INPUT.baselikelihoods -eth\
@ -44,6 +46,9 @@ nicity Caucasian | grep -v "INFO" | grep -v "DONE!" > OUTPUT.allelelikelihoods
*/
@Requires({DataSource.READS, DataSource.REFERENCE})
public class CalculateAlleleLikelihoodsWalker extends ReadWalker<Integer, Integer> {
@Output
public PrintStream out;
@Argument(fullName = "baseLikelihoods", shortName = "bl", doc = "Base likelihoods file", required = true)
public String baseLikelihoodsFile = "";

View File

@ -35,15 +35,21 @@ import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.utils.genotype.DiploidGenotype;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.io.PrintStream;
/**
* Calculates the probability of observing data for each genotype at every position. NOTE: run FindClosestAllele first to create .filter file. Usage: java -jar GenomeAnalysisTK.jar -T CalculateBaseLikelihoods -I INPUT.bam -R /broad/1KG/reference/human_b36_both.fasta -L /humgen/gsa-scr1/GSA/sjia/454_HLA/HAPMAP270/HLA_exons.interval [-filter INPUT.filter -minAllowedMismatches 7] | grep -v "INFO" | grep -v "MISALIGNED" > OUTPUT.baselikelihoods
* @author shermanjia
*/
public class CalculateBaseLikelihoodsWalker extends LocusWalker<Integer, Pair<Long, Long>>{
@Output
public PrintStream out;
@Argument(fullName = "debugHLA", shortName = "debugHLA", doc = "Print debug", required = false)
public boolean DEBUG = false;
@Argument(fullName = "debugAlleles", shortName = "debugAlleles", doc = "Print likelihood scores for these alleles", required = false)

View File

@ -37,11 +37,9 @@ import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
import org.broadinstitute.sting.utils.genotype.DiploidGenotype;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.*;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
@ -51,6 +49,9 @@ import java.util.List;
* @author shermanjia
*/
public class CallHLAWalker extends LocusWalker<Integer, Pair<Long, Long>>{
@Output
public PrintStream out;
@Argument(fullName="suppressLocusPrinting",doc="Suppress printing",required=false)
public boolean suppressPrinting = false;

View File

@ -5,15 +5,21 @@ import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.util.ArrayList;
import java.util.Hashtable;
import java.io.PrintStream;
/**
* Compares reads to longest read at each exon. Usage: java -jar GenomeAnalysisTK.jar -T ClusterReads -I INPUT.bam -R /broad/1KG/reference/human_b36_both.fasta [-filter INPUT.filter] | grep -v INFO | sort -k1 > OUTPUT
* @author shermanjia
*/
@Requires({DataSource.READS, DataSource.REFERENCE})
public class ClusterReadsWalker extends ReadWalker<Integer, Integer> {
@Output
public PrintStream out;
@Argument(fullName = "filter", shortName = "filter", doc = "file containing reads to exclude", required = false)
public String filterFile = "";

View File

@ -4,14 +4,20 @@ import net.sf.samtools.SAMRecord;
import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Output;
import java.util.Hashtable;
import java.io.PrintStream;
/**
* Creates a haplotype file given reads (for SNP analysis, imputation, etc)
* @author shermanjia
*/
@Requires({DataSource.READS, DataSource.REFERENCE})
public class CreateHaplotypesWalker extends ReadWalker<Integer, Integer> {
@Output
PrintStream out;
CigarParser formatter = new CigarParser();
char c;
boolean DEBUG = false;

View File

@ -30,10 +30,13 @@ import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Enumeration;
import java.io.PrintStream;
/**
* Creates a ped file of SNPs and amino acids coded as SNPs given an input ped file with 4-digit HLA alleles. Usage: java -jar GenomeAnalysisTK.jar -T CreatePedFile --allelesFile INPUT.ped -R /broad/1KG/reference/human_b36_both.fasta -I /humgen/gsa-sc\
r1/GSA/sjia/454_HLA/HLA/HLA.combined.4digitUnique.bam > OUTPUT.log
@ -41,6 +44,9 @@ r1/GSA/sjia/454_HLA/HLA/HLA.combined.4digitUnique.bam > OUTPUT.log
*/
@Requires({DataSource.READS, DataSource.REFERENCE})
public class CreatePedFileWalker extends ReadWalker<Integer, Integer> {
@Output
public PrintStream out;
@Argument(fullName = "allelesFile", shortName = "allelesFile", doc = "Create ped file for HLA alleles named in this file", required = true)
public String alleleNamesFile = "";

View File

@ -30,15 +30,21 @@ import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.util.ArrayList;
import java.util.Hashtable;
import java.io.PrintStream;
/**
* Finds the most similar HLA allele for each read (helps detect misalignments). Usage: java -jar GenomeAnalysisTK.jar -T FindClosestHLA -I INPUT.bam -R /broad/1KG/reference/human_b36_both.fasta -L INPUT.interval | grep -v INFO | sort -k1 > OUTPUT
* @author shermanjia
*/
@Requires({DataSource.READS, DataSource.REFERENCE})
public class FindClosestHLAWalker extends ReadWalker<Integer, Integer> {
@Output
protected PrintStream out;
@Argument(fullName = "debugRead", shortName = "debugRead", doc = "Print match score for read", required = false)
public String debugRead = "";
@ -300,5 +306,12 @@ public class FindClosestHLAWalker extends ReadWalker<Integer, Integer> {
public Integer reduce(Integer value, Integer sum) {
return value + sum;
}
@Override
public void onTraversalDone(Integer result) {
// Double check traversal result to make count is the same.
// TODO: Is this check necessary?
out.println("[REDUCE RESULT] Traversal result is: " + result);
}
}

View File

@ -5,15 +5,21 @@ import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.util.ArrayList;
import java.util.Hashtable;
import java.io.PrintStream;
/**
* Finds polymorphic sites in the HLA dictionary. Usage: java -jar GenomeAnalysisTK.jar -T FindPolymorphicSites -I HLA_DICTIONARY.bam -R /broad/1KG/reference/human_b36_both.fasta -L INPUT.interval -findFirst | grep -v INFO | sort -k1 > OUTPUT
* @author shermanjia
*/
@Requires({DataSource.READS, DataSource.REFERENCE})
public class FindPolymorphicSitesWalker extends ReadWalker<Integer, Integer> {
@Output
public PrintStream out;
@Argument(fullName = "debugRead", shortName = "debugRead", doc = "Print match score for read", required = false)
public String debugRead = "";

View File

@ -31,9 +31,11 @@ import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.gatk.arguments.GATKArgumentCollection;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.util.*;
import java.util.Map.Entry;
import java.io.PrintStream;
/**
* Calculates the likelihood of observing data given phase info from pairs of HLA alleles. Note: Run FindClosestAlleleWalker first! Usage: java -jar $GATK -T HLACaller -I INPUT.bam -R /broad/1KG/reference/human_b36_both.fasta -L /humgen/gsa-scr1/GSA/sjia/454_HLA/HAPMAP270/HLA_exons.interval -phaseInterval /humgen/gsa-scr1/GSA/sjia/454_HLA/HAPMAP270/HLA_exons.interval -bl IMPUT.baselikelihoods [-filter $ID.filter -minAllowe\
@ -42,6 +44,9 @@ dMismatches 7] -ethnicity Caucasian | grep -v "INFO" | grep -v "DEBUG" | grep -
*/
@Requires({DataSource.READS, DataSource.REFERENCE})
public class HLACallerWalker extends ReadWalker<Integer, Integer> {
@Output
private PrintStream out;
@Argument(fullName = "baseLikelihoods", shortName = "bl", doc = "Base likelihoods file", required = true)
public String baseLikelihoodsFile = "";

Some files were not shown because too many files have changed in this diff Show More