Search in sources :

Example 1 with IridaWorkflowNoParameterException

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);
    }
}
Also used : IridaWorkflowParameter(ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowParameter) WorkflowInputs(com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputs) IridaToolParameter(ca.corefacility.bioinformatics.irida.model.workflow.description.IridaToolParameter) IridaWorkflowNoParameterException(ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowNoParameterException) WorkflowInputsGalaxy(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy) IridaWorkflowParameterException(ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowParameterException)

Aggregations

IridaWorkflowNoParameterException (ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowNoParameterException)1 IridaWorkflowParameterException (ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowParameterException)1 IridaToolParameter (ca.corefacility.bioinformatics.irida.model.workflow.description.IridaToolParameter)1 IridaWorkflowParameter (ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowParameter)1 WorkflowInputsGalaxy (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy)1 WorkflowInputs (com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputs)1