The engine now automatically adds the command-line arguments to the header of every VCF, unless -NO_HEADER is specified.
Changed integration tests, adding the -NO_HEADER argument, for walkers that previously did not include the command-line arg headers. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4326 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
1af9ca6d45
commit
0c99c97685
|
|
@ -48,7 +48,7 @@ public class CommandLineUtils {
|
||||||
* @return A key-value mapping of argument full names to argument values. Produces best string representation
|
* @return A key-value mapping of argument full names to argument values. Produces best string representation
|
||||||
* possible given the information available.
|
* possible given the information available.
|
||||||
*/
|
*/
|
||||||
public static Map<String,String> getApproximateCommandLineArguments(Collection<Object> argumentProviders) {
|
public static Map<String,String> getApproximateCommandLineArguments(Object... argumentProviders) {
|
||||||
Map<String,String> commandLineArguments = new LinkedHashMap<String,String>();
|
Map<String,String> commandLineArguments = new LinkedHashMap<String,String>();
|
||||||
|
|
||||||
for(Object argumentProvider: argumentProviders) {
|
for(Object argumentProvider: argumentProviders) {
|
||||||
|
|
@ -67,47 +67,23 @@ public class CommandLineUtils {
|
||||||
return commandLineArguments;
|
return commandLineArguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static Map<String,String> getApproximateCommandLineArguments(Collection<Object> argumentProviders) {
|
/**
|
||||||
// Map<String,String> commandLineArguments = new LinkedHashMap<String,String>();
|
* Create an approximate list of command-line arguments based on the given argument providers.
|
||||||
//
|
* @param argumentProviders Argument providers to inspect.
|
||||||
// for(Object argumentProvider: argumentProviders) {
|
* @return A string representing the given command-line arguments.
|
||||||
// Map<ArgumentSource, Object> argBings = ParsingEngine.extractArgumentBindings(argumentProvider);
|
*/
|
||||||
// List<ArgumentSource> argumentSources = ParsingEngine.extractArgumentSources(argumentProvider.getClass());
|
public static String createApproximateCommandLineArgumentString(Object... argumentProviders) {
|
||||||
// for(ArgumentSource argumentSource: argumentSources) {
|
Map<String,String> commandLineArgs = getApproximateCommandLineArguments(argumentProviders);
|
||||||
// Object argumentValue = JVMUtils.getFieldValue(argumentSource.field,argumentProvider);
|
|
||||||
// String argumentValueString = argumentValue != null ? argumentValue.toString() : null;
|
|
||||||
//
|
|
||||||
// for(ArgumentDefinition definition: argumentSource.createArgumentDefinitions()) {
|
|
||||||
// String argumentName = definition.fullName;
|
|
||||||
// commandLineArguments.put(argumentName,argumentValueString);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return commandLineArguments;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public static String createApproximateCommandLineArgumentString(GenomeAnalysisEngine toolkit, Walker walker) {
|
|
||||||
return createApproximateCommandLineArgumentString(toolkit, null, walker);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String createApproximateCommandLineArgumentString(GenomeAnalysisEngine toolkit, Collection<Object> otherArgumentProviders, Walker walker) {
|
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
sb.append("analysis_type=");
|
|
||||||
sb.append(toolkit.getWalkerName(walker.getClass()));
|
|
||||||
|
|
||||||
ArrayList<Object> allArgumentProviders = new ArrayList<Object>();
|
|
||||||
allArgumentProviders.add(toolkit.getArguments());
|
|
||||||
allArgumentProviders.add(walker);
|
|
||||||
if (otherArgumentProviders != null) allArgumentProviders.addAll(otherArgumentProviders);
|
|
||||||
|
|
||||||
Map<String,String> commandLineArgs = getApproximateCommandLineArguments(allArgumentProviders);
|
|
||||||
|
|
||||||
|
boolean first = true;
|
||||||
for ( Map.Entry<String, String> commandLineArg : commandLineArgs.entrySet() ) {
|
for ( Map.Entry<String, String> commandLineArg : commandLineArgs.entrySet() ) {
|
||||||
sb.append(" ");
|
if(!first)
|
||||||
|
sb.append(" ");
|
||||||
sb.append(commandLineArg.getKey());
|
sb.append(commandLineArg.getKey());
|
||||||
sb.append("=");
|
sb.append("=");
|
||||||
sb.append(commandLineArg.getValue());
|
sb.append(commandLineArg.getValue());
|
||||||
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
|
|
||||||
|
|
@ -368,23 +368,6 @@ public class ParsingEngine {
|
||||||
return new ArrayList<ArgumentSource>(bindings.keySet());
|
return new ArrayList<ArgumentSource>(bindings.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
// List<ArgumentSource> argumentSources = new ArrayList<ArgumentSource>();
|
|
||||||
// while( sourceClass != null ) {
|
|
||||||
// Field[] fields = sourceClass.getDeclaredFields();
|
|
||||||
// for( Field field: fields ) {
|
|
||||||
// if( ArgumentTypeDescriptor.isArgumentAnnotationPresent(field) )
|
|
||||||
// argumentSources.add( new ArgumentSource(parentFields, field) );
|
|
||||||
// if( field.isAnnotationPresent(ArgumentCollection.class) ) {
|
|
||||||
// Field[] newParentFields = Arrays.copyOf(parentFields, parentFields.length + 1);
|
|
||||||
// newParentFields[parentFields.length] = field;
|
|
||||||
// argumentSources.addAll( extractArgumentSources(field.getType(), newParentFields) );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// sourceClass = sourceClass.getSuperclass();
|
|
||||||
// }
|
|
||||||
// return argumentSources;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public static Map<ArgumentSource, Object> extractArgumentBindings(Object obj) {
|
public static Map<ArgumentSource, Object> extractArgumentBindings(Object obj) {
|
||||||
if ( obj == null ) throw new IllegalArgumentException("Incoming object cannot be null");
|
if ( obj == null ) throw new IllegalArgumentException("Incoming object cannot be null");
|
||||||
return extractArgumentBindings(obj, obj.getClass(), new Field[0]);
|
return extractArgumentBindings(obj, obj.getClass(), new Field[0]);
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,10 @@ package org.broadinstitute.sting.gatk;
|
||||||
import org.broadinstitute.sting.gatk.arguments.GATKArgumentCollection;
|
import org.broadinstitute.sting.gatk.arguments.GATKArgumentCollection;
|
||||||
import org.broadinstitute.sting.commandline.CommandLineProgram;
|
import org.broadinstitute.sting.commandline.CommandLineProgram;
|
||||||
import org.broadinstitute.sting.commandline.ArgumentTypeDescriptor;
|
import org.broadinstitute.sting.commandline.ArgumentTypeDescriptor;
|
||||||
|
import org.broadinstitute.sting.gatk.io.stubs.OutputStreamArgumentTypeDescriptor;
|
||||||
|
import org.broadinstitute.sting.gatk.io.stubs.SAMFileReaderArgumentTypeDescriptor;
|
||||||
|
import org.broadinstitute.sting.gatk.io.stubs.SAMFileWriterArgumentTypeDescriptor;
|
||||||
|
import org.broadinstitute.sting.gatk.io.stubs.VCFWriterArgumentTypeDescriptor;
|
||||||
import org.broadinstitute.sting.gatk.phonehome.GATKRunReport;
|
import org.broadinstitute.sting.gatk.phonehome.GATKRunReport;
|
||||||
import org.broadinstitute.sting.gatk.walkers.Walker;
|
import org.broadinstitute.sting.gatk.walkers.Walker;
|
||||||
|
|
||||||
|
|
@ -39,15 +43,13 @@ import net.sf.picard.filter.SamRecordFilter;
|
||||||
* @author aaron
|
* @author aaron
|
||||||
*/
|
*/
|
||||||
public abstract class CommandLineExecutable extends CommandLineProgram {
|
public abstract class CommandLineExecutable extends CommandLineProgram {
|
||||||
public Object GATKResult = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The actual engine which performs the analysis.
|
* The actual engine which performs the analysis.
|
||||||
*/
|
*/
|
||||||
protected GenomeAnalysisEngine GATKEngine = new GenomeAnalysisEngine();
|
protected GenomeAnalysisEngine engine = new GenomeAnalysisEngine();
|
||||||
|
|
||||||
// get the analysis name
|
// get the analysis name
|
||||||
protected abstract String getAnalysisName();
|
public abstract String getAnalysisName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the GATK argument bundle.
|
* Gets the GATK argument bundle.
|
||||||
|
|
@ -55,8 +57,10 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
|
||||||
*/
|
*/
|
||||||
protected abstract GATKArgumentCollection getArgumentCollection();
|
protected abstract GATKArgumentCollection getArgumentCollection();
|
||||||
|
|
||||||
// override select arguments
|
/**
|
||||||
protected void overrideArguments() { }
|
* A list of all the arguments initially used as sources.
|
||||||
|
*/
|
||||||
|
private final Collection<Object> argumentSources = new ArrayList<Object>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this is the function that the inheriting class can expect to have called
|
* this is the function that the inheriting class can expect to have called
|
||||||
|
|
@ -65,21 +69,30 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
|
||||||
* @return the return code to exit the program with
|
* @return the return code to exit the program with
|
||||||
*/
|
*/
|
||||||
protected int execute() throws Exception {
|
protected int execute() throws Exception {
|
||||||
Walker<?,?> mWalker = GATKEngine.getWalkerByName(getAnalysisName());
|
argumentSources.add(this);
|
||||||
|
|
||||||
|
Walker<?,?> walker = engine.getWalkerByName(getAnalysisName());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Collection<SamRecordFilter> filters = GATKEngine.createFiltersForWalker(getArgumentCollection(),mWalker);
|
Collection<SamRecordFilter> filters = engine.createFiltersForWalker(getArgumentCollection(),walker);
|
||||||
|
|
||||||
// load the arguments into the walker / filters.
|
// load the arguments into the walker / filters.
|
||||||
loadArgumentsIntoObject(mWalker);
|
// TODO: The fact that this extra load call exists here when all the parsing happens at the engine
|
||||||
for (SamRecordFilter filter: filters)
|
// TODO: level indicates that we're doing something wrong. Turn this around so that the GATK can drive
|
||||||
|
// TODO: argument processing.
|
||||||
|
loadArgumentsIntoObject(walker);
|
||||||
|
argumentSources.add(walker);
|
||||||
|
|
||||||
|
for (SamRecordFilter filter: filters) {
|
||||||
loadArgumentsIntoObject(filter);
|
loadArgumentsIntoObject(filter);
|
||||||
|
argumentSources.add(filter);
|
||||||
|
}
|
||||||
|
|
||||||
// set the analysis name in the argument collection
|
// set the analysis name in the argument collection
|
||||||
GATKResult = GATKEngine.execute(getArgumentCollection(), mWalker, filters);
|
engine.execute(getArgumentCollection(), walker, filters);
|
||||||
generateGATKRunReport(mWalker);
|
generateGATKRunReport(walker);
|
||||||
} catch ( Exception e ) {
|
} catch ( Exception e ) {
|
||||||
generateGATKRunReport(mWalker, e);
|
generateGATKRunReport(walker, e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,9 +107,9 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
|
||||||
*
|
*
|
||||||
* @param e the exception, can be null if no exception occurred
|
* @param e the exception, can be null if no exception occurred
|
||||||
*/
|
*/
|
||||||
private void generateGATKRunReport(Walker<?,?> mWalker, Exception e) {
|
private void generateGATKRunReport(Walker<?,?> walker, Exception e) {
|
||||||
if ( getArgumentCollection().phoneHomeType != GATKRunReport.PhoneHomeOption.NO_ET ) {
|
if ( getArgumentCollection().phoneHomeType != GATKRunReport.PhoneHomeOption.NO_ET ) {
|
||||||
GATKRunReport report = new GATKRunReport(mWalker, e, GATKEngine, getArgumentCollection().phoneHomeType );
|
GATKRunReport report = new GATKRunReport(walker, e, engine, getArgumentCollection().phoneHomeType );
|
||||||
if ( getArgumentCollection().phoneHomeType == GATKRunReport.PhoneHomeOption.STDOUT )
|
if ( getArgumentCollection().phoneHomeType == GATKRunReport.PhoneHomeOption.STDOUT )
|
||||||
report.postReport(System.out);
|
report.postReport(System.out);
|
||||||
else
|
else
|
||||||
|
|
@ -108,10 +121,10 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
|
||||||
* Convenience method for fully parameterized generateGATKRunReport when an exception has
|
* Convenience method for fully parameterized generateGATKRunReport when an exception has
|
||||||
* not occurred
|
* not occurred
|
||||||
*
|
*
|
||||||
* @param mWalker
|
* @param walker
|
||||||
*/
|
*/
|
||||||
private void generateGATKRunReport(Walker<?,?> mWalker) {
|
private void generateGATKRunReport(Walker<?,?> walker) {
|
||||||
generateGATKRunReport(mWalker, null);
|
generateGATKRunReport(walker, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -119,7 +132,10 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
|
||||||
* @return A collection of type descriptors generating implementation-dependent placeholders.
|
* @return A collection of type descriptors generating implementation-dependent placeholders.
|
||||||
*/
|
*/
|
||||||
protected Collection<ArgumentTypeDescriptor> getArgumentTypeDescriptors() {
|
protected Collection<ArgumentTypeDescriptor> getArgumentTypeDescriptors() {
|
||||||
return GATKEngine.getArgumentTypeDescriptors();
|
return Arrays.asList( new VCFWriterArgumentTypeDescriptor(engine,System.out,argumentSources),
|
||||||
|
new SAMFileReaderArgumentTypeDescriptor(engine),
|
||||||
|
new SAMFileWriterArgumentTypeDescriptor(engine,System.out),
|
||||||
|
new OutputStreamArgumentTypeDescriptor(engine,System.out) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -143,10 +159,10 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
|
||||||
|
|
||||||
Collection<Class> argumentSources = new ArrayList<Class>();
|
Collection<Class> argumentSources = new ArrayList<Class>();
|
||||||
|
|
||||||
Walker walker = GATKEngine.getWalkerByName(getAnalysisName());
|
Walker walker = engine.getWalkerByName(getAnalysisName());
|
||||||
argumentSources.add(walker.getClass());
|
argumentSources.add(walker.getClass());
|
||||||
|
|
||||||
Collection<SamRecordFilter> filters = GATKEngine.createFiltersForWalker(getArgumentCollection(),walker);
|
Collection<SamRecordFilter> filters = engine.createFiltersForWalker(getArgumentCollection(),walker);
|
||||||
for(SamRecordFilter filter: filters)
|
for(SamRecordFilter filter: filters)
|
||||||
argumentSources.add(filter.getClass());
|
argumentSources.add(filter.getClass());
|
||||||
|
|
||||||
|
|
@ -156,7 +172,7 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getArgumentSourceName( Class argumentSource ) {
|
protected String getArgumentSourceName( Class argumentSource ) {
|
||||||
return GATKEngine.getWalkerName((Class<Walker>)argumentSource);
|
return engine.getWalkerName((Class<Walker>)argumentSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -166,6 +182,6 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void addTags(Object key, List<String> tags) {
|
protected void addTags(Object key, List<String> tags) {
|
||||||
GATKEngine.addTags(key,tags);
|
engine.addTags(key,tags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public class CommandLineGATK extends CommandLineExecutable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getAnalysisName() {
|
public String getAnalysisName() {
|
||||||
return analysisName;
|
return analysisName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -132,7 +132,7 @@ public class CommandLineGATK extends CommandLineExecutable {
|
||||||
String additionalHelp;
|
String additionalHelp;
|
||||||
|
|
||||||
// If no analysis name is present, fill in extra help on the walkers.
|
// If no analysis name is present, fill in extra help on the walkers.
|
||||||
WalkerManager walkerManager = GATKEngine.getWalkerManager();
|
WalkerManager walkerManager = engine.getWalkerManager();
|
||||||
String analysisName = getAnalysisName();
|
String analysisName = getAnalysisName();
|
||||||
if(analysisName != null && walkerManager.exists(getAnalysisName()))
|
if(analysisName != null && walkerManager.exists(getAnalysisName()))
|
||||||
additionalHelp = getWalkerHelp(walkerManager.getWalkerClassByName(getAnalysisName()));
|
additionalHelp = getWalkerHelp(walkerManager.getWalkerClassByName(getAnalysisName()));
|
||||||
|
|
@ -153,7 +153,7 @@ public class CommandLineGATK extends CommandLineExecutable {
|
||||||
|
|
||||||
formatter.format("Description:%n");
|
formatter.format("Description:%n");
|
||||||
|
|
||||||
WalkerManager walkerManager = GATKEngine.getWalkerManager();
|
WalkerManager walkerManager = engine.getWalkerManager();
|
||||||
String walkerHelpText = walkerManager.getWalkerDescriptionText(walkerType);
|
String walkerHelpText = walkerManager.getWalkerDescriptionText(walkerType);
|
||||||
|
|
||||||
printDescriptorLine(formatter,WALKER_INDENT,"",WALKER_INDENT,FIELD_SEPARATOR,walkerHelpText,TextFormattingUtils.DEFAULT_LINE_WIDTH);
|
printDescriptorLine(formatter,WALKER_INDENT,"",WALKER_INDENT,FIELD_SEPARATOR,walkerHelpText,TextFormattingUtils.DEFAULT_LINE_WIDTH);
|
||||||
|
|
@ -173,7 +173,7 @@ public class CommandLineGATK extends CommandLineExecutable {
|
||||||
formatter.format("Available analyses:%n");
|
formatter.format("Available analyses:%n");
|
||||||
|
|
||||||
// Get the list of walker names from the walker manager.
|
// Get the list of walker names from the walker manager.
|
||||||
WalkerManager walkerManager = GATKEngine.getWalkerManager();
|
WalkerManager walkerManager = engine.getWalkerManager();
|
||||||
|
|
||||||
// Build a list sorted by walker display name. As this information is collected, keep track of the longest
|
// Build a list sorted by walker display name. As this information is collected, keep track of the longest
|
||||||
// package / walker name for later formatting.
|
// package / walker name for later formatting.
|
||||||
|
|
|
||||||
|
|
@ -563,19 +563,6 @@ 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.
|
* Bundles all the source information about the reads into a unified data structure.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,6 @@ public class SAMFileWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor
|
||||||
* @return Argument definition for the BAM file itself. Will not be null.
|
* @return Argument definition for the BAM file itself. Will not be null.
|
||||||
*/
|
*/
|
||||||
private ArgumentDefinition createBAMCompressionArgumentDefinition(ArgumentSource source) {
|
private ArgumentDefinition createBAMCompressionArgumentDefinition(ArgumentSource source) {
|
||||||
Annotation annotation = getArgumentAnnotation(source);
|
|
||||||
return new ArgumentDefinition( ArgumentIOType.ARGUMENT,
|
return new ArgumentDefinition( ArgumentIOType.ARGUMENT,
|
||||||
int.class,
|
int.class,
|
||||||
COMPRESSION_FULLNAME,
|
COMPRESSION_FULLNAME,
|
||||||
|
|
@ -161,7 +160,6 @@ public class SAMFileWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArgumentDefinition createWriteIndexArgumentDefinition(ArgumentSource source) {
|
private ArgumentDefinition createWriteIndexArgumentDefinition(ArgumentSource source) {
|
||||||
Annotation annotation = getArgumentAnnotation(source);
|
|
||||||
return new ArgumentDefinition( ArgumentIOType.ARGUMENT,
|
return new ArgumentDefinition( ArgumentIOType.ARGUMENT,
|
||||||
boolean.class,
|
boolean.class,
|
||||||
CREATE_INDEX_FULLNAME,
|
CREATE_INDEX_FULLNAME,
|
||||||
|
|
|
||||||
|
|
@ -25,15 +25,18 @@
|
||||||
|
|
||||||
package org.broadinstitute.sting.gatk.io.stubs;
|
package org.broadinstitute.sting.gatk.io.stubs;
|
||||||
|
|
||||||
|
import org.broad.tribble.vcf.VCFHeaderLine;
|
||||||
import org.broad.tribble.vcf.VCFWriter;
|
import org.broad.tribble.vcf.VCFWriter;
|
||||||
import org.broadinstitute.sting.commandline.*;
|
import org.broadinstitute.sting.commandline.*;
|
||||||
|
import org.broadinstitute.sting.gatk.CommandLineExecutable;
|
||||||
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
|
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
|
||||||
|
import org.broadinstitute.sting.utils.classloader.JVMUtils;
|
||||||
|
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.List;
|
import java.lang.annotation.Annotation;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects new command-line arguments into the system providing support for the genotype writer.
|
* Injects new command-line arguments into the system providing support for the genotype writer.
|
||||||
|
|
@ -42,8 +45,9 @@ import java.util.HashSet;
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
public class VCFWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor {
|
public class VCFWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor {
|
||||||
|
private static final String NO_HEADER_ARG_NAME = "NO_HEADER";
|
||||||
private static final HashSet<String> SUPPORTED_ZIPPED_SUFFIXES = new HashSet<String>();
|
private static final HashSet<String> SUPPORTED_ZIPPED_SUFFIXES = new HashSet<String>();
|
||||||
|
|
||||||
//
|
//
|
||||||
// static list of zipped suffixes supported by this system.
|
// static list of zipped suffixes supported by this system.
|
||||||
//
|
//
|
||||||
|
|
@ -55,21 +59,28 @@ public class VCFWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor {
|
||||||
/**
|
/**
|
||||||
* The engine into which output stubs should be fed.
|
* 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.
|
* The default location to which data should be written if the user specifies no such location.
|
||||||
*/
|
*/
|
||||||
private final OutputStream defaultOutputStream;
|
private final OutputStream defaultOutputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sources into which arguments were injected.
|
||||||
|
*/
|
||||||
|
private final Collection<Object> argumentSources;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new GenotypeWriter argument, notifying the given engine when that argument has been created.
|
* Create a new GenotypeWriter argument, notifying the given engine when that argument has been created.
|
||||||
* @param engine the engine to be notified.
|
* @param engine the engine to be notified.
|
||||||
* @param defaultOutputStream the default output stream to be written to if nothing else is specified.
|
* @param defaultOutputStream the default output stream to be written to if nothing else is specified.
|
||||||
|
* @param argumentSources sources from which command-line arguments should be derived.
|
||||||
*/
|
*/
|
||||||
public VCFWriterArgumentTypeDescriptor(GenomeAnalysisEngine engine, OutputStream defaultOutputStream) {
|
public VCFWriterArgumentTypeDescriptor(GenomeAnalysisEngine engine, OutputStream defaultOutputStream, Collection<Object> argumentSources) {
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
this.defaultOutputStream = defaultOutputStream;
|
this.defaultOutputStream = defaultOutputStream;
|
||||||
|
this.argumentSources = argumentSources;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -84,7 +95,7 @@ public class VCFWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ArgumentDefinition> createArgumentDefinitions( ArgumentSource source ) {
|
public List<ArgumentDefinition> createArgumentDefinitions( ArgumentSource source ) {
|
||||||
return Arrays.asList( createDefaultArgumentDefinition(source) );
|
return Arrays.asList( createDefaultArgumentDefinition(source),createNoHeaderArgumentDefinition());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -98,7 +109,7 @@ public class VCFWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createTypeDefault(ArgumentSource source,Class type) {
|
public Object createTypeDefault(ArgumentSource source,Class type) {
|
||||||
VCFWriterStub stub = new VCFWriterStub(defaultOutputStream, false);
|
VCFWriterStub stub = new VCFWriterStub(defaultOutputStream, false, argumentSources, false);
|
||||||
engine.addOutput(stub);
|
engine.addOutput(stub);
|
||||||
return stub;
|
return stub;
|
||||||
}
|
}
|
||||||
|
|
@ -119,8 +130,11 @@ public class VCFWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor {
|
||||||
// Should we compress the output stream?
|
// Should we compress the output stream?
|
||||||
boolean compress = writerFileName != null && SUPPORTED_ZIPPED_SUFFIXES.contains(getFileSuffix(writerFileName));
|
boolean compress = writerFileName != null && SUPPORTED_ZIPPED_SUFFIXES.contains(getFileSuffix(writerFileName));
|
||||||
|
|
||||||
|
boolean skipWritingHeader = argumentIsPresent(createNoHeaderArgumentDefinition(),matches);
|
||||||
|
|
||||||
// Create a stub for the given object.
|
// Create a stub for the given object.
|
||||||
VCFWriterStub stub = (writerFile != null) ? new VCFWriterStub(writerFile, compress) : new VCFWriterStub(System.out, compress);
|
VCFWriterStub stub = (writerFile != null) ? new VCFWriterStub(writerFile, compress, argumentSources, skipWritingHeader)
|
||||||
|
: new VCFWriterStub(defaultOutputStream, compress, argumentSources, skipWritingHeader);
|
||||||
|
|
||||||
// WARNING: Side effects required by engine!
|
// WARNING: Side effects required by engine!
|
||||||
parsingEngine.addTags(stub,getArgumentTags(matches));
|
parsingEngine.addTags(stub,getArgumentTags(matches));
|
||||||
|
|
@ -129,6 +143,27 @@ public class VCFWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor {
|
||||||
return stub;
|
return stub;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the optional compression level argument for the BAM file.
|
||||||
|
* @return Argument definition for the BAM file itself. Will not be null.
|
||||||
|
*/
|
||||||
|
private ArgumentDefinition createNoHeaderArgumentDefinition() {
|
||||||
|
return new ArgumentDefinition( ArgumentIOType.ARGUMENT,
|
||||||
|
boolean.class,
|
||||||
|
NO_HEADER_ARG_NAME,
|
||||||
|
NO_HEADER_ARG_NAME,
|
||||||
|
"Don't output the usual VCF header tag with the command line. FOR DEBUGGING PURPOSES ONLY. This option is required in order to pass integration tests.",
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a lower-cased version of the suffix of the provided file.
|
* Returns a lower-cased version of the suffix of the provided file.
|
||||||
* @param fileName the file name. Must not be null.
|
* @param fileName the file name. Must not be null.
|
||||||
|
|
@ -140,4 +175,5 @@ public class VCFWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor {
|
||||||
return "";
|
return "";
|
||||||
return fileName.substring(indexOfLastDot).toLowerCase();
|
return fileName.substring(indexOfLastDot).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,18 @@ package org.broadinstitute.sting.gatk.io.stubs;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import org.broad.tribble.util.variantcontext.VariantContext;
|
import org.broad.tribble.util.variantcontext.VariantContext;
|
||||||
import org.broad.tribble.vcf.VCFHeader;
|
import org.broad.tribble.vcf.VCFHeader;
|
||||||
|
import org.broad.tribble.vcf.VCFHeaderLine;
|
||||||
import org.broad.tribble.vcf.VCFWriter;
|
import org.broad.tribble.vcf.VCFWriter;
|
||||||
|
import org.broadinstitute.sting.commandline.CommandLineUtils;
|
||||||
|
import org.broadinstitute.sting.gatk.CommandLineExecutable;
|
||||||
import org.broadinstitute.sting.gatk.io.OutputTracker;
|
import org.broadinstitute.sting.gatk.io.OutputTracker;
|
||||||
|
import org.broadinstitute.sting.utils.classloader.JVMUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A stub for routing and management of genotype reading and writing.
|
* A stub for routing and management of genotype reading and writing.
|
||||||
|
|
@ -55,7 +62,7 @@ public class VCFWriterStub implements Stub<VCFWriter>, VCFWriter {
|
||||||
private final PrintStream genotypeStream;
|
private final PrintStream genotypeStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The cached VCF header (initilized to null)
|
* The cached VCF header (initialized to null)
|
||||||
*/
|
*/
|
||||||
private VCFHeader vcfHeader = null;
|
private VCFHeader vcfHeader = null;
|
||||||
|
|
||||||
|
|
@ -64,6 +71,17 @@ public class VCFWriterStub implements Stub<VCFWriter>, VCFWriter {
|
||||||
*/
|
*/
|
||||||
private final boolean isCompressed;
|
private final boolean isCompressed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hack: push the argument sources into the VCF header so that the VCF header
|
||||||
|
* can rebuild the command-line arguments.
|
||||||
|
*/
|
||||||
|
private final Collection<Object> argumentSources;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should the header be written out? A hidden argument.
|
||||||
|
*/
|
||||||
|
private final boolean skipWritingHeader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects this stub with an external stream capable of serving the
|
* Connects this stub with an external stream capable of serving the
|
||||||
* requests of the consumer of this stub.
|
* requests of the consumer of this stub.
|
||||||
|
|
@ -75,10 +93,12 @@ public class VCFWriterStub implements Stub<VCFWriter>, VCFWriter {
|
||||||
* @param genotypeFile file to (ultimately) create.
|
* @param genotypeFile file to (ultimately) create.
|
||||||
* @param isCompressed should we compress the output stream?
|
* @param isCompressed should we compress the output stream?
|
||||||
*/
|
*/
|
||||||
public VCFWriterStub(File genotypeFile, boolean isCompressed) {
|
public VCFWriterStub(File genotypeFile, boolean isCompressed, Collection<Object> argumentSources, boolean skipWritingHeader) {
|
||||||
this.genotypeFile = genotypeFile;
|
this.genotypeFile = genotypeFile;
|
||||||
this.genotypeStream = null;
|
this.genotypeStream = null;
|
||||||
this.isCompressed = isCompressed;
|
this.isCompressed = isCompressed;
|
||||||
|
this.argumentSources = argumentSources;
|
||||||
|
this.skipWritingHeader = skipWritingHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -86,10 +106,12 @@ public class VCFWriterStub implements Stub<VCFWriter>, VCFWriter {
|
||||||
* @param genotypeStream stream to (ultimately) write.
|
* @param genotypeStream stream to (ultimately) write.
|
||||||
* @param isCompressed should we compress the output stream?
|
* @param isCompressed should we compress the output stream?
|
||||||
*/
|
*/
|
||||||
public VCFWriterStub(OutputStream genotypeStream, boolean isCompressed) {
|
public VCFWriterStub(OutputStream genotypeStream, boolean isCompressed, Collection<Object> argumentSources, boolean skipWritingHeader) {
|
||||||
this.genotypeFile = null;
|
this.genotypeFile = null;
|
||||||
this.genotypeStream = new PrintStream(genotypeStream);
|
this.genotypeStream = new PrintStream(genotypeStream);
|
||||||
this.isCompressed = isCompressed;
|
this.isCompressed = isCompressed;
|
||||||
|
this.argumentSources = argumentSources;
|
||||||
|
this.skipWritingHeader = skipWritingHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -134,7 +156,18 @@ public class VCFWriterStub implements Stub<VCFWriter>, VCFWriter {
|
||||||
|
|
||||||
public void writeHeader(VCFHeader header) {
|
public void writeHeader(VCFHeader header) {
|
||||||
vcfHeader = header;
|
vcfHeader = header;
|
||||||
outputTracker.getStorage(this).writeHeader(header);
|
|
||||||
|
// Check for the command-line argument header line. If not present, add it in.
|
||||||
|
VCFHeaderLine commandLineArgHeaderLine = getCommandLineArgumentHeaderLine();
|
||||||
|
boolean foundCommandLineHeaderLine = false;
|
||||||
|
for(VCFHeaderLine line: vcfHeader.getMetaData()) {
|
||||||
|
if(line.getKey().equals(commandLineArgHeaderLine.getKey()))
|
||||||
|
foundCommandLineHeaderLine = true;
|
||||||
|
}
|
||||||
|
if(!foundCommandLineHeaderLine && !skipWritingHeader)
|
||||||
|
vcfHeader.addMetaDataLine(commandLineArgHeaderLine);
|
||||||
|
|
||||||
|
outputTracker.getStorage(this).writeHeader(vcfHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -150,4 +183,22 @@ public class VCFWriterStub implements Stub<VCFWriter>, VCFWriter {
|
||||||
public void close() {
|
public void close() {
|
||||||
outputTracker.getStorage(this).close();
|
outputTracker.getStorage(this).close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a string representation of this object.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getClass().getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the appropriately formatted header for a VCF file
|
||||||
|
* @return VCF file header.
|
||||||
|
*/
|
||||||
|
private VCFHeaderLine getCommandLineArgumentHeaderLine() {
|
||||||
|
CommandLineExecutable executable = JVMUtils.getObjectOfType(argumentSources,CommandLineExecutable.class);
|
||||||
|
return new VCFHeaderLine(executable.getAnalysisName(), "\"" + CommandLineUtils.createApproximateCommandLineArgumentString(argumentSources) + "\"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -80,9 +80,6 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
|
||||||
@Argument(fullName="vcfContainsOnlyIndels", shortName="dels",doc="Use if you are annotating an indel vcf, currently VERY experimental", required = false)
|
@Argument(fullName="vcfContainsOnlyIndels", shortName="dels",doc="Use if you are annotating an indel vcf, currently VERY experimental", required = false)
|
||||||
protected boolean indelsOnly = false;
|
protected boolean indelsOnly = false;
|
||||||
|
|
||||||
@Argument(fullName = "NO_HEADER", shortName = "NO_HEADER", doc = "Don't output the usual VCF header tag with the command line. FOR DEBUGGING PURPOSES ONLY. This option is required in order to pass integration tests.", required = false)
|
|
||||||
protected Boolean NO_VCF_HEADER_LINE = false;
|
|
||||||
|
|
||||||
private HashMap<String, String> nonVCFsampleName = new HashMap<String, String>();
|
private HashMap<String, String> nonVCFsampleName = new HashMap<String, String>();
|
||||||
|
|
||||||
private VariantAnnotatorEngine engine;
|
private VariantAnnotatorEngine engine;
|
||||||
|
|
@ -145,9 +142,6 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
|
||||||
if ( isUniqueHeaderLine(line, hInfo) )
|
if ( isUniqueHeaderLine(line, hInfo) )
|
||||||
hInfo.add(line);
|
hInfo.add(line);
|
||||||
}
|
}
|
||||||
if ( !NO_VCF_HEADER_LINE ) {
|
|
||||||
hInfo.add(new VCFHeaderLine("VariantAnnotator", "\"" + CommandLineUtils.createApproximateCommandLineArgumentString(getToolkit(), this) + "\""));
|
|
||||||
}
|
|
||||||
|
|
||||||
VCFHeader vcfHeader = new VCFHeader(hInfo, samples);
|
VCFHeader vcfHeader = new VCFHeader(hInfo, samples);
|
||||||
vcfWriter.writeHeader(vcfHeader);
|
vcfWriter.writeHeader(vcfHeader);
|
||||||
|
|
|
||||||
|
|
@ -72,10 +72,6 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
|
||||||
@Argument(fullName="maskName", shortName="mask", doc="The text to put in the FILTER field if a 'mask' rod is provided and overlaps with a variant call; [default:'Mask']", required=false)
|
@Argument(fullName="maskName", shortName="mask", doc="The text to put in the FILTER field if a 'mask' rod is provided and overlaps with a variant call; [default:'Mask']", required=false)
|
||||||
protected String MASK_NAME = "Mask";
|
protected String MASK_NAME = "Mask";
|
||||||
|
|
||||||
@Hidden
|
|
||||||
@Argument(fullName = "NO_HEADER", shortName = "NO_HEADER", doc = "Don't output the usual VCF header tag with the command line. FOR DEBUGGING PURPOSES ONLY. This option is required in order to pass integration tests.", required = false)
|
|
||||||
protected Boolean NO_VCF_HEADER_LINE = false;
|
|
||||||
|
|
||||||
// JEXL expressions for the filters
|
// JEXL expressions for the filters
|
||||||
List<VariantContextUtils.JexlVCMatchExp> filterExps;
|
List<VariantContextUtils.JexlVCMatchExp> filterExps;
|
||||||
List<VariantContextUtils.JexlVCMatchExp> genotypeFilterExps;
|
List<VariantContextUtils.JexlVCMatchExp> genotypeFilterExps;
|
||||||
|
|
@ -113,10 +109,6 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !NO_VCF_HEADER_LINE ) {
|
|
||||||
hInfo.add(new VCFHeaderLine("VariantFiltration", "\"" + CommandLineUtils.createApproximateCommandLineArgumentString(getToolkit(), this) + "\""));
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.writeHeader(new VCFHeader(hInfo, vc.getSampleNames()));
|
writer.writeHeader(new VCFHeader(hInfo, vc.getSampleNames()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,10 +71,6 @@ public class UnifiedGenotyper extends LocusWalker<VariantCallContext, UnifiedGen
|
||||||
@Argument(fullName="group", shortName="G", doc="One or more classes/groups of annotations to apply to variant calls", required=false)
|
@Argument(fullName="group", shortName="G", doc="One or more classes/groups of annotations to apply to variant calls", required=false)
|
||||||
protected String[] annotationClassesToUse = { "Standard" };
|
protected String[] annotationClassesToUse = { "Standard" };
|
||||||
|
|
||||||
@Argument(fullName = "NO_HEADER", shortName = "NO_HEADER", doc = "Don't output the usual VCF header tag with the command line. FOR DEBUGGING PURPOSES ONLY. This option is required in order to pass integration tests.", required = false)
|
|
||||||
protected Boolean NO_VCF_HEADER_LINE = false;
|
|
||||||
|
|
||||||
|
|
||||||
// the calculation arguments
|
// the calculation arguments
|
||||||
private UnifiedGenotyperEngine UG_engine = null;
|
private UnifiedGenotyperEngine UG_engine = null;
|
||||||
|
|
||||||
|
|
@ -154,11 +150,6 @@ public class UnifiedGenotyper extends LocusWalker<VariantCallContext, UnifiedGen
|
||||||
UAC.TRIGGER_CONFIDENCE_FOR_EMITTING < UAC.TRIGGER_CONFIDENCE_FOR_CALLING )
|
UAC.TRIGGER_CONFIDENCE_FOR_EMITTING < UAC.TRIGGER_CONFIDENCE_FOR_CALLING )
|
||||||
headerInfo.add(new VCFFilterHeaderLine(UnifiedGenotyperEngine.LOW_QUAL_FILTER_NAME, "Low quality"));
|
headerInfo.add(new VCFFilterHeaderLine(UnifiedGenotyperEngine.LOW_QUAL_FILTER_NAME, "Low quality"));
|
||||||
|
|
||||||
// all of the arguments from the argument collection
|
|
||||||
if ( !NO_VCF_HEADER_LINE ) {
|
|
||||||
headerInfo.add(new VCFHeaderLine("UnifiedGenotyper", "\"" + CommandLineUtils.createApproximateCommandLineArgumentString(getToolkit(), this) + "\""));
|
|
||||||
}
|
|
||||||
|
|
||||||
return headerInfo;
|
return headerInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,13 +73,6 @@ public class ApplyVariantCuts extends RodWalker<Integer, Integer> {
|
||||||
@Argument(fullName="fdr_filter_level", shortName="fdr_filter_level", doc="The FDR level at which to start filtering.", required=false)
|
@Argument(fullName="fdr_filter_level", shortName="fdr_filter_level", doc="The FDR level at which to start filtering.", required=false)
|
||||||
private double FDR_FILTER_LEVEL = 0.0;
|
private double FDR_FILTER_LEVEL = 0.0;
|
||||||
|
|
||||||
/////////////////////////////
|
|
||||||
// Debug Arguments
|
|
||||||
/////////////////////////////
|
|
||||||
@Hidden
|
|
||||||
@Argument(fullName = "NO_HEADER", shortName = "NO_HEADER", doc = "Don't output the usual VCF header tag with the command line. FOR DEBUGGING PURPOSES ONLY. This option is required in order to pass integration tests.", required = false)
|
|
||||||
protected Boolean NO_VCF_HEADER_LINE = false;
|
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// Private Member Variables
|
// Private Member Variables
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
|
|
@ -167,9 +160,6 @@ public class ApplyVariantCuts extends RodWalker<Integer, Integer> {
|
||||||
// setup the header fields
|
// setup the header fields
|
||||||
final Set<VCFHeaderLine> hInfo = new HashSet<VCFHeaderLine>();
|
final Set<VCFHeaderLine> hInfo = new HashSet<VCFHeaderLine>();
|
||||||
hInfo.addAll(VCFUtils.getHeaderFields(getToolkit()));
|
hInfo.addAll(VCFUtils.getHeaderFields(getToolkit()));
|
||||||
if( !NO_VCF_HEADER_LINE ) {
|
|
||||||
hInfo.add(new VCFHeaderLine("ApplyVariantCuts", "\"" + CommandLineUtils.createApproximateCommandLineArgumentString(getToolkit(), this) + "\""));
|
|
||||||
}
|
|
||||||
final TreeSet<String> samples = new TreeSet<String>();
|
final TreeSet<String> samples = new TreeSet<String>();
|
||||||
samples.addAll(SampleUtils.getUniqueSamplesFromRods(getToolkit()));
|
samples.addAll(SampleUtils.getUniqueSamplesFromRods(getToolkit()));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,9 +111,6 @@ public class VariantRecalibrator extends RodWalker<ExpandingArrayList<VariantDat
|
||||||
// Debug Arguments
|
// Debug Arguments
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
@Hidden
|
@Hidden
|
||||||
@Argument(fullName = "NO_HEADER", shortName = "NO_HEADER", doc = "Don't output the usual VCF header tag with the command line. FOR DEBUGGING PURPOSES ONLY. This option is required in order to pass integration tests.", required = false)
|
|
||||||
protected Boolean NO_VCF_HEADER_LINE = false;
|
|
||||||
@Hidden
|
|
||||||
@Argument(fullName = "NoByHapMapValidationStatus", shortName = "NoByHapMapValidationStatus", doc = "Don't consider sites in dbsnp rod tagged as by-hapmap validation status as real HapMap sites. FOR DEBUGGING PURPOSES ONLY.", required=false)
|
@Argument(fullName = "NoByHapMapValidationStatus", shortName = "NoByHapMapValidationStatus", doc = "Don't consider sites in dbsnp rod tagged as by-hapmap validation status as real HapMap sites. FOR DEBUGGING PURPOSES ONLY.", required=false)
|
||||||
private Boolean NO_BY_HAPMAP_VALIDATION_STATUS = false;
|
private Boolean NO_BY_HAPMAP_VALIDATION_STATUS = false;
|
||||||
|
|
||||||
|
|
@ -182,9 +179,6 @@ public class VariantRecalibrator extends RodWalker<ExpandingArrayList<VariantDat
|
||||||
hInfo.addAll(VCFUtils.getHeaderFields(getToolkit(), inputNames));
|
hInfo.addAll(VCFUtils.getHeaderFields(getToolkit(), inputNames));
|
||||||
hInfo.add(new VCFInfoHeaderLine("OQ", 1, VCFHeaderLineType.Float, "The original variant quality score"));
|
hInfo.add(new VCFInfoHeaderLine("OQ", 1, VCFHeaderLineType.Float, "The original variant quality score"));
|
||||||
hInfo.add(new VCFInfoHeaderLine("LOD", 1, VCFHeaderLineType.Float, "The log odds ratio calculated by the VR algorithm which was turned into the phred scaled recalibrated quality score"));
|
hInfo.add(new VCFInfoHeaderLine("LOD", 1, VCFHeaderLineType.Float, "The log odds ratio calculated by the VR algorithm which was turned into the phred scaled recalibrated quality score"));
|
||||||
if( !NO_VCF_HEADER_LINE ) {
|
|
||||||
hInfo.add(new VCFHeaderLine("VariantRecalibrator", "\"" + CommandLineUtils.createApproximateCommandLineArgumentString(getToolkit(), this) + "\""));
|
|
||||||
}
|
|
||||||
samples.addAll(SampleUtils.getUniqueSamplesFromRods(getToolkit(), inputNames));
|
samples.addAll(SampleUtils.getUniqueSamplesFromRods(getToolkit(), inputNames));
|
||||||
|
|
||||||
final VCFHeader vcfHeader = new VCFHeader(hInfo, samples);
|
final VCFHeader vcfHeader = new VCFHeader(hInfo, samples);
|
||||||
|
|
|
||||||
|
|
@ -81,10 +81,6 @@ public class CombineVariants extends RodWalker<Integer, Integer> {
|
||||||
@Argument(fullName="setKey", shortName="setKey", doc="Key, by default set, in the INFO key=value tag emitted describing which set the combined VCF record came from. Set to null if you don't want the set field emitted.", required=false)
|
@Argument(fullName="setKey", shortName="setKey", doc="Key, by default set, in the INFO key=value tag emitted describing which set the combined VCF record came from. Set to null if you don't want the set field emitted.", required=false)
|
||||||
public String SET_KEY = "set";
|
public String SET_KEY = "set";
|
||||||
|
|
||||||
@Hidden
|
|
||||||
@Argument(fullName = "NO_HEADER", shortName = "NO_HEADER", doc = "Don't output the usual VCF header tag with the command line. FOR DEBUGGING PURPOSES ONLY. This option is required in order to pass integration tests.", required = false)
|
|
||||||
protected Boolean NO_VCF_HEADER_LINE = false;
|
|
||||||
|
|
||||||
private List<String> priority = null;
|
private List<String> priority = null;
|
||||||
|
|
||||||
private VariantAnnotatorEngine engine;
|
private VariantAnnotatorEngine engine;
|
||||||
|
|
@ -105,9 +101,6 @@ public class CombineVariants extends RodWalker<Integer, Integer> {
|
||||||
Set<VCFHeaderLine> headerLines = VCFUtils.smartMergeHeaders(vcfRods.values(), logger);
|
Set<VCFHeaderLine> headerLines = VCFUtils.smartMergeHeaders(vcfRods.values(), logger);
|
||||||
if ( SET_KEY != null )
|
if ( SET_KEY != null )
|
||||||
headerLines.add(new VCFInfoHeaderLine(SET_KEY, 1, VCFHeaderLineType.String, "Source VCF for the merged record in CombineVariants"));
|
headerLines.add(new VCFInfoHeaderLine(SET_KEY, 1, VCFHeaderLineType.String, "Source VCF for the merged record in CombineVariants"));
|
||||||
if ( !NO_VCF_HEADER_LINE ) {
|
|
||||||
headerLines.add(new VCFHeaderLine("CombineVariants", "\"" + CommandLineUtils.createApproximateCommandLineArgumentString(getToolkit(), this) + "\""));
|
|
||||||
}
|
|
||||||
vcfWriter.writeHeader(new VCFHeader(headerLines, samples));
|
vcfWriter.writeHeader(new VCFHeader(headerLines, samples));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ public class GATKExtensionsGenerator extends CommandLineProgram {
|
||||||
@Override
|
@Override
|
||||||
protected Collection<ArgumentTypeDescriptor> getArgumentTypeDescriptors() {
|
protected Collection<ArgumentTypeDescriptor> getArgumentTypeDescriptors() {
|
||||||
List<ArgumentTypeDescriptor> typeDescriptors = new ArrayList<ArgumentTypeDescriptor>();
|
List<ArgumentTypeDescriptor> typeDescriptors = new ArrayList<ArgumentTypeDescriptor>();
|
||||||
typeDescriptors.add(new VCFWriterArgumentTypeDescriptor(GATKEngine,System.out));
|
typeDescriptors.add(new VCFWriterArgumentTypeDescriptor(GATKEngine,System.out,Collections.<Object>emptyList()));
|
||||||
typeDescriptors.add(new SAMFileReaderArgumentTypeDescriptor(GATKEngine));
|
typeDescriptors.add(new SAMFileReaderArgumentTypeDescriptor(GATKEngine));
|
||||||
typeDescriptors.add(new SAMFileWriterArgumentTypeDescriptor(GATKEngine,System.out));
|
typeDescriptors.add(new SAMFileWriterArgumentTypeDescriptor(GATKEngine,System.out));
|
||||||
typeDescriptors.add(new OutputStreamArgumentTypeDescriptor(GATKEngine,System.out));
|
typeDescriptors.add(new OutputStreamArgumentTypeDescriptor(GATKEngine,System.out));
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import java.lang.reflect.Modifier;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
@ -146,4 +147,35 @@ public class JVMUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a single object in the list matching or type-compatible with the given type. Exceptions out if multiple objects match.
|
||||||
|
* @param type The desired type.
|
||||||
|
* @param <T> The selected type.
|
||||||
|
* @return A collection of the given arguments with the specified type.
|
||||||
|
*/
|
||||||
|
public static <T> T getObjectOfType(Collection<Object> objectsToFilter, Class<T> type) {
|
||||||
|
// TODO: Make JVM utils.
|
||||||
|
Collection<T> selectedObjects = getObjectsOfType(objectsToFilter,type);
|
||||||
|
if(selectedObjects.size() > 1)
|
||||||
|
throw new ReviewedStingException("User asked for a single instance of the type, multiple were present");
|
||||||
|
if(selectedObjects.size() == 0)
|
||||||
|
throw new ReviewedStingException("User asked for a single instance of the type, but none were present");
|
||||||
|
return selectedObjects.iterator().next();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a collection of all objects in the list matching or type-compatible with the given type.
|
||||||
|
* @param type The desired type.
|
||||||
|
* @param <T> Again, the desired type. Used so that clients can ignore type safety.
|
||||||
|
* @return A collection of the given arguments with the specified type.
|
||||||
|
*/
|
||||||
|
public static <T> Collection<T> getObjectsOfType(Collection<Object> objectsToFilter, Class<T> type) {
|
||||||
|
Collection<T> selectedObjects = new ArrayList<T>();
|
||||||
|
for(Object object: objectsToFilter) {
|
||||||
|
if(type.isAssignableFrom(object.getClass()))
|
||||||
|
selectedObjects.add((T)object);
|
||||||
|
}
|
||||||
|
return selectedObjects;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,6 @@ public class PackageUtils {
|
||||||
* Private constructor. No instantiating this class!
|
* Private constructor. No instantiating this class!
|
||||||
*/
|
*/
|
||||||
private PackageUtils() {}
|
private PackageUtils() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the classes that implement the specified interface.
|
* Return the classes that implement the specified interface.
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,8 @@ public class VariantsToVCFIntegrationTest extends WalkerTest {
|
||||||
" -T VariantsToVCF" +
|
" -T VariantsToVCF" +
|
||||||
" -L 1:10,000,000-11,000,000" +
|
" -L 1:10,000,000-11,000,000" +
|
||||||
" -sample NA123AB" +
|
" -sample NA123AB" +
|
||||||
" -o %s",
|
" -o %s" +
|
||||||
|
" -NO_HEADER",
|
||||||
1, // just one output file
|
1, // just one output file
|
||||||
md5);
|
md5);
|
||||||
executeTest("testVariantsToVCFUsingGeliInput #1", spec).getFirst();
|
executeTest("testVariantsToVCFUsingGeliInput #1", spec).getFirst();
|
||||||
|
|
@ -45,7 +46,8 @@ public class VariantsToVCFIntegrationTest extends WalkerTest {
|
||||||
" -T VariantsToVCF" +
|
" -T VariantsToVCF" +
|
||||||
" -L 1:10,000,000-11,000,000" +
|
" -L 1:10,000,000-11,000,000" +
|
||||||
" -sample NA123AB" +
|
" -sample NA123AB" +
|
||||||
" -o %s",
|
" -o %s" +
|
||||||
|
" -NO_HEADER",
|
||||||
1, // just one output file
|
1, // just one output file
|
||||||
md5);
|
md5);
|
||||||
executeTest("testVariantsToVCFUsingGeliInput #2", spec).getFirst();
|
executeTest("testVariantsToVCFUsingGeliInput #2", spec).getFirst();
|
||||||
|
|
@ -61,7 +63,8 @@ public class VariantsToVCFIntegrationTest extends WalkerTest {
|
||||||
" -B:variant,HapMap " + validationDataLocation + "rawHapMap.yri.chr1.txt" +
|
" -B:variant,HapMap " + validationDataLocation + "rawHapMap.yri.chr1.txt" +
|
||||||
" -T VariantsToVCF" +
|
" -T VariantsToVCF" +
|
||||||
" -L 1:1-1,000,000" +
|
" -L 1:1-1,000,000" +
|
||||||
" -o %s",
|
" -o %s" +
|
||||||
|
" -NO_HEADER",
|
||||||
1, // just one output file
|
1, // just one output file
|
||||||
md5);
|
md5);
|
||||||
executeTest("testVariantsToVCFUsingHapMapInput", spec).getFirst();
|
executeTest("testVariantsToVCFUsingHapMapInput", spec).getFirst();
|
||||||
|
|
@ -76,7 +79,8 @@ public class VariantsToVCFIntegrationTest extends WalkerTest {
|
||||||
"-R " + b36KGReference +
|
"-R " + b36KGReference +
|
||||||
" -B:variant,VCF " + validationDataLocation + "complexExample.vcf4" +
|
" -B:variant,VCF " + validationDataLocation + "complexExample.vcf4" +
|
||||||
" -T VariantsToVCF" +
|
" -T VariantsToVCF" +
|
||||||
" -o %s",
|
" -o %s" +
|
||||||
|
" -NO_HEADER",
|
||||||
1, // just one output file
|
1, // just one output file
|
||||||
md5);
|
md5);
|
||||||
executeTest("testVariantsToVCFUsingVCFInput", spec).getFirst();
|
executeTest("testVariantsToVCFUsingVCFInput", spec).getFirst();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ import java.util.Arrays;
|
||||||
import org.broadinstitute.sting.WalkerTest;
|
import org.broadinstitute.sting.WalkerTest;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class GenomicAnnotatorIntegrationTest extends WalkerTest {
|
public class
|
||||||
|
GenomicAnnotatorIntegrationTest extends WalkerTest {
|
||||||
@Test
|
@Test
|
||||||
public void testGenomicAnnotatorOnDbSNP() {
|
public void testGenomicAnnotatorOnDbSNP() {
|
||||||
|
|
||||||
|
|
@ -34,7 +35,8 @@ public class GenomicAnnotatorIntegrationTest extends WalkerTest {
|
||||||
" -m" + //generate many records from one input record if necessary
|
" -m" + //generate many records from one input record if necessary
|
||||||
" -o %s" +
|
" -o %s" +
|
||||||
" -BTI variant" +
|
" -BTI variant" +
|
||||||
" -s dbsnp.name,dbsnp.refUCSC,dbsnp.strand,dbsnp.observed,dbsnp.avHet",
|
" -s dbsnp.name,dbsnp.refUCSC,dbsnp.strand,dbsnp.observed,dbsnp.avHet" +
|
||||||
|
" -NO_HEADER",
|
||||||
1,
|
1,
|
||||||
Arrays.asList(md5WithDashSArg));
|
Arrays.asList(md5WithDashSArg));
|
||||||
executeTest("test with dbSNP and -s arg", specWithSArg);
|
executeTest("test with dbSNP and -s arg", specWithSArg);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ import java.util.Map;
|
||||||
// Note that this class also serves as an integration test for the VariantAnnotator! //
|
// Note that this class also serves as an integration test for the VariantAnnotator! //
|
||||||
// ********************************************************************************** //
|
// ********************************************************************************** //
|
||||||
|
|
||||||
public class UnifiedGenotyperIntegrationTest extends WalkerTest {
|
public class
|
||||||
|
UnifiedGenotyperIntegrationTest extends WalkerTest {
|
||||||
|
|
||||||
private final static String baseCommand = "-T UnifiedGenotyper -R " + b36KGReference + " -NO_HEADER";
|
private final static String baseCommand = "-T UnifiedGenotyper -R " + b36KGReference + " -NO_HEADER";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ public class LiftoverVariantsIntegrationTest extends WalkerTest {
|
||||||
@Test
|
@Test
|
||||||
public void testb36Tohg19() {
|
public void testb36Tohg19() {
|
||||||
WalkerTestSpec spec = new WalkerTestSpec(
|
WalkerTestSpec spec = new WalkerTestSpec(
|
||||||
"-T LiftoverVariants -o %s -R " + b36KGReference + " -B:variant,vcf " + validationDataLocation + "yri.trio.gatk_glftrio.intersection.annotated.filtered.chr1.500.noheader.vcf -chain " + validationDataLocation + "b36ToHg19.broad.over.chain -dict /seq/references/Homo_sapiens_assembly19/v0/Homo_sapiens_assembly19.dict",
|
"-T LiftoverVariants -o %s -R " + b36KGReference + " -B:variant,vcf " + validationDataLocation + "yri.trio.gatk_glftrio.intersection.annotated.filtered.chr1.500.noheader.vcf -chain " + validationDataLocation + "b36ToHg19.broad.over.chain -dict /seq/references/Homo_sapiens_assembly19/v0/Homo_sapiens_assembly19.dict -NO_HEADER",
|
||||||
1,
|
1,
|
||||||
Arrays.asList("1637877892a019061e74eb3d9a9d100f"));
|
Arrays.asList("1637877892a019061e74eb3d9a9d100f"));
|
||||||
executeTest("test b36 to hg19", spec);
|
executeTest("test b36 to hg19", spec);
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ public class SelectVariantsIntegrationTest extends WalkerTest {
|
||||||
String samplesFile = validationDataLocation + "SelectVariants.samples.txt";
|
String samplesFile = validationDataLocation + "SelectVariants.samples.txt";
|
||||||
|
|
||||||
WalkerTestSpec spec = new WalkerTestSpec(
|
WalkerTestSpec spec = new WalkerTestSpec(
|
||||||
baseTestString(" -sn A -sn '[CDH]' -sn " + samplesFile + " -env -ef -select 'AF < 0.2' -B:variant,VCF " + testfile),
|
baseTestString(" -sn A -sn '[CDH]' -sn " + samplesFile + " -env -ef -select 'AF < 0.2' -B:variant,VCF " + testfile + " -NO_HEADER"),
|
||||||
1,
|
1,
|
||||||
Arrays.asList("3a15628b5980031c629c0c33e7e60b40")
|
Arrays.asList("3a15628b5980031c629c0c33e7e60b40")
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue