use of ca.corefacility.bioinformatics.irida.model.workflow.description.IridaToolParameter in project irida by phac-nml.
the class AnalysisParameterServiceGalaxyTest method testPrepareParametersOverrideMultipleLevelSuccess.
/**
* Tests preparing workflow parameters with multiple levels and overriding
* with custom value successfully.
*
* @throws IridaWorkflowParameterException
*/
@Test
public void testPrepareParametersOverrideMultipleLevelSuccess() throws IridaWorkflowParameterException {
IridaToolParameter iridaToolParameter = new IridaToolParameter("galaxy-tool1", "level1.parameter1");
IridaWorkflowParameter parameter1 = new IridaWorkflowParameter("parameter1", "0", Lists.newArrayList(iridaToolParameter));
List<IridaWorkflowParameter> iridaWorkflowParameters = Lists.newArrayList(parameter1);
when(iridaWorkflowDescription.getParameters()).thenReturn(iridaWorkflowParameters);
Map<String, String> parameters = Maps.newHashMap();
parameters.put("parameter1", "1");
WorkflowInputsGalaxy workflowInputsGalaxy = analysisParameterService.prepareAnalysisParameters(parameters, iridaWorkflow);
assertNotNull("workflowInputsGalaxy is null", workflowInputsGalaxy);
WorkflowInputs workflowInputs = workflowInputsGalaxy.getInputsObject();
Map<Object, Map<String, Object>> workflowParameters = workflowInputs.getParameters();
Map<String, Object> tool1Parameters = workflowParameters.get("galaxy-tool1");
assertNotNull("parameters for galaxy-tool1 should not be null", tool1Parameters);
assertEquals("parameter not properly defined", ImmutableMap.of("level1", ImmutableMap.of("parameter1", "1")), tool1Parameters);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.description.IridaToolParameter in project irida by phac-nml.
the class AnalysisParameterServiceGalaxyTest method testPrepareParametersOverrideSuccessTwoTools.
/**
* Tests preparing workflow parameters and overriding with custom value
* successfully in two tools.
*
* @throws IridaWorkflowParameterException
*/
@Test
public void testPrepareParametersOverrideSuccessTwoTools() throws IridaWorkflowParameterException {
Map<String, String> parameters = Maps.newHashMap();
parameters.put("parameter1", "1");
IridaToolParameter iridaToolParameter = new IridaToolParameter("galaxy-tool1", "parameter1");
IridaToolParameter iridaToolParameter2 = new IridaToolParameter("galaxy-tool1", "parameter2");
IridaWorkflowParameter parameter1 = new IridaWorkflowParameter("parameter1", "0", Lists.newArrayList(iridaToolParameter, iridaToolParameter2));
List<IridaWorkflowParameter> iridaWorkflowParameters = Lists.newArrayList(parameter1);
when(iridaWorkflowDescription.getParameters()).thenReturn(iridaWorkflowParameters);
WorkflowInputsGalaxy workflowInputsGalaxy = analysisParameterService.prepareAnalysisParameters(parameters, iridaWorkflow);
assertNotNull("workflowInputsGalaxy is null", workflowInputsGalaxy);
WorkflowInputs workflowInputs = workflowInputsGalaxy.getInputsObject();
Map<Object, Map<String, Object>> workflowParameters = workflowInputs.getParameters();
Map<String, Object> tool1Parameters = workflowParameters.get("galaxy-tool1");
assertNotNull("parameters for galaxy-tool1 should not be null", tool1Parameters);
assertEquals("galaxy-tool1,parameter1 is not valid", "1", tool1Parameters.get("parameter1"));
assertEquals("galaxy-tool1,parameter2 is not valid", "1", tool1Parameters.get("parameter2"));
}
use of ca.corefacility.bioinformatics.irida.model.workflow.description.IridaToolParameter 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);
}
}
use of ca.corefacility.bioinformatics.irida.model.workflow.description.IridaToolParameter in project irida by phac-nml.
the class IridaWorkflowTestBuilder method buildTestDescription.
/**
* Builds a {@link IridaWorkflowDescription} with the following information.
*
* @param id
* The id of the workflow.
* @param name
* The name of the workflow.
* @param version
* The version of the workflow.
* @param analysisType
* The {@link AnalysisType} of the workflow.
* @param reference
* The reference label for the workflow.
* @param requiresSingleSample
* Whether or not this workflow requires a single sample.
* @return An {@link IridaWorkflowDescription} with the given information.
* @throws MalformedURLException
*/
public static IridaWorkflowDescription buildTestDescription(UUID id, String name, String version, AnalysisType analysisType, Input input, String reference, boolean requiresSingleSample) throws MalformedURLException {
List<IridaWorkflowOutput> outputs = new LinkedList<>();
outputs.add(new IridaWorkflowOutput("output1", "output1.txt"));
outputs.add(new IridaWorkflowOutput("output2", "output2.txt"));
List<IridaWorkflowToolRepository> tools = new LinkedList<>();
IridaWorkflowToolRepository workflowTool = new IridaWorkflowToolRepository("sam_to_bam", "devteam", new URL("http://toolshed.g2.bx.psu.edu/"), "8176b2575aa1");
tools.add(workflowTool);
IridaWorkflowInput workflowInput = null;
switch(input) {
case SINGLE:
workflowInput = new IridaWorkflowInput("sequence_reads", null, reference, requiresSingleSample);
break;
case PAIRED:
workflowInput = new IridaWorkflowInput(null, "sequence_reads_paired", reference, requiresSingleSample);
break;
case SINGLE_PAIRED:
workflowInput = new IridaWorkflowInput("sequence_reads", "sequence_reads_paired", reference, requiresSingleSample);
break;
}
List<IridaWorkflowParameter> parameters = new LinkedList<>();
IridaToolParameter tool1 = new IridaToolParameter("irida.corefacility.ca/galaxy-shed/repos/irida/test-tool/0.1", "a");
IridaToolParameter tool2 = new IridaToolParameter("irida.corefacility.ca/galaxy-shed/repos/irida/test-tool/0.1", "b");
IridaWorkflowParameter parameter1 = new IridaWorkflowParameter("test-parameter", "1", Lists.newArrayList(tool1, tool2));
parameters.add(parameter1);
IridaWorkflowDescription iridaWorkflow = new IridaWorkflowDescription(id, name, version, analysisType, workflowInput, outputs, tools, parameters);
return iridaWorkflow;
}
use of ca.corefacility.bioinformatics.irida.model.workflow.description.IridaToolParameter in project irida by phac-nml.
the class AnalysisParameterServiceGalaxyTest method testPrepareParametersOverrideThreeLevelMultipleParameterSuccess.
/**
* Tests preparing workflow parameters with three levels, multiple
* parameters and overriding with custom value successfully.
*
* @throws IridaWorkflowParameterException
*/
@Test
public void testPrepareParametersOverrideThreeLevelMultipleParameterSuccess() throws IridaWorkflowParameterException {
IridaToolParameter iridaToolParameter = new IridaToolParameter("galaxy-tool1", "level1.level2.parameter1");
IridaToolParameter iridaToolParameter2 = new IridaToolParameter("galaxy-tool1", "level1.level2.parameter2");
IridaToolParameter iridaToolParameter3 = new IridaToolParameter("galaxy-tool1", "level1.parameter3");
IridaWorkflowParameter parameter1 = new IridaWorkflowParameter("parameter1", "0", Lists.newArrayList(iridaToolParameter, iridaToolParameter2, iridaToolParameter3));
List<IridaWorkflowParameter> iridaWorkflowParameters = Lists.newArrayList(parameter1);
when(iridaWorkflowDescription.getParameters()).thenReturn(iridaWorkflowParameters);
Map<String, String> parameters = Maps.newHashMap();
parameters.put("parameter1", "1");
WorkflowInputsGalaxy workflowInputsGalaxy = analysisParameterService.prepareAnalysisParameters(parameters, iridaWorkflow);
assertNotNull("workflowInputsGalaxy is null", workflowInputsGalaxy);
WorkflowInputs workflowInputs = workflowInputsGalaxy.getInputsObject();
Map<Object, Map<String, Object>> workflowParameters = workflowInputs.getParameters();
Map<String, Object> tool1Parameters = workflowParameters.get("galaxy-tool1");
assertNotNull("parameters for galaxy-tool1 should not be null", tool1Parameters);
assertEquals("parameter not properly defined", ImmutableMap.of("level1", ImmutableMap.of("parameter3", "1", "level2", ImmutableMap.of("parameter1", "1", "parameter2", "1"))), tool1Parameters);
}
Aggregations