Temporary fix for Eric's problems with SOLiD reads: make sure the command-line argument system takes the --validation-strictness command-line argument into account when creating SAMFileReaders.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1183 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
hanna 2009-07-07 15:18:05 +00:00
parent f5b00c20d0
commit 5d7393d7cb
5 changed files with 89 additions and 13 deletions

View File

@ -4,16 +4,15 @@ import org.broadinstitute.sting.gatk.walkers.Walker;
import org.broadinstitute.sting.gatk.traversals.TraversalEngine;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.xReadLines;
import org.broadinstitute.sting.utils.cmdLine.Argument;
import org.broadinstitute.sting.utils.cmdLine.ArgumentCollection;
import org.broadinstitute.sting.utils.cmdLine.CommandLineProgram;
import org.broadinstitute.sting.utils.cmdLine.ArgumentException;
import org.broadinstitute.sting.utils.cmdLine.*;
import java.io.FileNotFoundException;
import java.io.File;
import java.util.List;
import java.util.ArrayList;
import net.sf.samtools.SAMFileReader;
/**
*
* User: aaron
@ -148,6 +147,24 @@ public class CommandLineGATK extends CommandLineProgram {
this.argCollection = argCollection;
}
/**
* Get a custom factory for instantiating specialty GATK arguments.
* @return An instance of the command-line argument of the specified type.
*/
@Override
protected ArgumentFactory getCustomArgumentFactory() {
return new ArgumentFactory() {
public Object createArgument( Class type, String repr ) {
if (type == SAMFileReader.class) {
SAMFileReader samFileReader = new SAMFileReader(new File(repr),true);
samFileReader.setValidationStringency(GenomeAnalysisEngine.getValidationStringency(argCollection));
return samFileReader;
}
return null;
}
};
}
/**
* Preprocess the arguments before submitting them to the GATK engine.

View File

@ -125,7 +125,7 @@ public class GenomeAnalysisEngine {
}
// Determine the validation stringency. Default to ValidationStringency.STRICT.
ValidationStringency strictness = getValidationStringency();
ValidationStringency strictness = getValidationStringency(argCollection);
logger.info("Strictness is " + strictness);
@ -219,7 +219,7 @@ public class GenomeAnalysisEngine {
*/
private Reads extractSourceInfoFromArguments( GATKArgumentCollection argCollection ) {
return new Reads( argCollection.samFiles,
getValidationStringency(),
getValidationStringency(argCollection),
argCollection.downsampleFraction,
argCollection.downsampleCoverage,
!argCollection.unsafe,
@ -264,10 +264,10 @@ public class GenomeAnalysisEngine {
/**
* Default to ValidationStringency.STRICT.
*
* TODO: Store ValidationStringency as pre-parsed enum in GATKArgumentCollection.
* @return the validation stringency
*/
private ValidationStringency getValidationStringency() {
public static ValidationStringency getValidationStringency( GATKArgumentCollection argCollection ) {
ValidationStringency strictness = ValidationStringency.SILENT;
try {
strictness = Enum.valueOf(ValidationStringency.class, argCollection.strictnessLevel.toUpperCase().trim());

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2009 The Broad Institute
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
package org.broadinstitute.sting.utils.cmdLine;
/**
* Provides a service whereby the application can provide a mechanism
* for creating specialty arguments.
* @version 0.1
*/
public abstract class ArgumentFactory {
/**
* Create an instance of a specified type of argument.
* @param type The type of the argument to create.
* @param repr A String representation of the argument.
* @return
*/
public abstract Object createArgument(Class type, String repr);
}

View File

@ -142,6 +142,14 @@ public abstract class CommandLineProgram {
*/
protected abstract int execute();
/**
* Retrieves a factory for custom creation of command-line arguments, specified by the
* subclass.
* @return
*/
protected ArgumentFactory getCustomArgumentFactory() {
return null;
}
/**
* This function is called to start processing the command line, and kick
@ -160,7 +168,7 @@ public abstract class CommandLineProgram {
PatternLayout layout = new PatternLayout();
// setup the parser
ParsingEngine parser = clp.parser = new ParsingEngine();
ParsingEngine parser = clp.parser = new ParsingEngine( clp.getCustomArgumentFactory() );
parser.addArgumentSource( clp.getClass() );
// process the args

View File

@ -53,6 +53,13 @@ public class ParsingEngine {
*/
ArgumentMatches argumentMatches = null;
/**
* Stores a custom argument factory for building out arguments of which only
* subclasses of CommandLineProgram should be aware.
*/
ArgumentFactory customArgumentFactory = null;
/**
* Techniques for parsing and for argument lookup.
*/
@ -63,7 +70,8 @@ public class ParsingEngine {
*/
protected static Logger logger = Logger.getLogger(ParsingEngine.class);
public ParsingEngine() {
public ParsingEngine( ArgumentFactory customArgumentFactory ) {
this.customArgumentFactory = customArgumentFactory;
parsingMethods.add( ParsingMethod.FullNameParsingMethod );
parsingMethods.add( ParsingMethod.ShortNameParsingMethod );
}
@ -423,10 +431,13 @@ public class ParsingEngine {
* @return parsed form of String.
*/
private Object constructSingleElement(Field f, Class type, String str) {
// lets go through the types we support
if (type == SAMFileReader.class) {
return new SAMFileReader(new File(str),true);
if( customArgumentFactory != null ) {
Object instance = customArgumentFactory.createArgument(type, str);
if( instance != null )
return instance;
}
// lets go through the types we support
if (type == Boolean.TYPE) {
boolean b = false;
if (str.toLowerCase().equals("true")) {