Bug fix for help text / version number - help text retriever was crashing in the debugger if help text hadn't been built.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2643 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
ab289872e4
commit
908d399670
|
|
@ -99,10 +99,10 @@ public class CommandLineGATK extends CommandLineExecutable {
|
||||||
* @return The application header.
|
* @return The application header.
|
||||||
*/
|
*/
|
||||||
public static List<String> createApplicationHeader() {
|
public static List<String> createApplicationHeader() {
|
||||||
ResourceBundle headerInfo = ResourceBundle.getBundle("StingText");
|
ResourceBundle headerInfo = TextFormattingUtils.loadResourceBundle("StingText");
|
||||||
|
|
||||||
String versionNumber = headerInfo.getString("org.broadinstitute.sting.gatk.version");
|
String versionNumber = headerInfo.containsKey("org.broadinstitute.sting.gatk.version") ? headerInfo.getString("org.broadinstitute.sting.gatk.version") : "<unknown>";
|
||||||
String timestamp = headerInfo.getString("build.timestamp");
|
String timestamp = headerInfo.containsKey("build.timestamp") ? headerInfo.getString("build.timestamp") : "<unknown>";
|
||||||
|
|
||||||
List<String> header = new ArrayList<String>();
|
List<String> header = new ArrayList<String>();
|
||||||
header.add(String.format("The Genome Analysis Toolkit (GATK) v%s, Compiled %s",versionNumber,timestamp));
|
header.add(String.format("The Genome Analysis Toolkit (GATK) v%s, Compiled %s",versionNumber,timestamp));
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,6 @@
|
||||||
package org.broadinstitute.sting.gatk;
|
package org.broadinstitute.sting.gatk;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.broadinstitute.sting.gatk.walkers.*;
|
import org.broadinstitute.sting.gatk.walkers.*;
|
||||||
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum;
|
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum;
|
||||||
|
|
@ -35,6 +33,7 @@ import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedData;
|
||||||
import org.broadinstitute.sting.gatk.filters.FilterManager;
|
import org.broadinstitute.sting.gatk.filters.FilterManager;
|
||||||
import org.broadinstitute.sting.utils.StingException;
|
import org.broadinstitute.sting.utils.StingException;
|
||||||
import org.broadinstitute.sting.utils.PluginManager;
|
import org.broadinstitute.sting.utils.PluginManager;
|
||||||
|
import org.broadinstitute.sting.utils.TextFormattingUtils;
|
||||||
import org.broadinstitute.sting.utils.help.DisplayNameTaglet;
|
import org.broadinstitute.sting.utils.help.DisplayNameTaglet;
|
||||||
import org.broadinstitute.sting.utils.help.DescriptionTaglet;
|
import org.broadinstitute.sting.utils.help.DescriptionTaglet;
|
||||||
import org.broadinstitute.sting.utils.help.SummaryTaglet;
|
import org.broadinstitute.sting.utils.help.SummaryTaglet;
|
||||||
|
|
@ -62,7 +61,7 @@ public class WalkerManager extends PluginManager<Walker> {
|
||||||
|
|
||||||
public WalkerManager() {
|
public WalkerManager() {
|
||||||
super(Walker.class,"walker","Walker");
|
super(Walker.class,"walker","Walker");
|
||||||
helpText = ResourceBundle.getBundle("StingText");
|
helpText = TextFormattingUtils.loadResourceBundle("StingText");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
package org.broadinstitute.sting.utils;
|
package org.broadinstitute.sting.utils;
|
||||||
|
|
||||||
import java.util.List;
|
import org.apache.log4j.Logger;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
import java.util.*;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common utilities for dealing with text formatting.
|
* Common utilities for dealing with text formatting.
|
||||||
|
|
@ -13,6 +15,11 @@ import java.util.regex.Matcher;
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
public class TextFormattingUtils {
|
public class TextFormattingUtils {
|
||||||
|
/**
|
||||||
|
* our log, which we want to capture anything from this class
|
||||||
|
*/
|
||||||
|
private static Logger logger = Logger.getLogger(TextFormattingUtils.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default line width, for GATK output written to the screen.
|
* The default line width, for GATK output written to the screen.
|
||||||
*/
|
*/
|
||||||
|
|
@ -57,7 +64,30 @@ public class TextFormattingUtils {
|
||||||
if(rhs == null) return -1;
|
if(rhs == null) return -1;
|
||||||
return lhs.toLowerCase().compareTo(rhs.toLowerCase());
|
return lhs.toLowerCase().compareTo(rhs.toLowerCase());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the contents of a resource bundle with the given name. If no such resource exists, warn the user
|
||||||
|
* and create an empty bundle.
|
||||||
|
* @param bundleName The name of the bundle to load.
|
||||||
|
* @return The best resource bundle that can be found matching the given name.
|
||||||
|
*/
|
||||||
|
public static ResourceBundle loadResourceBundle(String bundleName) {
|
||||||
|
ResourceBundle bundle;
|
||||||
|
try {
|
||||||
|
bundle = ResourceBundle.getBundle(bundleName);
|
||||||
|
}
|
||||||
|
catch(MissingResourceException ex) {
|
||||||
|
logger.warn("Unable to load help text. Help output will be sparse.");
|
||||||
|
// Generate an empty resource bundle.
|
||||||
|
try {
|
||||||
|
bundle = new PropertyResourceBundle(new StringReader(""));
|
||||||
|
}
|
||||||
|
catch(IOException ioe) {
|
||||||
|
throw new StingException("No resource bundle found, and unable to create an empty placeholder.",ioe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue