use of com.github.jmchilton.blend4j.galaxy.beans.ToolParameter in project irida by phac-nml.
the class GalaxyWorkflowsIT method runSingleFileTabularWorkflowSleepTool.
/**
* Runs a test sleep workflow with the given input.
*
* @param history
* The history to run the workflow in.
* @param inputFile
* The file to run the workflow on.
* @param sleepTime
* The sleep time.
* @return A {@link WorkflowOutputs} for this workflow.
* @throws ExecutionManagerException
*/
private WorkflowOutputs runSingleFileTabularWorkflowSleepTool(History history, Path inputFile, String sleepTime) throws ExecutionManagerException {
String workflowId = localGalaxy.getWorkflowSleepId();
String workflowInputLabel = localGalaxy.getWorkflowSleepLabel();
ToolParameter toolParameter = new ToolParameter("time", sleepTime);
return runSingleFileTabularWorkflow(workflowId, workflowInputLabel, history, inputFile, "sleep", toolParameter);
}
use of com.github.jmchilton.blend4j.galaxy.beans.ToolParameter in project irida by phac-nml.
the class GalaxyWorkflowsIT method testExecuteWorkflowChangeToolParameter.
/**
* Tests executing a single workflow in Galaxy and changing a single tool
* parameter.
*
* @throws ExecutionManagerException
*/
@Test
public void testExecuteWorkflowChangeToolParameter() throws ExecutionManagerException {
String toolId = "Grep1";
String workflowId = localGalaxy.getSingleInputWorkflowId();
String workflowInputLabel = localGalaxy.getSingleInputWorkflowLabel();
Map<String, ToolParameter> toolParameters = ImmutableMap.of(toolId, new ToolParameter("pattern", "^#"));
WorkflowOutputs workflowOutput = runSingleFileWorkflow(dataFile1, FILE_TYPE, workflowId, workflowInputLabel, toolParameters);
assertNotNull("workflowOutput should not be null", workflowOutput);
assertNotNull("workflowOutput history id should not be null", workflowOutput.getHistoryId());
// history should exist
HistoryDetails historyDetails = historiesClient.showHistory(workflowOutput.getHistoryId());
assertNotNull("historyDetails for the history for the workflow should not be null", historyDetails);
// outputs should exist
assertNotNull("outputIds for the workflow should not be null", workflowOutput.getOutputIds());
assertTrue("there should exist output dataset ids for the workflow", workflowOutput.getOutputIds().size() > 0);
// each output dataset should exist
for (String outputId : workflowOutput.getOutputIds()) {
Dataset dataset = historiesClient.showDataset(workflowOutput.getHistoryId(), outputId);
assertNotNull("the output dataset should exist", dataset);
HistoryContentsProvenance provenance = historiesClient.showProvenance(workflowOutput.getHistoryId(), dataset.getId());
if (toolId.equals(provenance.getToolId())) {
Map<String, Object> parametersMap = provenance.getParameters();
assertEquals("pattern parameter is correct", "\"^#\"", parametersMap.get("pattern"));
}
}
// test get workflow status
GalaxyWorkflowStatus workflowStatus = galaxyHistory.getStatusForHistory(workflowOutput.getHistoryId());
float proportionComplete = workflowStatus.getProportionComplete();
assertTrue("the workflow proportion complete should be between 0 and 1", 0.0f <= proportionComplete && proportionComplete <= 1.0f);
}
use of com.github.jmchilton.blend4j.galaxy.beans.ToolParameter in project irida by phac-nml.
the class GalaxyWorkflowsIT method runSingleFileTabularWorkflowFilterTool.
/**
* Runs a test filter workflow with the given input.
*
* @param history
* The history to run the workflow in.
* @param inputFile
* The file to run the workflow on.
* @param filterParameters
* The condition to run the workflow with.
* @return A {@link WorkflowOutputs} for this workflow.
* @throws ExecutionManagerException
*/
private WorkflowOutputs runSingleFileTabularWorkflowFilterTool(History history, Path inputFile, String filterParameters) throws ExecutionManagerException {
String workflowId = localGalaxy.getWorkflowFilterId();
String workflowInputLabel = localGalaxy.getWorkflowFilterLabel();
ToolParameter toolParameter = new ToolParameter("cond", filterParameters);
return runSingleFileTabularWorkflow(workflowId, workflowInputLabel, history, inputFile, "Filter1", toolParameter);
}
use of com.github.jmchilton.blend4j.galaxy.beans.ToolParameter in project irida by phac-nml.
the class GalaxyWorkflowsIT method runSingleFileWorkflow.
/**
* Starts the execution of a workflow with a single fastq file and the given workflow id.
* @param inputFile An input file to start the workflow.
* @param inputFileType The file type of the input file.
* @param workflowId The id of the workflow to start.
* @param workflowInputLabel The label of a workflow input in Galaxy.
* @param toolParameters A map of tool parameters to set.
* @throws ExecutionManagerException If there was an error executing the workflow.
*/
private WorkflowOutputs runSingleFileWorkflow(Path inputFile, InputFileType inputFileType, String workflowId, String workflowInputLabel, Map<String, ToolParameter> toolParameters) throws ExecutionManagerException {
checkNotNull(inputFile, "file is null");
checkNotNull(inputFileType, "inputFileType is null");
checkNotNull(workflowInputLabel, "workflowInputLabel is null");
checkArgument(Files.exists(inputFile), "inputFile " + inputFile + " does not exist");
History workflowHistory = galaxyHistory.newHistoryForWorkflow();
WorkflowDetails workflowDetails = workflowsClient.showWorkflow(workflowId);
// upload dataset to history
Dataset inputDataset = galaxyHistory.fileToHistory(inputFile, inputFileType, workflowHistory);
assertNotNull(inputDataset);
String workflowInputId = galaxyWorkflowService.getWorkflowInputId(workflowDetails, workflowInputLabel);
WorkflowInputs inputs = new WorkflowInputs();
inputs.setDestination(new WorkflowInputs.ExistingHistory(workflowHistory.getId()));
inputs.setWorkflowId(workflowDetails.getId());
inputs.setInput(workflowInputId, new WorkflowInputs.WorkflowInput(inputDataset.getId(), WorkflowInputs.InputSourceType.HDA));
if (toolParameters != null) {
for (String toolId : toolParameters.keySet()) {
ToolParameter toolParameter = toolParameters.get(toolId);
inputs.setToolParameter(toolId, toolParameter);
}
}
// execute workflow
WorkflowOutputs output = workflowsClient.runWorkflow(inputs);
logger.debug("Running workflow in history " + output.getHistoryId());
return output;
}
Aggregations