Permalink
Browse files

Moving HelpConstants out of HelpUtils so that we stop getting these P…

…rogramElementDoc errors when com.sun.javadoc cannot load on a user's system.
  • Loading branch information...
1 parent b8f1308 commit d738181c8e9862281009fcd333ad0f49b9cad955 @eitanbanks eitanbanks committed Jan 6, 2013
View
4 public/java/src/org/broadinstitute/sting/commandline/CommandLineProgram.java
@@ -32,8 +32,8 @@
import org.broadinstitute.sting.gatk.CommandLineGATK;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
import org.broadinstitute.sting.utils.help.ApplicationDetails;
+import org.broadinstitute.sting.utils.help.HelpConstants;
import org.broadinstitute.sting.utils.help.HelpFormatter;
-import org.broadinstitute.sting.utils.help.HelpUtils;
import java.io.IOException;
import java.util.*;
@@ -289,7 +289,7 @@ private void setupLoggerLevel(PatternLayout layout) {
*/
private static void printDocumentationReference() {
errorPrintf("Visit our website and forum for extensive documentation and answers to %n");
- errorPrintf("commonly asked questions " + HelpUtils.BASE_GATK_URL + "%n");
+ errorPrintf("commonly asked questions " + HelpConstants.BASE_GATK_URL + "%n");
}
View
7 public/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java
@@ -36,10 +36,7 @@
import org.broadinstitute.sting.gatk.walkers.Attribution;
import org.broadinstitute.sting.gatk.walkers.Walker;
import org.broadinstitute.sting.utils.exceptions.UserException;
-import org.broadinstitute.sting.utils.help.ApplicationDetails;
-import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
-import org.broadinstitute.sting.utils.help.GATKDocUtils;
-import org.broadinstitute.sting.utils.help.HelpUtils;
+import org.broadinstitute.sting.utils.help.*;
import org.broadinstitute.sting.utils.text.TextFormattingUtils;
import java.util.*;
@@ -161,7 +158,7 @@ private static void checkForMaskedUserErrors(final Throwable t) {
List<String> header = new ArrayList<String>();
header.add(String.format("The Genome Analysis Toolkit (GATK) v%s, Compiled %s",getVersionNumber(), getBuildTime()));
header.add("Copyright (c) 2010 The Broad Institute");
- header.add("For support and documentation go to " + HelpUtils.BASE_GATK_URL);
+ header.add("For support and documentation go to " + HelpConstants.BASE_GATK_URL);
return header;
}
View
4 public/java/src/org/broadinstitute/sting/gatk/filters/FilterManager.java
@@ -27,7 +27,7 @@
import org.broadinstitute.sting.utils.classloader.PluginManager;
import org.broadinstitute.sting.utils.help.GATKDocUtils;
-import org.broadinstitute.sting.utils.help.HelpUtils;
+import org.broadinstitute.sting.utils.help.HelpConstants;
import java.util.Collection;
import java.util.List;
@@ -71,7 +71,7 @@ protected String formatErrorMessage(String pluginCategory, String pluginName) {
return String.format("Read filter %s not found. Available read filters:%n%n%s%n%n%s",pluginName,
userFriendlyListofReadFilters(availableFilters),
- "Please consult the GATK Documentation (" + HelpUtils.GATK_DOCS_URL + ") for more information.");
+ "Please consult the GATK Documentation (" + HelpConstants.GATK_DOCS_URL + ") for more information.");
}
private String userFriendlyListofReadFilters(List<Class<? extends ReadFilter>> filters) {
View
4 ...va/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantDataManager.java
@@ -32,7 +32,7 @@
import org.broadinstitute.sting.utils.MathUtils;
import org.broadinstitute.sting.utils.codecs.vcf.VCFConstants;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
-import org.broadinstitute.sting.utils.help.HelpUtils;
+import org.broadinstitute.sting.utils.help.HelpConstants;
import org.broadinstitute.sting.utils.variantcontext.writer.VariantContextWriter;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.utils.exceptions.UserException;
@@ -81,7 +81,7 @@ public void normalizeData() {
final double theSTD = standardDeviation(theMean, iii);
logger.info( annotationKeys.get(iii) + String.format(": \t mean = %.2f\t standard deviation = %.2f", theMean, theSTD) );
if( Double.isNaN(theMean) ) {
- throw new UserException.BadInput("Values for " + annotationKeys.get(iii) + " annotation not detected for ANY training variant in the input callset. VariantAnnotator may be used to add these annotations. See " + HelpUtils.forumPost("discussion/49/using-variant-annotator"));
+ throw new UserException.BadInput("Values for " + annotationKeys.get(iii) + " annotation not detected for ANY training variant in the input callset. VariantAnnotator may be used to add these annotations. See " + HelpConstants.forumPost("discussion/49/using-variant-annotator"));
}
foundZeroVarianceAnnotation = foundZeroVarianceAnnotation || (theSTD < 1E-6);
View
6 public/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java
@@ -30,7 +30,7 @@
import org.broadinstitute.sting.gatk.phonehome.GATKRunReport;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
-import org.broadinstitute.sting.utils.help.HelpUtils;
+import org.broadinstitute.sting.utils.help.HelpConstants;
import org.broadinstitute.sting.utils.sam.ReadUtils;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
@@ -278,7 +278,7 @@ public MalformedVCFHeader(String message) {
public static class ReadMissingReadGroup extends MalformedBAM {
public ReadMissingReadGroup(SAMRecord read) {
- super(read, String.format("Read %s is either missing the read group or its read group is not defined in the BAM header, both of which are required by the GATK. Please use " + HelpUtils.forumPost("discussion/59/companion-utilities-replacereadgroups to fix this problem"), read.getReadName()));
+ super(read, String.format("Read %s is either missing the read group or its read group is not defined in the BAM header, both of which are required by the GATK. Please use " + HelpConstants.forumPost("discussion/59/companion-utilities-replacereadgroups to fix this problem"), read.getReadName()));
}
}
@@ -354,7 +354,7 @@ public LexicographicallySortedSequenceDictionary(String name, SAMSequenceDiction
super(String.format("Lexicographically sorted human genome sequence detected in %s."
+ "\nFor safety's sake the GATK requires human contigs in karyotypic order: 1, 2, ..., 10, 11, ..., 20, 21, 22, X, Y with M either leading or trailing these contigs."
+ "\nThis is because all distributed GATK resources are sorted in karyotypic order, and your processing will fail when you need to use these files."
- + "\nYou can use the ReorderSam utility to fix this problem: " + HelpUtils.forumPost("discussion/58/companion-utilities-reordersam")
+ + "\nYou can use the ReorderSam utility to fix this problem: " + HelpConstants.forumPost("discussion/58/companion-utilities-reordersam")
+ "\n %s contigs = %s",
name, name, ReadUtils.prettyPrintSequenceRecords(dict)));
}
View
4 public/java/src/org/broadinstitute/sting/utils/help/ForumAPIUtils.java
@@ -50,7 +50,7 @@
Gson gson = new Gson();
List<String> output = new ArrayList<String>();
- String text = httpGet(HelpUtils.GATK_FORUM_API_URL + "categories.json?CategoryIdentifier=tool-bulletin&page=1-100000&" + ACCESS_TOKEN + forumKey);
+ String text = httpGet(HelpConstants.GATK_FORUM_API_URL + "categories.json?CategoryIdentifier=tool-bulletin&page=1-100000&" + ACCESS_TOKEN + forumKey);
APIQuery details = gson.fromJson(text, APIQuery.class);
ForumDiscussion[] discussions = details.Discussions;
@@ -158,7 +158,7 @@ public static void postToForum(GATKDocWorkUnit tool, final String forumKey) {
Gson gson = new Gson();
String data = gson.toJson(post.getPostData());
- httpPost(data, HelpUtils.GATK_FORUM_API_URL + "post/discussion.json?" + ACCESS_TOKEN + forumKey);
+ httpPost(data, HelpConstants.GATK_FORUM_API_URL + "post/discussion.json?" + ACCESS_TOKEN + forumKey);
}
View
2 public/java/src/org/broadinstitute/sting/utils/help/GATKDocUtils.java
@@ -28,7 +28,7 @@
/**
* The URL root for RELEASED GATKDOC units
*/
- public final static String URL_ROOT_FOR_RELEASE_GATKDOCS = HelpUtils.GATK_DOCS_URL;
+ public final static String URL_ROOT_FOR_RELEASE_GATKDOCS = HelpConstants.GATK_DOCS_URL;
/**
* The URL root for STABLE GATKDOC units
*/
View
81 public/java/src/org/broadinstitute/sting/utils/help/HelpConstants.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2011, 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.help;
+
+import com.sun.javadoc.FieldDoc;
+import com.sun.javadoc.PackageDoc;
+import com.sun.javadoc.ProgramElementDoc;
+import org.broadinstitute.sting.utils.classloader.JVMUtils;
+
+import java.lang.reflect.Field;
+
+public class HelpConstants {
+
+ public final static String BASE_GATK_URL = "http://www.broadinstitute.org/gatk";
+ public final static String GATK_DOCS_URL = BASE_GATK_URL + "/gatkdocs/";
+ public final static String GATK_FORUM_URL = "http://gatkforums.broadinstitute.org/";
+ public final static String GATK_FORUM_API_URL = "https://gatkforums.broadinstitute.org/api/v1/";
+
+ public static String forumPost(String post) {
+ return GATK_FORUM_URL + post;
+ }
+
+ protected static boolean assignableToClass(ProgramElementDoc classDoc, Class lhsClass, boolean requireConcrete) {
+ try {
+ Class type = getClassForDoc(classDoc);
+ return lhsClass.isAssignableFrom(type) && (!requireConcrete || JVMUtils.isConcrete(type));
+ } catch (Throwable t) {
+ // Ignore errors.
+ return false;
+ }
+ }
+
+ protected static Class getClassForDoc(ProgramElementDoc doc) throws ClassNotFoundException {
+ return Class.forName(getClassName(doc));
+ }
+
+ protected static Field getFieldForFieldDoc(FieldDoc fieldDoc) {
+ try {
+ Class clazz = getClassForDoc(fieldDoc.containingClass());
+ return JVMUtils.findField(clazz, fieldDoc.name());
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Reconstitute the class name from the given class JavaDoc object.
+ *
+ * @param doc the Javadoc model for the given class.
+ * @return The (string) class name of the given class.
+ */
+ protected static String getClassName(ProgramElementDoc doc) {
+ PackageDoc containingPackage = doc.containingPackage();
+ return containingPackage.name().length() > 0 ?
+ String.format("%s.%s", containingPackage.name(), doc.name()) :
+ String.format("%s", doc.name());
+ }
+
+}
View
9 public/java/src/org/broadinstitute/sting/utils/help/HelpUtils.java
@@ -33,15 +33,6 @@
public class HelpUtils {
- public final static String BASE_GATK_URL = "http://www.broadinstitute.org/gatk";
- public final static String GATK_DOCS_URL = BASE_GATK_URL + "/gatkdocs/";
- public final static String GATK_FORUM_URL = "http://gatkforums.broadinstitute.org/";
- public final static String GATK_FORUM_API_URL = "https://gatkforums.broadinstitute.org/api/v1/";
-
- public static String forumPost(String post) {
- return GATK_FORUM_URL + post;
- }
-
protected static boolean assignableToClass(ProgramElementDoc classDoc, Class lhsClass, boolean requireConcrete) {
try {
Class type = getClassForDoc(classDoc);

0 comments on commit d738181

Please sign in to comment.