+ public static List<String> writeParameterSet(List<Option> optSet,
+ String pseparator)
+ {
+ List<String> pset = new ArrayList<String>();
+ for (Option o : optSet)
+ {
+ pset.add(o.toCommand(pseparator));
+ }
+ return pset;
+ }
+
+ /**
+ * Converts options supplied via parameters file into {@code Option} objects
+ * (Refactored from compbio.ws.client.Jws2Client)
+ *
+ * @param <T>
+ * web service type
+ * @param params
+ * @param options
+ * @return List of Options of type T
+ *
+ */
+ /*
+ * @SuppressWarnings(value = { "true" }) public static <T> List<Option<T>>
+ * processParameters(List<String> params, RunnerConfig<T> options, String
+ * pseparator)
+ */
+ public static List<Option> processParameters(List<String> params,
+ RunnerConfig options, String pseparator)
+ {
+ List<Option> chosenOptions = new ArrayList<Option>();
+ for (String param : params)
+ {
+ String oname = null;
+ if (isParameter(param, pseparator))
+ {
+ oname = getParamName(param, pseparator);
+ }
+ else
+ {
+ oname = param;
+ }
+ Option o = options.getArgumentByOptionName(oname);
+ if (o == null)
+ {
+ System.out.println("WARN ignoring unsuppoted parameter: " + oname);
+ continue;
+ }
+ if (o instanceof Parameter)
+ {
+ o = copyParameter((Parameter) o);
+ }
+ else
+ {
+ o = copyOption(o);
+ }
+ {
+ try
+ {
+ o.setDefaultValue(isParameter(param, pseparator) ? getParamValue(
+ param, pseparator) : param);
+ } catch (WrongParameterException e)
+ {
+ System.out.println("Problem setting value for the parameter: "
+ + param);
+ e.printStackTrace();
+ }
+ }
+ chosenOptions.add(o);
+ }
+ return chosenOptions;
+ }
+
+ static String getParamName(String fullName, String pseparator)
+ {
+ assert isParameter(fullName, pseparator);
+ return fullName.substring(0, fullName.indexOf(pseparator));
+ }
+
+ static String getParamValue(String fullName, String pseparator)
+ {
+ assert isParameter(fullName, pseparator);
+ return fullName.substring(fullName.indexOf(pseparator) + 1);
+ }
+
+ static boolean isParameter(String param, String pseparator)
+ {
+ return param.contains(pseparator);
+ }