From dde092fb6108f2f441e12baea66d1ab2e43a3443 Mon Sep 17 00:00:00 2001 From: ebanks Date: Tue, 13 Apr 2010 22:15:58 +0000 Subject: [PATCH] Added the ability in VE2 to select which eval modules to run, so that you aren't forced to use all of them. You can use --list to list all of the possible modules to run. Heads up everyone: by default, *no* modules are run. Please add "-all" to your scripts to maintain the previous behavior. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3161 348d0f76-0448-11de-a6fe-93d51630548a --- .../varianteval2/VariantEval2Walker.java | 50 +++++++++++++++++-- .../VariantEval2IntegrationTest.java | 2 +- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/varianteval2/VariantEval2Walker.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/varianteval2/VariantEval2Walker.java index 07a147b36..483007253 100755 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/varianteval2/VariantEval2Walker.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/varianteval2/VariantEval2Walker.java @@ -101,6 +101,18 @@ public class VariantEval2Walker extends RodWalker { protected String[] SAMPLES = {}; private List SAMPLES_LIST = null; + // + // Arguments for choosing which modules to run + // + @Argument(fullName="evalModule", shortName="E", doc="One or more specific eval modules to apply to the eval track(s)", required=false) + protected String[] modulesToUse = {}; + + @Argument(fullName="useAllModules", shortName="all", doc="Use all possible eval modules", required=false) + protected Boolean USE_ALL_MODULES = false; + + @Argument(fullName="list", shortName="ls", doc="List the available eval modules and exit") + protected Boolean LIST = false; + // // Arguments for Mendelian Violation calculations // @@ -117,7 +129,7 @@ public class VariantEval2Walker extends RodWalker { @Argument(shortName = "Q", fullName="minPhredConfidenceScore", doc="Minimum confidence score to consider an evaluation SNP a variant", required=false) public double minQualScore = NO_MIN_QUAL_SCORE; - /** Right now we will only be looking at SNPS */ + // Right now we will only be looking at SNPS EnumSet ALLOW_VARIANT_CONTEXT_TYPES = EnumSet.of(VariantContext.Type.SNP, VariantContext.Type.NO_VARIATION); @Argument(shortName="rsID", fullName="rsID", doc="If provided, list of rsID and build number for capping known snps by their build date", required=false) @@ -214,9 +226,13 @@ public class VariantEval2Walker extends RodWalker { // -------------------------------------------------------------------------------------------------------------- public void initialize() { + if ( LIST ) + listModulesAndExit(); + SAMPLES_LIST = Arrays.asList(SAMPLES); - determineAllEvalations(); + determineEvalations(); + List selectExps = VariantContextUtils.initializeMatchExps(SELECT_NAMES, SELECT_EXPS); for ( ReferenceOrderedDataSource d : this.getToolkit().getRodDataSources() ) { @@ -246,6 +262,15 @@ public class VariantEval2Walker extends RodWalker { } } + private void listModulesAndExit() { + List> veClasses = PackageUtils.getClassesImplementingInterface(VariantEvaluator.class); + out.println("\nAvailable eval modules:"); + for (int i = 0; i < veClasses.size(); i++) + out.println("\t" + veClasses.get(i).getSimpleName()); + out.println(); + System.exit(0); + } + private static Set getrsIDsToExclude(File rsIDFile, int maxRsIDBuild) { List toExclude = new LinkedList(); @@ -283,8 +308,25 @@ public class VariantEval2Walker extends RodWalker { return ex; } - private void determineAllEvalations() { - evaluationClasses = PackageUtils.getClassesImplementingInterface(VariantEvaluator.class); + private void determineEvalations() { + // create a map for all eval modules for easy lookup + HashMap> classMap = new HashMap>(); + for ( Class c : PackageUtils.getClassesImplementingInterface(VariantEvaluator.class) ) + classMap.put(c.getSimpleName(), c); + + if ( USE_ALL_MODULES ) { + evaluationClasses = new ArrayList>(classMap.values()); + } else { + // get the specific classes provided + evaluationClasses = new ArrayList>(modulesToUse.length); + for ( String module : modulesToUse ) { + Class moduleClass = classMap.get(module); + if ( moduleClass == null ) + throw new StingException("Class " + module + " is not found; please check that you have specified the class name correctly"); + evaluationClasses.add(moduleClass); + } + } + for ( VariantEvaluator e : instantiateEvalationsSet() ) { // for collecting purposes variantEvaluationNames.add(e.getName()); diff --git a/java/test/org/broadinstitute/sting/oneoffprojects/walkers/varianteval2/VariantEval2IntegrationTest.java b/java/test/org/broadinstitute/sting/oneoffprojects/walkers/varianteval2/VariantEval2IntegrationTest.java index f26db95c6..951e35fcd 100755 --- a/java/test/org/broadinstitute/sting/oneoffprojects/walkers/varianteval2/VariantEval2IntegrationTest.java +++ b/java/test/org/broadinstitute/sting/oneoffprojects/walkers/varianteval2/VariantEval2IntegrationTest.java @@ -9,7 +9,7 @@ import java.util.Map; public class VariantEval2IntegrationTest extends WalkerTest { private static String cmdRoot = "-T VariantEval2" + - " -R " + oneKGLocation + "reference/human_b36_both.fasta -reportType Grep"; + " -R " + oneKGLocation + "reference/human_b36_both.fasta -reportType Grep -all"; private static String root = cmdRoot + " -D " + GATKDataLocation + "dbsnp_129_b36.rod" +