Search in sources :

Example 21 with HistoryContents

use of com.github.jmchilton.blend4j.galaxy.beans.HistoryContents in project irida by phac-nml.

the class AnalysisProvenanceServiceGalaxyTest method testBuildSingleStepToolExecutionOneParameter.

@Test
public void testBuildSingleStepToolExecutionOneParameter() throws ExecutionManagerException {
    final HistoryContents hc = new HistoryContents();
    hc.setName(FILENAME);
    final HistoryContentsProvenance hcp = new HistoryContentsProvenance();
    hcp.setParameters(ImmutableMap.of("akey", (Object) "avalue"));
    final JobDetails jd = new JobDetails();
    jd.setCommandLine("");
    when(galaxyHistoriesService.showHistoryContents(any(String.class))).thenReturn(Lists.newArrayList(hc));
    when(galaxyHistoriesService.showProvenance(any(String.class), any(String.class))).thenReturn(hcp);
    when(toolsClient.showTool(any(String.class))).thenReturn(new Tool());
    when(jobsClient.showJob(any(String.class))).thenReturn(jd);
    final ToolExecution toolExecution = provenanceService.buildToolExecutionForOutputFile(analysisSubmission(), analysisOutputFile());
    assertTrue("tool execution should have the specified parameter.", toolExecution.getExecutionTimeParameters().containsKey("akey"));
    assertEquals("tool execution parameter should be specified value.", "avalue", toolExecution.getExecutionTimeParameters().get("akey"));
    assertTrue("Tool execution should be considered input step, no predecessors.", toolExecution.isInputTool());
}
Also used : ToolExecution(ca.corefacility.bioinformatics.irida.model.workflow.analysis.ToolExecution) HistoryContents(com.github.jmchilton.blend4j.galaxy.beans.HistoryContents) HistoryContentsProvenance(com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance) JobDetails(com.github.jmchilton.blend4j.galaxy.beans.JobDetails) Tool(com.github.jmchilton.blend4j.galaxy.beans.Tool) Test(org.junit.Test)

Example 22 with HistoryContents

use of com.github.jmchilton.blend4j.galaxy.beans.HistoryContents in project irida by phac-nml.

the class AnalysisProvenanceServiceGalaxy method buildToolExecutionForOutputFile.

/**
 * Build up a provenance report for a specific file that's attached to the
 * outputs of an analysis submission.
 *
 * @param remoteAnalysisId
 *            the identifier of the submission history that the output file
 *            is attached to on the execution manager (i.e., Galaxy's
 *            history id).
 * @param analysisOutputFilename
 *            the filename to build the report for. This should be the raw
 *            basename of the file (i.e., only the filename + extension
 *            part).
 * @return the complete report for the file.
 * @throws ExecutionManagerException
 *             if the history contents could not be shown for the specified
 *             file.
 */
public ToolExecution buildToolExecutionForOutputFile(final String remoteAnalysisId, final String analysisOutputFilename) throws ExecutionManagerException {
    final List<HistoryContents> historyContents = galaxyHistoriesService.showHistoryContents(remoteAnalysisId);
    // group the history contents by name. The names that we're interested
    // in starting from should match the filename of the output file.
    final Map<String, List<HistoryContents>> historyContentsByName = historyContents.stream().collect(Collectors.groupingBy(HistoryContents::getName));
    final List<HistoryContents> currentContents = historyContentsByName.get(analysisOutputFilename);
    if (currentContents == null || currentContents.isEmpty() || currentContents.size() > 1) {
        throw new ExecutionManagerException("Could not load a unique history contents for the specified filename [" + analysisOutputFilename + "] in history with id [" + remoteAnalysisId + "]");
    }
    final HistoryContentsProvenance currentProvenance = galaxyHistoriesService.showProvenance(remoteAnalysisId, currentContents.get(0).getId());
    try {
        final Tool toolDetails = toolsClient.showTool(currentProvenance.getToolId());
        return buildToolExecutionForHistoryStep(toolDetails, currentProvenance, remoteAnalysisId);
    } catch (final RuntimeException e) {
        throw new ExecutionManagerException("Failed to build tool execution provenance.", e);
    }
}
Also used : HistoryContents(com.github.jmchilton.blend4j.galaxy.beans.HistoryContents) List(java.util.List) HistoryContentsProvenance(com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance) ExecutionManagerException(ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException) Tool(com.github.jmchilton.blend4j.galaxy.beans.Tool)

Aggregations

HistoryContents (com.github.jmchilton.blend4j.galaxy.beans.HistoryContents)22 Test (org.junit.Test)18 History (com.github.jmchilton.blend4j.galaxy.beans.History)11 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)9 HistoryContentsProvenance (com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance)8 WithMockUser (org.springframework.security.test.context.support.WithMockUser)8 Path (java.nio.file.Path)7 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)6 PreparedWorkflowGalaxy (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.PreparedWorkflowGalaxy)6 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)6 WorkflowsClient (com.github.jmchilton.blend4j.galaxy.WorkflowsClient)6 Tool (com.github.jmchilton.blend4j.galaxy.beans.Tool)6 Workflow (com.github.jmchilton.blend4j.galaxy.beans.Workflow)6 ToolExecution (ca.corefacility.bioinformatics.irida.model.workflow.analysis.ToolExecution)5 WorkflowInputsGalaxy (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy)5 JobDetails (com.github.jmchilton.blend4j.galaxy.beans.JobDetails)5 LibrariesClient (com.github.jmchilton.blend4j.galaxy.LibrariesClient)4 HashMap (java.util.HashMap)4 List (java.util.List)4 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)3