diff --git a/ivy.xml b/ivy.xml
index 0761cb411..1e3346ff5 100644
--- a/ivy.xml
+++ b/ivy.xml
@@ -78,8 +78,8 @@
-
-
+
+
diff --git a/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatch.java b/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatch.java
index c0823e5c5..6c8fb1f4d 100755
--- a/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatch.java
+++ b/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatch.java
@@ -46,7 +46,7 @@ public class ArgumentMatch implements Iterable {
/**
* Maps indices of command line arguments to values paired with that argument.
*/
- public final SortedMap> sites = new TreeMap>();
+ public final SortedMap> sites = new TreeMap>();
/**
* An ordered, freeform collection of tags.
@@ -90,11 +90,11 @@ public class ArgumentMatch implements Iterable {
* @param value Value for the argument at this position.
* @param tags ordered freeform text tags associated with this argument.
*/
- private ArgumentMatch(final String label, final ArgumentDefinition definition, final ArgumentMatchSite site, final String value, final Tags tags) {
+ private ArgumentMatch(final String label, final ArgumentDefinition definition, final ArgumentMatchSite site, final ArgumentMatchValue value, final Tags tags) {
this.label = label;
this.definition = definition;
- ArrayList values = new ArrayList();
+ ArrayList values = new ArrayList();
if( value != null )
values.add(value);
sites.put(site,values );
@@ -131,11 +131,11 @@ public class ArgumentMatch implements Iterable {
*/
@SuppressWarnings("unchecked")
ArgumentMatch transform(Multiplexer multiplexer, Object key) {
- SortedMap> newIndices = new TreeMap>();
- for(Map.Entry> site: sites.entrySet()) {
- List newEntries = new ArrayList();
- for(String entry: site.getValue())
- newEntries.add(multiplexer.transformArgument(key,entry));
+ SortedMap> newIndices = new TreeMap>();
+ for(Map.Entry> site: sites.entrySet()) {
+ List newEntries = new ArrayList();
+ for(ArgumentMatchValue entry: site.getValue())
+ newEntries.add(new ArgumentMatchStringValue(multiplexer.transformArgument(key,entry.asString())));
newIndices.put(site.getKey(),newEntries);
}
ArgumentMatch newArgumentMatch = new ArgumentMatch(label,definition);
@@ -165,7 +165,7 @@ public class ArgumentMatch implements Iterable {
/**
* Iterate over each available token.
*/
- private Iterator tokenIterator = null;
+ private Iterator tokenIterator = null;
/**
* The next site to return. Null if none remain.
@@ -175,7 +175,7 @@ public class ArgumentMatch implements Iterable {
/**
* The next token to return. Null if none remain.
*/
- String nextToken = null;
+ ArgumentMatchValue nextToken = null;
{
siteIterator = sites.keySet().iterator();
@@ -254,9 +254,9 @@ public class ArgumentMatch implements Iterable {
* @param site site of the command-line argument to which this value is mated.
* @param value Text representation of value to add.
*/
- public void addValue( ArgumentMatchSite site, String value ) {
+ public void addValue( ArgumentMatchSite site, ArgumentMatchValue value ) {
if( !sites.containsKey(site) || sites.get(site) == null )
- sites.put(site, new ArrayList() );
+ sites.put(site, new ArrayList() );
sites.get(site).add(value);
}
@@ -275,8 +275,8 @@ public class ArgumentMatch implements Iterable {
* Return the values associated with this argument match.
* @return A collection of the string representation of these value.
*/
- public List values() {
- List values = new ArrayList();
+ public List values() {
+ List values = new ArrayList();
for( ArgumentMatchSite site: sites.keySet() ) {
if( sites.get(site) != null )
values.addAll(sites.get(site));
diff --git a/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatchFileValue.java b/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatchFileValue.java
new file mode 100644
index 000000000..344b6829a
--- /dev/null
+++ b/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatchFileValue.java
@@ -0,0 +1,27 @@
+package org.broadinstitute.sting.commandline;
+
+import java.io.File;
+
+/**
+ * Holds a reference to a file as an argument match value.
+ *
+ * This is useful when the type of the stored file may be a subclass of java.io.File,
+ * for example a Queue RemoteFile.
+ */
+public class ArgumentMatchFileValue extends ArgumentMatchValue {
+ private final File file;
+
+ public ArgumentMatchFileValue(File file) {
+ this.file = file;
+ }
+
+ @Override
+ public String asString() {
+ return file == null ? null : file.getAbsolutePath();
+ }
+
+ @Override
+ public File asFile() {
+ return file;
+ }
+}
diff --git a/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatchSource.java b/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatchSource.java
index ed2700006..9dfb3afbe 100644
--- a/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatchSource.java
+++ b/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatchSource.java
@@ -24,38 +24,36 @@
package org.broadinstitute.sting.commandline;
-import java.io.File;
-
/**
- * Where an argument match originated, via the commandline or a file.
+ * Where an argument match originated, via the commandline or a custom provider.
*/
public class ArgumentMatchSource implements Comparable {
public static final ArgumentMatchSource COMMAND_LINE = new ArgumentMatchSource(ArgumentMatchSourceType.CommandLine, null);
private final ArgumentMatchSourceType type;
- private final File file;
+ private final String description;
/**
* Creates an argument match source from the specified file.
- * @param file File specifying the arguments. Must not be null.
+ * @param description Where the arguments originated.
*/
- public ArgumentMatchSource(File file) {
- this(ArgumentMatchSourceType.File, file);
+ public ArgumentMatchSource(String description) {
+ this(ArgumentMatchSourceType.Provider, description);
}
- private ArgumentMatchSource(ArgumentMatchSourceType type, File file) {
- if (type == ArgumentMatchSourceType.File && file == null)
- throw new IllegalArgumentException("An argument match source of type File cannot have a null file.");
+ private ArgumentMatchSource(ArgumentMatchSourceType type, String description) {
+ if (type == ArgumentMatchSourceType.Provider && description == null)
+ throw new IllegalArgumentException("An argument match source provider cannot have a null description.");
this.type = type;
- this.file = file;
+ this.description = description;
}
public ArgumentMatchSourceType getType() {
return type;
}
- public File getFile() {
- return file;
+ public String getDescription() {
+ return description;
}
@Override
@@ -65,13 +63,13 @@ public class ArgumentMatchSource implements Comparable {
ArgumentMatchSource that = (ArgumentMatchSource) o;
- return (type == that.type) && (file == null ? that.file == null : file.equals(that.file));
+ return (type == that.type) && (description == null ? that.description == null : description.equals(that.description));
}
@Override
public int hashCode() {
int result = type != null ? type.hashCode() : 0;
- result = 31 * result + (file != null ? file.hashCode() : 0);
+ result = 31 * result + (description != null ? description.hashCode() : 0);
return result;
}
@@ -84,15 +82,15 @@ public class ArgumentMatchSource implements Comparable {
if (comp != 0)
return comp;
- File f1 = this.file;
- File f2 = that.file;
+ String d1 = this.description;
+ String d2 = that.description;
- if ((f1 == null) ^ (f2 == null)) {
- // If one of the files is null and the other is not
- // put the null file first
- return f1 == null ? -1 : 1;
+ if ((d1 == null) ^ (d2 == null)) {
+ // If one of the descriptions is null and the other is not
+ // put the null description first
+ return d1 == null ? -1 : 1;
}
- return f1 == null ? 0 : f1.compareTo(f2);
+ return d1 == null ? 0 : d1.compareTo(d2);
}
}
diff --git a/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatchSourceType.java b/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatchSourceType.java
index 3ff6e21d4..118316473 100644
--- a/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatchSourceType.java
+++ b/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatchSourceType.java
@@ -25,8 +25,8 @@
package org.broadinstitute.sting.commandline;
/**
- * Type of where an argument match originated, via the commandline or a file.
+ * Type of where an argument match originated, via the commandline or a some other provider.
*/
public enum ArgumentMatchSourceType {
- CommandLine, File
+ CommandLine, Provider
}
diff --git a/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatchStringValue.java b/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatchStringValue.java
new file mode 100644
index 000000000..bb2015c3b
--- /dev/null
+++ b/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatchStringValue.java
@@ -0,0 +1,24 @@
+package org.broadinstitute.sting.commandline;
+
+import java.io.File;
+
+/**
+ * Argument values that originated from a string.
+ */
+public class ArgumentMatchStringValue extends ArgumentMatchValue {
+ private final String value;
+
+ public ArgumentMatchStringValue(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String asString() {
+ return value;
+ }
+
+ @Override
+ public File asFile() {
+ return value == null ? null : new File(value);
+ }
+}
diff --git a/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatchValue.java b/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatchValue.java
new file mode 100644
index 000000000..bed4edfa6
--- /dev/null
+++ b/public/java/src/org/broadinstitute/sting/commandline/ArgumentMatchValue.java
@@ -0,0 +1,18 @@
+package org.broadinstitute.sting.commandline;
+
+import java.io.File;
+
+/**
+ * Returns argument values as either strings or values.
+ */
+public abstract class ArgumentMatchValue {
+ /**
+ * @return the value of this argument as a String object.
+ */
+ public abstract String asString();
+
+ /**
+ * @return the value of this argument as a File object.
+ */
+ public abstract File asFile();
+}
diff --git a/public/java/src/org/broadinstitute/sting/commandline/ArgumentTypeDescriptor.java b/public/java/src/org/broadinstitute/sting/commandline/ArgumentTypeDescriptor.java
index dd4a151bf..4b9774806 100644
--- a/public/java/src/org/broadinstitute/sting/commandline/ArgumentTypeDescriptor.java
+++ b/public/java/src/org/broadinstitute/sting/commandline/ArgumentTypeDescriptor.java
@@ -215,8 +215,8 @@ public abstract class ArgumentTypeDescriptor {
* @param matches The matches for the given argument.
* @return The value of the argument if available, or null if not present.
*/
- protected String getArgumentValue( ArgumentDefinition definition, ArgumentMatches matches ) {
- Collection argumentValues = getArgumentValues( definition, matches );
+ protected ArgumentMatchValue getArgumentValue( ArgumentDefinition definition, ArgumentMatches matches ) {
+ Collection argumentValues = getArgumentValues( definition, matches );
if( argumentValues.size() > 1 )
throw new UserException.CommandLineException("Multiple values associated with given definition, but this argument expects only one: " + definition.fullName);
return argumentValues.size() > 0 ? argumentValues.iterator().next() : null;
@@ -244,8 +244,8 @@ public abstract class ArgumentTypeDescriptor {
* @param matches The matches for the given argument.
* @return The value of the argument if available, or an empty collection if not present.
*/
- protected Collection getArgumentValues( ArgumentDefinition definition, ArgumentMatches matches ) {
- Collection values = new ArrayList();
+ protected Collection getArgumentValues( ArgumentDefinition definition, ArgumentMatches matches ) {
+ Collection values = new ArrayList();
for( ArgumentMatch match: matches ) {
if( match.definition.equals(definition) )
values.addAll(match.values());
@@ -310,7 +310,7 @@ public abstract class ArgumentTypeDescriptor {
*/
protected Object parseBinding(ArgumentSource source, Type type, ArgumentMatches matches, Tags tags) {
ArgumentDefinition defaultDefinition = createDefaultArgumentDefinition(source);
- String value = getArgumentValue(defaultDefinition, matches);
+ ArgumentMatchValue value = getArgumentValue(defaultDefinition, matches);
@SuppressWarnings("unchecked")
Class extends Feature> parameterType = JVMUtils.getParameterizedTypeClass(type);
String name = defaultDefinition.fullName;
@@ -328,7 +328,7 @@ public abstract class ArgumentTypeDescriptor {
* @param fieldName The name of the field that was parsed. Used for error reporting.
* @return The newly created binding object of type bindingClass.
*/
- public static Object parseBinding(String value, Class extends Feature> parameterType, Type bindingClass,
+ public static Object parseBinding(ArgumentMatchValue value, Class extends Feature> parameterType, Type bindingClass,
String bindingName, Tags tags, String fieldName) {
try {
String tribbleType = null;
@@ -337,7 +337,7 @@ public abstract class ArgumentTypeDescriptor {
throw new UserException.CommandLineException(
String.format("Unexpected number of positional tags for argument %s : %s. " +
"Rod bindings only support -X:type and -X:name,type argument styles",
- value, fieldName));
+ value.asString(), fieldName));
} else if ( tags.getPositionalTags().size() == 2 ) {
// -X:name,type style
bindingName = tags.getPositionalTags().get(0);
@@ -366,7 +366,7 @@ public abstract class ArgumentTypeDescriptor {
if ( tribbleType == null ) {
// try to determine the file type dynamically
- File file = new File(value);
+ File file = value.asFile();
if ( file.canRead() && file.isFile() ) {
FeatureManager.FeatureDescriptor featureDescriptor = manager.getByFiletype(file);
if ( featureDescriptor != null ) {
@@ -379,7 +379,7 @@ public abstract class ArgumentTypeDescriptor {
// IntervalBinding can be created from a normal String
Class rawType = (makeRawTypeIfNecessary(bindingClass));
try {
- return rawType.getConstructor(String.class).newInstance(value);
+ return rawType.getConstructor(String.class).newInstance(value.asString());
} catch (NoSuchMethodException e) {
/* ignore */
}
@@ -399,14 +399,14 @@ public abstract class ArgumentTypeDescriptor {
}
Constructor ctor = (makeRawTypeIfNecessary(bindingClass)).getConstructor(Class.class, String.class, String.class, String.class, Tags.class);
- return ctor.newInstance(parameterType, bindingName, value, tribbleType, tags);
+ return ctor.newInstance(parameterType, bindingName, value.asString(), tribbleType, tags);
} catch (Exception e) {
if ( e instanceof UserException )
throw ((UserException)e);
else
throw new UserException.CommandLineException(
String.format("Failed to parse value %s for argument %s. Message: %s",
- value, fieldName, e.getMessage()));
+ value.asString(), fieldName, e.getMessage()));
}
}
}
@@ -517,7 +517,7 @@ class SimpleArgumentTypeDescriptor extends ArgumentTypeDescriptor {
return true;
ArgumentDefinition defaultDefinition = createDefaultArgumentDefinition(source);
- String value = getArgumentValue( defaultDefinition, matches );
+ ArgumentMatchValue value = getArgumentValue(defaultDefinition, matches);
Object result;
Tags tags = getArgumentTags(matches);
@@ -527,12 +527,12 @@ class SimpleArgumentTypeDescriptor extends ArgumentTypeDescriptor {
Method valueOf = primitiveToWrapperMap.get(type).getMethod("valueOf",String.class);
if(value == null)
throw new MissingArgumentValueException(createDefaultArgumentDefinition(source));
- result = valueOf.invoke(null,value.trim());
+ result = valueOf.invoke(null,value.asString().trim());
} else if (type.isEnum()) {
Object[] vals = type.getEnumConstants();
Object defaultEnumeration = null; // as we look at options, record the default option if it exists
for (Object val : vals) {
- if (String.valueOf(val).equalsIgnoreCase(value)) return val;
+ if (String.valueOf(val).equalsIgnoreCase(value.asString())) return val;
try { if (type.getField(val.toString()).isAnnotationPresent(EnumerationArgumentDefault.class)) defaultEnumeration = val; }
catch (NoSuchFieldException e) { throw new ReviewedStingException("parsing " + type.toString() + "doesn't contain the field " + val.toString()); }
}
@@ -544,10 +544,12 @@ class SimpleArgumentTypeDescriptor extends ArgumentTypeDescriptor {
else if (value == null)
throw new MissingArgumentValueException(createDefaultArgumentDefinition(source));
else
- throw new UnknownEnumeratedValueException(createDefaultArgumentDefinition(source),value);
+ throw new UnknownEnumeratedValueException(createDefaultArgumentDefinition(source),value.asString());
+ } else if (type.equals(File.class)) {
+ result = value.asFile();
} else {
Constructor ctor = type.getConstructor(String.class);
- result = ctor.newInstance(value);
+ result = ctor.newInstance(value.asString());
}
} catch (UserException e) {
throw e;
diff --git a/public/java/src/org/broadinstitute/sting/commandline/CommandLineProgram.java b/public/java/src/org/broadinstitute/sting/commandline/CommandLineProgram.java
index 15ec9dfe5..d77ae67cf 100644
--- a/public/java/src/org/broadinstitute/sting/commandline/CommandLineProgram.java
+++ b/public/java/src/org/broadinstitute/sting/commandline/CommandLineProgram.java
@@ -174,7 +174,7 @@ public abstract class CommandLineProgram {
ParsingEngine parser = clp.parser = new ParsingEngine(clp);
parser.addArgumentSource(clp.getClass());
- Map> parsedArgs;
+ Map parsedArgs;
// process the args
if (clp.canAddArgumentsDynamically()) {
diff --git a/public/java/src/org/broadinstitute/sting/commandline/ParsedArgs.java b/public/java/src/org/broadinstitute/sting/commandline/ParsedArgs.java
new file mode 100644
index 000000000..9ab315175
--- /dev/null
+++ b/public/java/src/org/broadinstitute/sting/commandline/ParsedArgs.java
@@ -0,0 +1,13 @@
+package org.broadinstitute.sting.commandline;
+
+/**
+ * Represents a collection of parsed arguments for an argument source.
+ *
+ * Useful for printing out help documents.
+ */
+public abstract class ParsedArgs {
+ /**
+ * @return A compact description of the arguments from an provider/source.
+ */
+ public abstract String getDescription();
+}
diff --git a/public/java/src/org/broadinstitute/sting/commandline/ParsedListArgs.java b/public/java/src/org/broadinstitute/sting/commandline/ParsedListArgs.java
new file mode 100644
index 000000000..a77e73bcf
--- /dev/null
+++ b/public/java/src/org/broadinstitute/sting/commandline/ParsedListArgs.java
@@ -0,0 +1,30 @@
+package org.broadinstitute.sting.commandline;
+
+import org.apache.commons.lang.StringUtils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * A list of string arguments, usually from the command line or an args list file.
+ */
+public class ParsedListArgs extends ParsedArgs {
+ private final List args = new ArrayList();
+
+ public ParsedListArgs() {
+ }
+
+ public ParsedListArgs(List args) {
+ this.args.addAll(args);
+ }
+
+ public void add(String... args) {
+ this.args.addAll(Arrays.asList(args));
+ }
+
+ @Override
+ public String getDescription() {
+ return StringUtils.join(this.args, " ");
+ }
+}
diff --git a/public/java/src/org/broadinstitute/sting/commandline/ParsingEngine.java b/public/java/src/org/broadinstitute/sting/commandline/ParsingEngine.java
index 0fac195e1..a8b729be4 100755
--- a/public/java/src/org/broadinstitute/sting/commandline/ParsingEngine.java
+++ b/public/java/src/org/broadinstitute/sting/commandline/ParsingEngine.java
@@ -30,6 +30,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.utils.classloader.JVMUtils;
+import org.broadinstitute.sting.utils.classloader.PluginManager;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
import org.broadinstitute.sting.utils.exceptions.UserException;
@@ -61,7 +62,7 @@ public class ParsingEngine {
* Indicates as best as possible where command-line text remains unmatched
* to existing arguments.
*/
- ArgumentMatches argumentMatches = null;
+ private ArgumentMatches argumentMatches = null;
/**
* Techniques for parsing and for argument lookup.
@@ -88,7 +89,10 @@ public class ParsingEngine {
/**
* List of tags associated with the given instantiation of the command-line argument.
*/
- private final Map