@groovy.util.logging.Log abstract class ToolBase extends java.lang.Object
A support class that makes implementing a tool based on GNGS very easy while supporting some standard behaviors (such as logging, etc).
To implement a tool, use the following steps:
ToolBase
static void main(String [] args)
method
A simple example:
opts variable ...
if(opts.i) {
// ...
}
}
static void main(String [] args) {
cli('Does some foo stuff', args) {
i 'Input to the foo', longOpt: 'input', args:1
}
}
}
Creating tests for tools based on ToolBase encounters some challenges due to the static methods
and the way the command line options are translated directly to the opts variable. To help, a
dedicated test method is provided that allows invocation of the tool using command line arguments,
which correctly sets up the opts variable as appropriate.
Example:
MultiCov mc = new MultiCov()
mc.test(['-bed', 'src/test/data/multicov_test.bed', 'src/test/data/small.test.bam']) {
mc.run()
}
Constructor and description |
---|
ToolBase
() |
Type Params | Return Type | Name and description |
---|---|---|
|
static void |
cli(java.lang.String usage, java.lang.String[] args, groovy.lang.Closure specBuilder) |
|
static void |
cli(java.lang.String usage, java.lang.String header, java.lang.String[] args, groovy.lang.Closure specBuilder) Create an instance of the enclosing class and call its run method after parsing options with a Cli instance configured by the provided specBiulder closure. |
|
void |
error(java.lang.String msg) Print a formatted error message and exit |
|
void |
printTitle() |
|
abstract void |
run() |
|
static void |
setProxy() Check if the http_proxy variable is set, and if no proxy set, initialize the system properties needed from there. |
|
void |
test(java.util.List<java.lang.String> args, groovy.lang.Closure c) A utility method to facilitate testing of tools that extend this class. |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
The options parsed for the tool
Create an instance of the enclosing class and call its run method after
parsing options with a Cli instance configured by
the provided specBiulder
closure.
usage
- a string to present to the user explaining usage of the toolargs
- raw args from command linespecBuilder
- a closure to configure a groovy.util.CliBuilder via a
Cli instancePrint a formatted error message and exit
Check if the http_proxy variable is set, and if no proxy set, initialize the system properties needed from there.
A utility method to facilitate testing of tools that extend this class.
To use this method, create an instance of the tools, then invoke the test method with the command line arguments to pass, and then execute actual functions within the closure callback.
args
- the command line argsGroovy Documentation