Search in sources :

Example 11 with Workflow

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

the class LocalGalaxy method constructTestWorkflow.

/**
 * Constructs a workflow in the test Galaxy with the given workflow file.
 * @param workflowFile  The file to construct a workflow from.
 * @return  The id of the workflow constructed.
 * @throws IOException If there was an error reading the workflow file.
 */
private String constructTestWorkflow(Path workflowFile) throws IOException, RuntimeException {
    checkNotNull(workflowFile, "workflowFile is null");
    String content = readFile(workflowFile);
    WorkflowsClient workflowsClient = galaxyInstanceAdmin.getWorkflowsClient();
    Workflow workflow = workflowsClient.importWorkflow(content);
    if (workflow != null && workflow.getId() != null) {
        return workflow.getId();
    } else {
        throw new RuntimeException("Error building workflow from file " + workflowFile + " in Galaxy " + galaxyURL);
    }
}
Also used : WorkflowsClient(com.github.jmchilton.blend4j.galaxy.WorkflowsClient) Workflow(com.github.jmchilton.blend4j.galaxy.beans.Workflow)

Example 12 with Workflow

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

the class AnalysisWorkspaceServiceGalaxyIT method testPrepareAnalysisFilesParametersSuccessWithNoParameters.

/**
 * Tests out successfully preparing paired workflow input files for
 * execution, no parameters set.
 *
 * @throws InterruptedException
 * @throws ExecutionManagerException
 * @throws IOException
 * @throws IridaWorkflowException
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testPrepareAnalysisFilesParametersSuccessWithNoParameters() throws InterruptedException, ExecutionManagerException, IOException, IridaWorkflowException {
    History history = new History();
    history.setName("testPrepareAnalysisFilesParametersSuccessWithNoParameters");
    HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
    WorkflowsClient workflowsClient = localGalaxy.getGalaxyInstanceAdmin().getWorkflowsClient();
    History createdHistory = historiesClient.create(history);
    IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(validWorkflowIdPairedWithParameters);
    Path workflowPath = iridaWorkflow.getWorkflowStructure().getWorkflowFile();
    String workflowString = new String(Files.readAllBytes(workflowPath), StandardCharsets.UTF_8);
    Workflow galaxyWorkflow = workflowsClient.importWorkflow(workflowString);
    AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupPairSubmissionInDatabase(1L, pairSequenceFiles1A, pairSequenceFiles2A, referenceFilePath, validWorkflowIdPairedWithParameters, false);
    analysisSubmission.setRemoteAnalysisId(createdHistory.getId());
    analysisSubmission.setRemoteWorkflowId(galaxyWorkflow.getId());
    PreparedWorkflowGalaxy preparedWorkflow = analysisWorkspaceService.prepareAnalysisFiles(analysisSubmission);
    assertEquals("the response history id should match the input history id", createdHistory.getId(), preparedWorkflow.getRemoteAnalysisId());
    WorkflowInputsGalaxy workflowInputsGalaxy = preparedWorkflow.getWorkflowInputs();
    assertNotNull("the returned workflow inputs should not be null", workflowInputsGalaxy);
    assertNotNull("the returned library id should not be null", preparedWorkflow.getRemoteDataId());
    // verify correct files have been uploaded
    List<HistoryContents> historyContents = historiesClient.showHistoryContents(createdHistory.getId());
    assertEquals("the created history has an invalid number of elements", 4, historyContents.size());
    WorkflowInputs workflowInputs = preparedWorkflow.getWorkflowInputs().getInputsObject();
    assertNotNull("created workflowInputs is null", workflowInputs);
    Map<String, Object> toolParameters = workflowInputs.getParameters().get("core_pipeline_outputs_paired_with_parameters");
    assertNotNull("toolParameters is null", toolParameters);
    String coverageMinValue = (String) toolParameters.get("coverageMin");
    assertEquals("coverageMinValue should have been changed to default", "10", coverageMinValue);
    assertEquals("coverageMidValue should have been changed to default", ImmutableMap.of("coverageMid", "10"), toolParameters.get("conditional"));
    String coverageMaxValue = (String) toolParameters.get("coverageMin");
    assertEquals("coverageMaxValue should have been changed to default", "10", coverageMaxValue);
}
Also used : Path(java.nio.file.Path) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) HistoryContents(com.github.jmchilton.blend4j.galaxy.beans.HistoryContents) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) WorkflowInputs(com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputs) Workflow(com.github.jmchilton.blend4j.galaxy.beans.Workflow) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) History(com.github.jmchilton.blend4j.galaxy.beans.History) WorkflowInputsGalaxy(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy) HistoriesClient(com.github.jmchilton.blend4j.galaxy.HistoriesClient) WorkflowsClient(com.github.jmchilton.blend4j.galaxy.WorkflowsClient) PreparedWorkflowGalaxy(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.PreparedWorkflowGalaxy) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 13 with Workflow

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

the class AnalysisWorkspaceServiceGalaxyIT method testGetAnalysisResultsPhylogenomicsSuccess.

/**
 * Tests out successfully getting results for an analysis (phylogenomics).
 *
 * @throws InterruptedException
 * @throws ExecutionManagerException
 * @throws IridaWorkflowNotFoundException
 * @throws IOException
 * @throws IridaWorkflowAnalysisTypeException
 * @throws TimeoutException
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testGetAnalysisResultsPhylogenomicsSuccess() throws InterruptedException, ExecutionManagerException, IridaWorkflowNotFoundException, IOException, IridaWorkflowAnalysisTypeException, TimeoutException {
    History history = new History();
    history.setName("testGetAnalysisResultsPhylogenomicsSuccess");
    HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
    WorkflowsClient workflowsClient = localGalaxy.getGalaxyInstanceAdmin().getWorkflowsClient();
    ToolsClient toolsClient = localGalaxy.getGalaxyInstanceAdmin().getToolsClient();
    History createdHistory = historiesClient.create(history);
    // upload test outputs
    uploadFileToHistory(sequenceFilePathA, TABLE_NAME, createdHistory.getId(), toolsClient);
    uploadFileToHistory(sequenceFilePathA, MATRIX_NAME, createdHistory.getId(), toolsClient);
    uploadFileToHistory(sequenceFilePathA, TREE_NAME, createdHistory.getId(), toolsClient);
    // wait for history
    Util.waitUntilHistoryComplete(createdHistory.getId(), galaxyHistoriesService, 60);
    IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(phylogenomicsWorkflowId);
    Path workflowPath = iridaWorkflow.getWorkflowStructure().getWorkflowFile();
    String workflowString = new String(Files.readAllBytes(workflowPath), StandardCharsets.UTF_8);
    Workflow galaxyWorkflow = workflowsClient.importWorkflow(workflowString);
    AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupSubmissionInDatabase(1L, sequenceFilePathA, referenceFilePath, phylogenomicsWorkflowId, false);
    analysisSubmission.setRemoteAnalysisId(createdHistory.getId());
    analysisSubmission.setRemoteWorkflowId(galaxyWorkflow.getId());
    analysisSubmission.setAnalysisState(AnalysisState.COMPLETING);
    analysisSubmissionRepository.save(analysisSubmission);
    Analysis analysis = analysisWorkspaceService.getAnalysisResults(analysisSubmission);
    assertNotNull("the analysis results were not properly created", analysis);
    assertEquals("the Analysis results class is invalid", AnalysisType.PHYLOGENOMICS, analysis.getAnalysisType());
    assertEquals("the analysis results has an invalid number of output files", 3, analysis.getAnalysisOutputFiles().size());
    assertEquals("the analysis results output file has an invalid name", Paths.get(TABLE_NAME), analysis.getAnalysisOutputFile(TABLE_KEY).getFile().getFileName());
    assertEquals("the analysis results output file has an invalid label", TABLE_NAME, analysis.getAnalysisOutputFile(TABLE_KEY).getLabel());
    assertEquals("the analysis results output file has an invalid name", Paths.get(MATRIX_NAME), analysis.getAnalysisOutputFile(MATRIX_KEY).getFile().getFileName());
    assertEquals("the analysis results output file has an invalid label", MATRIX_NAME, analysis.getAnalysisOutputFile(MATRIX_KEY).getLabel());
    assertEquals("the analysis results output file has an invalid name", Paths.get(TREE_NAME), analysis.getAnalysisOutputFile(TREE_KEY).getFile().getFileName());
    assertEquals("the analysis results output file has an invalid label", TREE_NAME, analysis.getAnalysisOutputFile(TREE_KEY).getLabel());
}
Also used : Path(java.nio.file.Path) WorkflowsClient(com.github.jmchilton.blend4j.galaxy.WorkflowsClient) ToolsClient(com.github.jmchilton.blend4j.galaxy.ToolsClient) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) Workflow(com.github.jmchilton.blend4j.galaxy.beans.Workflow) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) History(com.github.jmchilton.blend4j.galaxy.beans.History) HistoriesClient(com.github.jmchilton.blend4j.galaxy.HistoriesClient) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 14 with Workflow

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

the class AnalysisWorkspaceServiceGalaxyIT method testGetAnalysisResultsTestAnalysisFail.

/**
 * Tests out failing to get results for an analysis (missing output file).
 *
 * @throws InterruptedException
 * @throws ExecutionManagerException
 * @throws IridaWorkflowNotFoundException
 * @throws IOException
 * @throws IridaWorkflowAnalysisTypeException
 * @throws TimeoutException
 */
@Test(expected = GalaxyDatasetNotFoundException.class)
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testGetAnalysisResultsTestAnalysisFail() throws InterruptedException, ExecutionManagerException, IridaWorkflowNotFoundException, IOException, IridaWorkflowAnalysisTypeException, TimeoutException {
    History history = new History();
    history.setName("testGetAnalysisResultsTestAnalysisFail");
    HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
    WorkflowsClient workflowsClient = localGalaxy.getGalaxyInstanceAdmin().getWorkflowsClient();
    ToolsClient toolsClient = localGalaxy.getGalaxyInstanceAdmin().getToolsClient();
    History createdHistory = historiesClient.create(history);
    // upload test outputs
    uploadFileToHistory(sequenceFilePathA, OUTPUT1_NAME, createdHistory.getId(), toolsClient);
    // wait for history
    Util.waitUntilHistoryComplete(createdHistory.getId(), galaxyHistoriesService, 60);
    IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(validWorkflowIdSingle);
    Path workflowPath = iridaWorkflow.getWorkflowStructure().getWorkflowFile();
    String workflowString = new String(Files.readAllBytes(workflowPath), StandardCharsets.UTF_8);
    Workflow galaxyWorkflow = workflowsClient.importWorkflow(workflowString);
    AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupSubmissionInDatabase(1L, sequenceFilePathA, referenceFilePath, validWorkflowIdSingle, false);
    analysisSubmission.setRemoteAnalysisId(createdHistory.getId());
    analysisSubmission.setRemoteWorkflowId(galaxyWorkflow.getId());
    analysisSubmission.setAnalysisState(AnalysisState.COMPLETING);
    analysisSubmissionRepository.save(analysisSubmission);
    analysisWorkspaceService.getAnalysisResults(analysisSubmission);
}
Also used : Path(java.nio.file.Path) WorkflowsClient(com.github.jmchilton.blend4j.galaxy.WorkflowsClient) ToolsClient(com.github.jmchilton.blend4j.galaxy.ToolsClient) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) Workflow(com.github.jmchilton.blend4j.galaxy.beans.Workflow) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) History(com.github.jmchilton.blend4j.galaxy.beans.History) HistoriesClient(com.github.jmchilton.blend4j.galaxy.HistoriesClient) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 15 with Workflow

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

the class AnalysisWorkspaceServiceGalaxyIT method testGetAnalysisResultsTestAnalysisDeleteSampleRunningSuccess.

/**
 * Tests out successfully getting results for an analysis (TestAnalysis)
 * when sequencing objects are present, but the sample was deleted while pipeline was running.
 *
 * @throws InterruptedException
 * @throws ExecutionManagerException
 * @throws IridaWorkflowNotFoundException
 * @throws IOException
 * @throws IridaWorkflowAnalysisTypeException
 * @throws TimeoutException
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testGetAnalysisResultsTestAnalysisDeleteSampleRunningSuccess() throws InterruptedException, ExecutionManagerException, IridaWorkflowNotFoundException, IOException, IridaWorkflowAnalysisTypeException, TimeoutException {
    History history = new History();
    history.setName("testGetAnalysisResultsTestAnalysisDeleteSampleRunningSuccess");
    HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
    WorkflowsClient workflowsClient = localGalaxy.getGalaxyInstanceAdmin().getWorkflowsClient();
    ToolsClient toolsClient = localGalaxy.getGalaxyInstanceAdmin().getToolsClient();
    History createdHistory = historiesClient.create(history);
    // upload test outputs
    uploadFileToHistory(sequenceFilePathA, OUTPUT1_NAME, createdHistory.getId(), toolsClient);
    uploadFileToHistory(sequenceFilePathA, OUTPUT2_NAME, createdHistory.getId(), toolsClient);
    // wait for history
    Util.waitUntilHistoryComplete(createdHistory.getId(), galaxyHistoriesService, 60);
    IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(validWorkflowIdPairedSingleSample);
    Path workflowPath = iridaWorkflow.getWorkflowStructure().getWorkflowFile();
    String workflowString = new String(Files.readAllBytes(workflowPath), StandardCharsets.UTF_8);
    Workflow galaxyWorkflow = workflowsClient.importWorkflow(workflowString);
    List<Path> paths1 = new ArrayList<>();
    paths1.add(sequenceFilePathA);
    List<Path> paths2 = new ArrayList<>();
    paths2.add(sequenceFilePath2A);
    AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupPairSubmissionInDatabase(1L, paths1, paths2, referenceFilePath, validWorkflowIdPairedSingleSample, false);
    sampleRepository.delete(1L);
    assertTrue(!sampleService.exists(1L));
    analysisSubmission.setRemoteAnalysisId(createdHistory.getId());
    analysisSubmission.setRemoteWorkflowId(galaxyWorkflow.getId());
    analysisSubmission.setAnalysisState(AnalysisState.COMPLETING);
    analysisSubmissionRepository.save(analysisSubmission);
    Analysis analysis = analysisWorkspaceService.getAnalysisResults(analysisSubmission);
    assertNotNull("the analysis results were not properly created", analysis);
    assertEquals("the Analysis results class is invalid", Analysis.class, analysis.getClass());
    assertEquals("the analysis results has an invalid number of output files", 2, analysis.getAnalysisOutputFiles().size());
    assertEquals("the analysis results output file has an invalid name", Paths.get(OUTPUT1_NAME), analysis.getAnalysisOutputFile(OUTPUT1_KEY).getFile().getFileName());
    assertEquals("the analysis results output file has an invalid label", OUTPUT1_NAME, analysis.getAnalysisOutputFile(OUTPUT1_KEY).getLabel());
    assertEquals("the analysis results output file has an invalid name", Paths.get(OUTPUT2_NAME), analysis.getAnalysisOutputFile(OUTPUT2_KEY).getFile().getFileName());
    assertEquals("the analysis results output file has an invalid label", OUTPUT2_NAME, analysis.getAnalysisOutputFile(OUTPUT2_KEY).getLabel());
}
Also used : Path(java.nio.file.Path) WorkflowsClient(com.github.jmchilton.blend4j.galaxy.WorkflowsClient) ToolsClient(com.github.jmchilton.blend4j.galaxy.ToolsClient) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) ArrayList(java.util.ArrayList) Workflow(com.github.jmchilton.blend4j.galaxy.beans.Workflow) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) History(com.github.jmchilton.blend4j.galaxy.beans.History) HistoriesClient(com.github.jmchilton.blend4j.galaxy.HistoriesClient) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

Workflow (com.github.jmchilton.blend4j.galaxy.beans.Workflow)20 WorkflowsClient (com.github.jmchilton.blend4j.galaxy.WorkflowsClient)19 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)18 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)18 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)18 History (com.github.jmchilton.blend4j.galaxy.beans.History)18 Path (java.nio.file.Path)18 Test (org.junit.Test)18 WithMockUser (org.springframework.security.test.context.support.WithMockUser)18 ToolsClient (com.github.jmchilton.blend4j.galaxy.ToolsClient)8 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)7 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)6 PreparedWorkflowGalaxy (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.PreparedWorkflowGalaxy)6 HistoryContents (com.github.jmchilton.blend4j.galaxy.beans.HistoryContents)6 ArrayList (java.util.ArrayList)6 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)5 WorkflowInputsGalaxy (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy)5 SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)3 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)3 WorkflowInputs (com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputs)3