diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java index 330d29c79..301baaba3 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java @@ -36,10 +36,10 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.*; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.*; import org.broadinstitute.sting.utils.help.HelpConstants; +import org.broadinstitute.sting.utils.help.HelpUtils; import org.broadinstitute.sting.utils.variant.GATKVCFUtils; import org.broadinstitute.sting.utils.BaseUtils; import org.broadinstitute.sting.utils.SampleUtils; -import org.broadinstitute.sting.utils.classloader.PluginManager; import org.broadinstitute.variant.vcf.*; import org.broadinstitute.sting.utils.help.DocumentedGATKFeature; import org.broadinstitute.variant.variantcontext.VariantContext; @@ -47,7 +47,6 @@ import org.broadinstitute.variant.variantcontext.writer.VariantContextWriter; import java.util.*; - /** * Annotates variant calls with context information. * @@ -165,7 +164,7 @@ public class VariantAnnotator extends RodWalker implements Ann protected Boolean USE_ALL_ANNOTATIONS = false; /** - * Note that the --list argument requires a fully resolved and correct command-line to work. + * Note that the --list argument requires a fully resolved and correct command-line to work. As a simpler alternative, you can use ListAnnotations (see Help Utilities). */ @Argument(fullName="list", shortName="ls", doc="List the available annotations and exit", required=false) protected Boolean LIST = false; @@ -177,7 +176,7 @@ public class VariantAnnotator extends RodWalker implements Ann protected Boolean ALWAYS_APPEND_DBSNP_ID = false; public boolean alwaysAppendDbsnpId() { return ALWAYS_APPEND_DBSNP_ID; } - @Argument(fullName="MendelViolationGenotypeQualityThreshold",shortName="mvq",required=false,doc="The genotype quality treshold in order to annotate mendelian violation ratio") + @Argument(fullName="MendelViolationGenotypeQualityThreshold",shortName="mvq",required=false,doc="The genotype quality threshold in order to annotate mendelian violation ratio") public double minGenotypeQualityP = 0.0; @Argument(fullName="requireStrictAlleleMatch", shortName="strict", doc="If provided only comp tracks that exactly match both reference and alternate alleles will be counted as concordant", required=false) @@ -185,33 +184,14 @@ public class VariantAnnotator extends RodWalker implements Ann private VariantAnnotatorEngine engine; - - private void listAnnotationsAndExit() { - System.out.println("\nStandard annotations in the list below are marked with a '*'."); - List> infoAnnotationClasses = new PluginManager(InfoFieldAnnotation.class).getPlugins(); - System.out.println("\nAvailable annotations for the VCF INFO field:"); - for (int i = 0; i < infoAnnotationClasses.size(); i++) - System.out.println("\t" + (StandardAnnotation.class.isAssignableFrom(infoAnnotationClasses.get(i)) ? "*" : "") + infoAnnotationClasses.get(i).getSimpleName()); - System.out.println(); - List> genotypeAnnotationClasses = new PluginManager(GenotypeAnnotation.class).getPlugins(); - System.out.println("\nAvailable annotations for the VCF FORMAT field:"); - for (int i = 0; i < genotypeAnnotationClasses.size(); i++) - System.out.println("\t" + (StandardAnnotation.class.isAssignableFrom(genotypeAnnotationClasses.get(i)) ? "*" : "") + genotypeAnnotationClasses.get(i).getSimpleName()); - System.out.println(); - System.out.println("\nAvailable classes/groups of annotations:"); - for ( Class c : new PluginManager(AnnotationType.class).getInterfaces() ) - System.out.println("\t" + c.getSimpleName()); - System.out.println(); - System.exit(0); - } - /** * Prepare the output file and the list of available features. */ public void initialize() { if ( LIST ) - listAnnotationsAndExit(); + HelpUtils.listAnnotations(); + System.exit(0); // get the list of all sample names from the variant VCF input rod, if applicable List rodName = Arrays.asList(variantCollection.variants.getName()); diff --git a/public/java/src/org/broadinstitute/sting/tools/CatVariants.java b/public/java/src/org/broadinstitute/sting/tools/CatVariants.java index e1dd2c255..ad77b2548 100644 --- a/public/java/src/org/broadinstitute/sting/tools/CatVariants.java +++ b/public/java/src/org/broadinstitute/sting/tools/CatVariants.java @@ -35,7 +35,6 @@ import org.broadinstitute.sting.commandline.Argument; import org.broadinstitute.sting.commandline.Input; import org.broadinstitute.sting.commandline.Output; import org.broadinstitute.sting.commandline.CommandLineProgram; -import org.broadinstitute.sting.gatk.CommandLineGATK; import org.broadinstitute.sting.utils.help.DocumentedGATKFeature; import org.broadinstitute.sting.utils.help.HelpConstants; import org.broadinstitute.variant.bcf2.BCF2Codec; @@ -54,7 +53,7 @@ import java.util.*; /** * - * Concatenates VCF files of non-overlapped genome intervals, all with the same set of samples. + * Concatenates VCF files of non-overlapped genome intervals, all with the same set of samples * *

* The main purpose of this tool is to speed up the gather function when using scatter-gather parallelization. @@ -80,10 +79,14 @@ import java.util.*; * A combined VCF. The output file should be 'name.vcf' or 'name.VCF'. * <\p> * + *

Important note

+ *

This is a command-line utility that bypasses the GATK engine. As a result, the command-line you must use to + * invoke it is a little different from other GATK tools (see example below), and it does not accept any of the + * classic "CommandLineGATK" arguments.

* - *

Examples

+ *

Example

*
- * java -cp dist/GenomeAnalysisTK.jar org.broadinstitute.sting.tools.CatVariants \
+ * java -cp GenomeAnalysisTK.jar org.broadinstitute.sting.tools.CatVariants \
  *    -R ref.fasta \
  *    -V input1.vcf \
  *    -V input2.vcf \
@@ -95,7 +98,7 @@ import java.util.*;
  * @since Jan 2012
  */
 
-@DocumentedGATKFeature( groupName = HelpConstants.DOCS_CAT_VARMANIP, extraDocs = {CommandLineGATK.class} )
+@DocumentedGATKFeature( groupName = HelpConstants.DOCS_CAT_VARMANIP )
 public class CatVariants extends CommandLineProgram {
     // setup the logging system, used by some codecs
     private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getRootLogger();
@@ -124,7 +127,7 @@ public class CatVariants extends CommandLineProgram {
      * print usage information
      */
     private static void printUsage() {
-        System.err.println("Usage: java -cp dist/GenomeAnalysisTK.jar org.broadinstitute.sting.tools.AppendVariants    [sorted (optional)]");
+        System.err.println("Usage: java -cp dist/GenomeAnalysisTK.jar org.broadinstitute.sting.tools.CatVariants    [sorted (optional)]");
         System.err.println("    The input files can be of type: VCF (ends in .vcf or .VCF)");
         System.err.println("                                    BCF2 (ends in .bcf or .BCF)");
         System.err.println("    Output file must be vcf or bcf file (.vcf or .bcf)");
diff --git a/public/java/src/org/broadinstitute/sting/tools/ListAnnotations.java b/public/java/src/org/broadinstitute/sting/tools/ListAnnotations.java
new file mode 100644
index 000000000..fabcf828a
--- /dev/null
+++ b/public/java/src/org/broadinstitute/sting/tools/ListAnnotations.java
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2012 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.tools;
+
+import org.broadinstitute.sting.commandline.CommandLineProgram;
+import org.broadinstitute.sting.utils.exceptions.UserException;
+import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
+import org.broadinstitute.sting.utils.help.HelpConstants;
+import org.broadinstitute.sting.utils.help.HelpUtils;
+
+/**
+ * Utility program to print a list of available annotations
+ *
+ * 

This is a very simple utility tool that retrieves available annotations for use with tools such as + * UnifiedGenotyper, HaplotypeCaller and VariantAnnotator.

+ * + *

Important note

+ *

This is a command-line utility that bypasses the GATK engine. As a result, the command-line you must use to + * invoke it is a little different from other GATK tools (see usage below), and it does not accept any of the + * classic "CommandLineGATK" arguments.

+ * + *

Usage

+ *
java -cp GenomeAnalysisTK.jar org.broadinstitute.sting.tools.ListAnnotations
+ * + * @author vdauwera + * @since 3/14/13 + */ +@DocumentedGATKFeature( groupName = HelpConstants.DOCS_CAT_HELPUTILS ) +public class ListAnnotations extends CommandLineProgram { + + /* + * Print usage information + * + * TODO: would be more convenient if we could just call the program by name instead of the full classpath + */ + private static void printUsage() { + System.err.println("Usage: java -cp dist/GenomeAnalysisTK.jar org.broadinstitute.sting.tools.ListAnnotations"); + System.err.println(" Prints a list of available annotations and exits."); + } + + // TODO: override CommandLineProgram bit that offers version, logging etc arguments. We don't need that stuff here and it makes the doc confusing. + + @Override + protected int execute() throws Exception { + + HelpUtils.listAnnotations(); + return 0; + } + + public static void main(String[] args){ + try { + ListAnnotations instance = new ListAnnotations(); + start(instance, args); + System.exit(CommandLineProgram.result); + } catch ( UserException e ) { + printUsage(); + exitSystemWithUserError(e); + } catch ( Exception e ) { + exitSystemWithError(e); + } + } +} diff --git a/public/java/src/org/broadinstitute/sting/utils/help/HelpConstants.java b/public/java/src/org/broadinstitute/sting/utils/help/HelpConstants.java index f99ff7538..2ed35d848 100644 --- a/public/java/src/org/broadinstitute/sting/utils/help/HelpConstants.java +++ b/public/java/src/org/broadinstitute/sting/utils/help/HelpConstants.java @@ -56,6 +56,7 @@ public class HelpConstants { public final static String DOCS_CAT_VARDISC = "Variant Discovery Tools"; public final static String DOCS_CAT_VARMANIP = "Variant Evaluation and Manipulation Tools"; public final static String DOCS_CAT_TEST = "Testing Tools"; + public final static String DOCS_CAT_HELPUTILS = "Help Utilities"; public static String forumPost(String post) { return GATK_FORUM_URL + post; diff --git a/public/java/src/org/broadinstitute/sting/utils/help/HelpUtils.java b/public/java/src/org/broadinstitute/sting/utils/help/HelpUtils.java index 81606d2f3..9a23fd022 100644 --- a/public/java/src/org/broadinstitute/sting/utils/help/HelpUtils.java +++ b/public/java/src/org/broadinstitute/sting/utils/help/HelpUtils.java @@ -28,9 +28,15 @@ package org.broadinstitute.sting.utils.help; import com.sun.javadoc.FieldDoc; import com.sun.javadoc.PackageDoc; import com.sun.javadoc.ProgramElementDoc; +import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.AnnotationType; +import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.GenotypeAnnotation; +import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; +import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation; import org.broadinstitute.sting.utils.classloader.JVMUtils; +import org.broadinstitute.sting.utils.classloader.PluginManager; import java.lang.reflect.Field; +import java.util.List; public class HelpUtils { @@ -70,4 +76,27 @@ public class HelpUtils { String.format("%s", doc.name()); } + /** + * Simple method to print a list of available annotations. + */ + public static void listAnnotations() { + System.out.println("\nThis is a list of available Variant Annotations for use with tools such as UnifiedGenotyper, HaplotypeCaller and VariantAnnotator. Please see the Technical Documentation for more details about these annotations:"); + System.out.println("http://www.broadinstitute.org/gatk/gatkdocs/"); + System.out.println("\nStandard annotations in the list below are marked with a '*'."); + List> infoAnnotationClasses = new PluginManager(InfoFieldAnnotation.class).getPlugins(); + System.out.println("\nAvailable annotations for the VCF INFO field:"); + for (int i = 0; i < infoAnnotationClasses.size(); i++) + System.out.println("\t" + (StandardAnnotation.class.isAssignableFrom(infoAnnotationClasses.get(i)) ? "*" : "") + infoAnnotationClasses.get(i).getSimpleName()); + System.out.println(); + List> genotypeAnnotationClasses = new PluginManager(GenotypeAnnotation.class).getPlugins(); + System.out.println("\nAvailable annotations for the VCF FORMAT field:"); + for (int i = 0; i < genotypeAnnotationClasses.size(); i++) + System.out.println("\t" + (StandardAnnotation.class.isAssignableFrom(genotypeAnnotationClasses.get(i)) ? "*" : "") + genotypeAnnotationClasses.get(i).getSimpleName()); + System.out.println(); + System.out.println("\nAvailable classes/groups of annotations:"); + for ( Class c : new PluginManager(AnnotationType.class).getInterfaces() ) + System.out.println("\t" + c.getSimpleName()); + System.out.println(); + } + } \ No newline at end of file