diff --git a/java/src/org/broadinstitute/sting/gatk/CommandLineExecutable.java b/java/src/org/broadinstitute/sting/gatk/CommandLineExecutable.java index f8426ddbf..f885102e1 100644 --- a/java/src/org/broadinstitute/sting/gatk/CommandLineExecutable.java +++ b/java/src/org/broadinstitute/sting/gatk/CommandLineExecutable.java @@ -3,6 +3,7 @@ package org.broadinstitute.sting.gatk; import org.broadinstitute.sting.utils.cmdLine.CommandLineProgram; import org.broadinstitute.sting.utils.cmdLine.ArgumentFactory; import org.broadinstitute.sting.utils.cmdLine.ArgumentCollection; +import org.broadinstitute.sting.utils.cmdLine.Argument; import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.xReadLines; import org.broadinstitute.sting.gatk.walkers.Walker; @@ -42,17 +43,22 @@ import net.sf.samtools.SAMFileReader; /** * @author aaron - *

- * Generate a executable class for the SomaticCoverageWalker */ public abstract class CommandLineExecutable extends CommandLineProgram { - // our genome analysis engine - private GenomeAnalysisEngine GATKEngine = new GenomeAnalysisEngine(); + /** + * Get an instance of the GATK engine. + * @return The GATK engine that will power the requested traversal. + */ + protected abstract GenomeAnalysisEngine getGATKEngine(); // get the analysis name protected abstract String getAnalysisName(); + /** + * Gets the GATK argument bundle. + * @return A structure consisting of whatever arguments should be used to initialize the GATK engine. + */ protected abstract GATKArgumentCollection getArgumentCollection(); // override select arguments @@ -65,10 +71,11 @@ public abstract class CommandLineExecutable extends CommandLineProgram { * @return the return code to exit the program with */ protected int execute() { - Walker mWalker = GATKEngine.getWalkerByName(getAnalysisName()); - + GenomeAnalysisEngine GATKEngine = getGATKEngine(); GATKArgumentCollection arguments = getArgumentCollection(); + Walker mWalker = GATKEngine.getWalkerByName(getAnalysisName()); + // load the arguments into the walkers loadArgumentsIntoObject(arguments); loadArgumentsIntoObject(mWalker); @@ -101,7 +108,7 @@ public abstract class CommandLineExecutable extends CommandLineProgram { protected Class[] getArgumentSources() { // No walker info? No plugins. if (getAnalysisName() == null) return new Class[] {}; - return new Class[] { GATKEngine.getWalkerByName(getAnalysisName()).getClass() }; + return new Class[] { getGATKEngine().getWalkerByName(getAnalysisName()).getClass() }; } @Override diff --git a/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java b/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java index c04b52518..d53638a19 100755 --- a/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java +++ b/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java @@ -36,13 +36,18 @@ import net.sf.samtools.SAMFileReader; * the gatk engine should deal with any data related information. */ public class CommandLineGATK extends CommandLineExecutable { + // our genome analysis engine + private GenomeAnalysisEngine GATKEngine = null; @Argument(fullName = "analysis_type", shortName = "T", doc = "Type of analysis to run") - public String analysisName = null; + private String analysisName = null; + + @Argument(fullName = "plugin_path", doc = "Which path will the GATK search for plugin walkers.", required = false) + private String pluginPath = null; // our argument collection, the collection of command line args we accept @ArgumentCollection - protected GATKArgumentCollection argCollection = new GATKArgumentCollection(); + private GATKArgumentCollection argCollection = new GATKArgumentCollection(); /** * Get pleasing info about the GATK. @@ -59,6 +64,19 @@ public class CommandLineGATK extends CommandLineExecutable { return header; } + /** + * Lazy load the GATK engine. This current CANNOT happen until after the command-line arguments are populated. + * TODO: Make this chain of events more explicit. Perhaps an abstract initialize method after clp arguments are parsed? + * @return The GATK engine that will power the requested traversal. + */ + @Override + protected GenomeAnalysisEngine getGATKEngine() { + if( GATKEngine == null ) + GATKEngine = new GenomeAnalysisEngine( pluginPath ); + return GATKEngine; + } + + @Override protected String getAnalysisName() { return analysisName; diff --git a/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java b/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java index 5648a21b4..ca378bb94 100755 --- a/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java +++ b/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java @@ -63,9 +63,6 @@ public class GenomeAnalysisEngine { /** our walker manager */ private final WalkerManager walkerManager; - /** plugin path for the walker manager. */ - public final String pluginPathName = null; - /** * our constructor, where all the work is done *

@@ -73,7 +70,7 @@ public class GenomeAnalysisEngine { * new MicroScheduler class we'll be able to delete that function. * */ - public GenomeAnalysisEngine() { + public GenomeAnalysisEngine( String pluginPathName ) { // make sure our instance variable points to this analysis engine instance = this; walkerManager = new WalkerManager(pluginPathName); diff --git a/java/src/org/broadinstitute/sting/playground/somaticcoverage/SomaticCoverageTool.java b/java/src/org/broadinstitute/sting/playground/somaticcoverage/SomaticCoverageTool.java index c00be688d..2853ce766 100644 --- a/java/src/org/broadinstitute/sting/playground/somaticcoverage/SomaticCoverageTool.java +++ b/java/src/org/broadinstitute/sting/playground/somaticcoverage/SomaticCoverageTool.java @@ -2,6 +2,7 @@ package org.broadinstitute.sting.playground.somaticcoverage; import org.broadinstitute.sting.gatk.CommandLineExecutable; import org.broadinstitute.sting.gatk.GATKArgumentCollection; +import org.broadinstitute.sting.gatk.GenomeAnalysisEngine; import org.broadinstitute.sting.utils.cmdLine.Argument; import java.io.File; @@ -41,7 +42,9 @@ import java.util.ArrayList; * * a executable command line for the Somatic Coverage Walker. */ -public class SomaticCoverageTool extends CommandLineExecutable { +public class SomaticCoverageTool extends CommandLineExecutable { + // our genome analysis engine + private GenomeAnalysisEngine GATKEngine = null; // the two sam/bam files, one for cancer, one for normal @Argument(fullName = "bam_file", shortName = "I", doc = "The bam files, one for the tumor one for the normal", required = true) @@ -57,6 +60,14 @@ public class SomaticCoverageTool extends CommandLineExecutable { } } + @Override + protected GenomeAnalysisEngine getGATKEngine() { + if( GATKEngine == null ) + GATKEngine = new GenomeAnalysisEngine( null ); + return GATKEngine; + } + + /** * a required method, returns the analysis name. This is usually the walker * name with 'Walker' stripped off.