Added code to correct the violation of the parsing interface. Now the analysis type resides in the command line arg, but is stored into the argument collection before it's passed to the genomeAnalysisEngine.

Also fixed a bug where we'd exception-out if we didn't provide a interval region.


git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@669 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
aaron 2009-05-12 15:33:55 +00:00
parent c4d89997ca
commit 9f942fdfa0
3 changed files with 26 additions and 17 deletions

View File

@ -2,9 +2,9 @@ package org.broadinstitute.sting.gatk;
import org.broadinstitute.sting.gatk.walkers.Walker;
import org.broadinstitute.sting.utils.StingException;
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.gatk.GATKArgumentCollection;
/**
*
@ -36,6 +36,9 @@ import org.broadinstitute.sting.gatk.GATKArgumentCollection;
*/
public class CommandLineGATK extends CommandLineProgram {
@Argument(fullName = "analysis_type", shortName = "T", doc = "Type of analysis to run")
public String analysisName = null;
@ArgumentCollection // our argument collection, the collection of command line args we accept
public GATKArgumentCollection argCollection = new GATKArgumentCollection();
@ -68,14 +71,16 @@ public class CommandLineGATK extends CommandLineProgram {
protected int execute() {
Walker<?, ?> mWalker = null;
try {
mWalker = walkerManager.createWalkerByName(argCollection.analysisName);
mWalker = walkerManager.createWalkerByName(analysisName);
} catch (InstantiationException ex) {
throw new RuntimeException("Unable to instantiate walker.", ex);
}
catch (IllegalAccessException ex) {
throw new RuntimeException("Unable to access walker", ex);
}
loadArgumentsIntoObject(argCollection);
loadArgumentsIntoObject(mWalker);
this.argCollection.analysisName = this.analysisName;
try {
GATKEngine = new GenomeAnalysisEngine(argCollection, mWalker);
} catch (StingException exp) {
@ -103,16 +108,20 @@ public class CommandLineGATK extends CommandLineProgram {
*/
@Override
protected Class[] getArgumentSources() {
loadArgumentsIntoObject(this.argCollection);
if (argCollection.analysisName == null)
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
if (analysisName == null)
throw new IllegalArgumentException("Must provide analysis name");
walkerManager = new WalkerManager(pluginPathName);
if (!walkerManager.doesWalkerExist(argCollection.analysisName))
if (!walkerManager.doesWalkerExist(analysisName))
throw new IllegalArgumentException("Invalid analysis name");
return new Class[]{walkerManager.getWalkerClassByName(argCollection.analysisName)};
return new Class[]{walkerManager.getWalkerClassByName(analysisName)};
}
@Override

View File

@ -68,7 +68,6 @@ public class GATKArgumentCollection {
public File referenceFile = null;
@Element(required=false)
@Argument(fullName = "analysis_type", shortName = "T", doc = "Type of analysis to run")
public String analysisName = null;
// parameters and their defaults

View File

@ -184,8 +184,7 @@ public class GenomeAnalysisEngine {
microScheduler = MicroScheduler.create(my_walker, argCollection.samFiles, argCollection.referenceFile, rods, argCollection.numberOfThreads);
engine = microScheduler.getTraversalEngine();
}
else if (my_walker instanceof ReadWalker)
{
else if (my_walker instanceof ReadWalker) {
if (argCollection.referenceFile == null)
Utils.scareUser(String.format("Locus-based traversals require a reference file but none was given"));
microScheduler = MicroScheduler.create(my_walker, argCollection.samFiles, argCollection.referenceFile, rods, argCollection.numberOfThreads);
@ -236,15 +235,17 @@ public class GenomeAnalysisEngine {
* @return a list of genomeLoc representing the interval file
*/
private List<GenomeLoc> setupIntervalRegion() {
List<GenomeLoc> locs;
if( new File(argCollection.intervals).exists() ) {
logger.info("Intervals argument specifies a file. Loading intervals from file.");
return GenomeLoc.IntervalFileToList(argCollection.intervals);
}
else {
logger.info("Intervals argument does not specify a file. Trying to parse it as a simple string.");
return GenomeLoc.parseGenomeLocs(argCollection.intervals);
List<GenomeLoc> locs = null;
if (argCollection.intervals != null) {
if (new File(argCollection.intervals).exists()) {
logger.info("Intervals argument specifies a file. Loading intervals from file.");
locs = GenomeLoc.IntervalFileToList(argCollection.intervals);
} else {
logger.info("Intervals argument does not specify a file. Trying to parse it as a simple string.");
locs = GenomeLoc.parseGenomeLocs(argCollection.intervals);
}
}
return locs;
}
/**