Search in sources :

Example 1 with ToolParameter

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);
}
Also used : ToolParameter(com.github.jmchilton.blend4j.galaxy.beans.ToolParameter)

Example 2 with 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);
}
Also used : WorkflowOutputs(com.github.jmchilton.blend4j.galaxy.beans.WorkflowOutputs) HistoryDetails(com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails) Dataset(com.github.jmchilton.blend4j.galaxy.beans.Dataset) ToolParameter(com.github.jmchilton.blend4j.galaxy.beans.ToolParameter) GalaxyWorkflowStatus(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus) HistoryContentsProvenance(com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance) Test(org.junit.Test)

Example 3 with ToolParameter

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);
}
Also used : ToolParameter(com.github.jmchilton.blend4j.galaxy.beans.ToolParameter)

Example 4 with 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;
}
Also used : WorkflowOutputs(com.github.jmchilton.blend4j.galaxy.beans.WorkflowOutputs) Dataset(com.github.jmchilton.blend4j.galaxy.beans.Dataset) WorkflowInputs(com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputs) WorkflowDetails(com.github.jmchilton.blend4j.galaxy.beans.WorkflowDetails) ToolParameter(com.github.jmchilton.blend4j.galaxy.beans.ToolParameter) History(com.github.jmchilton.blend4j.galaxy.beans.History)

Aggregations

ToolParameter (com.github.jmchilton.blend4j.galaxy.beans.ToolParameter)4 Dataset (com.github.jmchilton.blend4j.galaxy.beans.Dataset)2 WorkflowOutputs (com.github.jmchilton.blend4j.galaxy.beans.WorkflowOutputs)2 GalaxyWorkflowStatus (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus)1 History (com.github.jmchilton.blend4j.galaxy.beans.History)1 HistoryContentsProvenance (com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance)1 HistoryDetails (com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails)1 WorkflowDetails (com.github.jmchilton.blend4j.galaxy.beans.WorkflowDetails)1 WorkflowInputs (com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputs)1 Test (org.junit.Test)1