use of ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowNoParameterException in project irida by phac-nml.
the class AnalysisParameterServiceGalaxy method prepareAnalysisParameters.
/**
* {@inheritDoc}
*/
@Override
public WorkflowInputsGalaxy prepareAnalysisParameters(Map<String, String> parameters, IridaWorkflow iridaWorkflow) throws IridaWorkflowParameterException {
checkNotNull(parameters, "parameters is null");
checkNotNull(iridaWorkflow, "iridaWorkflow is null");
WorkflowInputs inputs = new WorkflowInputs();
Set<String> parameterNamesUsed = Sets.newHashSet();
if (!iridaWorkflow.getWorkflowDescription().acceptsParameters()) {
if (parameters.isEmpty()) {
logger.debug("workflow " + iridaWorkflow + " does not accept parameters and no parameters passed.");
} else {
throw new IridaWorkflowNoParameterException("The workflow " + iridaWorkflow + " does not accept parameters but parameters " + parameters + " were passed.");
}
} else {
List<IridaWorkflowParameter> iridaParameters = iridaWorkflow.getWorkflowDescription().getParameters();
ParameterBuilderGalaxy parameterBuilder = new ParameterBuilderGalaxy();
for (IridaWorkflowParameter iridaParameter : iridaParameters) {
String parameterName = iridaParameter.getName();
String value = parameters.get(parameterName);
parameterNamesUsed.add(parameterName);
if (ignoreDefaultValue(parameters, parameterName)) {
logger.debug("Parameter with name=" + parameterName + " will ignore the default value=" + iridaParameter.getDefaultValue());
} else {
if (useDefaultValue(parameters, parameterName)) {
value = iridaParameter.getDefaultValue();
logger.debug("Parameter with name=" + parameterName + ", for workflow=" + iridaWorkflow + ", has no value set, using defaultValue=" + value);
}
for (IridaToolParameter iridaToolParameter : iridaParameter.getToolParameters()) {
String toolId = iridaToolParameter.getToolId();
String galaxyParameterName = iridaToolParameter.getParameterName();
parameterBuilder.addParameter(toolId, galaxyParameterName, value);
logger.debug("Setting parameter iridaName=" + parameterName + ", galaxyToolId=" + toolId + ", galaxyParameterName=" + galaxyParameterName + ", value=" + value);
}
}
}
for (ParameterBuilderGalaxy.ParameterId parameterId : parameterBuilder.getParameterIds()) {
inputs.setToolParameter(parameterId.getToolId(), parameterId.getStartName(), parameterBuilder.getMappingForParameterId(parameterId));
}
}
Set<String> parameterNamesUnused = Sets.difference(parameters.keySet(), parameterNamesUsed);
if (!parameterNamesUnused.isEmpty()) {
throw new IridaWorkflowParameterException("The set of parameters " + parameterNamesUnused + " are not defined in " + iridaWorkflow);
} else {
return new WorkflowInputsGalaxy(inputs);
}
}
Aggregations