Search in sources :

Example 6 with WorkflowDetails

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

the class AnalysisExecutionServiceGalaxyIT method testCleanupCompletedAnalysisSuccess.

/**
 * Tests out cleaning up a completed analysis successfully.
 *
 * @throws Exception
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testCleanupCompletedAnalysisSuccess() throws Exception {
    AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupSubmissionInDatabase(1L, sequenceFilePath, referenceFilePath, iridaTestAnalysisWorkflowId, false);
    Future<AnalysisSubmission> analysisSubmittedFuture = analysisExecutionService.prepareSubmission(analysisSubmission);
    AnalysisSubmission analysisSubmitted = analysisSubmittedFuture.get();
    Future<AnalysisSubmission> analysisExecutionFuture = analysisExecutionService.executeAnalysis(analysisSubmitted);
    AnalysisSubmission analysisExecuted = analysisExecutionFuture.get();
    analysisExecutionGalaxyITService.waitUntilSubmissionComplete(analysisExecuted);
    analysisExecuted.setAnalysisState(AnalysisState.FINISHED_RUNNING);
    Future<AnalysisSubmission> analysisSubmissionCompletedFuture = analysisExecutionService.transferAnalysisResults(analysisExecuted);
    AnalysisSubmission analysisSubmissionCompleted = analysisSubmissionCompletedFuture.get();
    assertEquals(AnalysisState.COMPLETED, analysisSubmissionCompleted.getAnalysisState());
    assertEquals(AnalysisCleanedState.NOT_CLEANED, analysisSubmissionCompleted.getAnalysisCleanedState());
    WorkflowDetails workflowDetails = workflowsClient.showWorkflow(analysisSubmissionCompleted.getRemoteWorkflowId());
    assertFalse("Workflow is already deleted", workflowDetails.isDeleted());
    // Once analysis is complete, attempt to clean up
    Future<AnalysisSubmission> analysisSubmissionCleanedFuture = analysisExecutionService.cleanupSubmission(analysisSubmissionCompleted);
    AnalysisSubmission analysisSubmissionCleaned = analysisSubmissionCleanedFuture.get();
    assertEquals("Analysis submission not properly cleaned", AnalysisCleanedState.CLEANED, analysisSubmissionCleaned.getAnalysisCleanedState());
    workflowDetails = workflowsClient.showWorkflow(analysisSubmissionCompleted.getRemoteWorkflowId());
    assertTrue("Workflow is not deleted", workflowDetails.isDeleted());
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) WorkflowDetails(com.github.jmchilton.blend4j.galaxy.beans.WorkflowDetails) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 7 with WorkflowDetails

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

the class AnalysisWorkspaceServiceGalaxy method prepareAnalysisFiles.

/**
 * {@inheritDoc}
 */
@Override
public PreparedWorkflowGalaxy prepareAnalysisFiles(AnalysisSubmission analysisSubmission) throws ExecutionManagerException, IridaWorkflowException {
    checkNotNull(analysisSubmission, "analysisSubmission is null");
    checkNotNull(analysisSubmission.getRemoteAnalysisId(), "analysisId is null");
    checkNotNull(analysisSubmission.getWorkflowId(), "workflowId is null");
    checkNotNull(analysisSubmission.getRemoteWorkflowId(), "remoteWorkflowId is null");
    IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(analysisSubmission.getWorkflowId());
    IridaWorkflowInput workflowInput = iridaWorkflow.getWorkflowDescription().getInputs();
    Set<SingleEndSequenceFile> singleEndFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SingleEndSequenceFile.class);
    Set<SequenceFilePair> pairedEndFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SequenceFilePair.class);
    if (iridaWorkflow.getWorkflowDescription().requiresReference()) {
        checkArgument(analysisSubmission.getReferenceFile().isPresent(), "workflow requires reference but none defined in submission");
    } else {
        checkArgument(!analysisSubmission.getReferenceFile().isPresent(), "workflow does not require a reference and a reference file is set in the submission");
    }
    if (!iridaWorkflow.getWorkflowDescription().acceptsSingleSequenceFiles()) {
        checkArgument(singleEndFiles.isEmpty(), "workflow does not accept single sequence files, but single sequence files are passed as input to " + analysisSubmission);
    }
    if (!iridaWorkflow.getWorkflowDescription().acceptsPairedSequenceFiles()) {
        checkArgument(pairedEndFiles.isEmpty(), "workflow does not accept paired sequence files, but paired sequence files are passed as input to " + analysisSubmission);
    }
    String temporaryLibraryName = AnalysisSubmission.class.getSimpleName() + "-" + UUID.randomUUID().toString();
    History workflowHistory = galaxyHistoriesService.findById(analysisSubmission.getRemoteAnalysisId());
    Library workflowLibrary = galaxyLibrariesService.buildEmptyLibrary(new GalaxyProjectName(temporaryLibraryName));
    // get unique files for pairs and single files
    Map<Sample, SingleEndSequenceFile> singleFiles = sequencingObjectService.getUniqueSamplesForSequencingObjects(singleEndFiles);
    Map<Sample, SequenceFilePair> pairedFiles = sequencingObjectService.getUniqueSamplesForSequencingObjects(pairedEndFiles);
    // check that there aren't common sample names between single and paired
    if (samplesInCommon(singleFiles, pairedFiles)) {
        throw new SampleAnalysisDuplicateException("Single and paired input files share a common sample for submission " + analysisSubmission);
    }
    String workflowId = analysisSubmission.getRemoteWorkflowId();
    WorkflowDetails workflowDetails = galaxyWorkflowService.getWorkflowDetails(workflowId);
    WorkflowInputsGalaxy workflowInputsGalaxy = analysisParameterServiceGalaxy.prepareAnalysisParameters(analysisSubmission.getInputParameters(), iridaWorkflow);
    WorkflowInputs inputs = workflowInputsGalaxy.getInputsObject();
    inputs.setDestination(new WorkflowInputs.ExistingHistory(workflowHistory.getId()));
    inputs.setWorkflowId(workflowDetails.getId());
    if (!singleFiles.isEmpty()) {
        String sequenceFilesLabelSingle = workflowInput.getSequenceReadsSingle().get();
        String workflowSequenceFileSingleInputId = galaxyWorkflowService.getWorkflowInputId(workflowDetails, sequenceFilesLabelSingle);
        CollectionResponse collectionResponseSingle = analysisCollectionServiceGalaxy.uploadSequenceFilesSingleEnd(singleFiles, workflowHistory, workflowLibrary);
        inputs.setInput(workflowSequenceFileSingleInputId, new WorkflowInputs.WorkflowInput(collectionResponseSingle.getId(), WorkflowInputs.InputSourceType.HDCA));
    }
    if (!pairedFiles.isEmpty()) {
        String sequenceFilesLabelPaired = workflowInput.getSequenceReadsPaired().get();
        String workflowSequenceFilePairedInputId = galaxyWorkflowService.getWorkflowInputId(workflowDetails, sequenceFilesLabelPaired);
        CollectionResponse collectionResponsePaired = analysisCollectionServiceGalaxy.uploadSequenceFilesPaired(pairedFiles, workflowHistory, workflowLibrary);
        inputs.setInput(workflowSequenceFilePairedInputId, new WorkflowInputs.WorkflowInput(collectionResponsePaired.getId(), WorkflowInputs.InputSourceType.HDCA));
    }
    String analysisId = workflowHistory.getId();
    if (iridaWorkflow.getWorkflowDescription().requiresReference()) {
        String referenceFileLabel = workflowInput.getReference().get();
        prepareReferenceFile(analysisSubmission.getReferenceFile().get(), workflowHistory, referenceFileLabel, workflowDetails, inputs);
    }
    return new PreparedWorkflowGalaxy(analysisId, workflowLibrary.getId(), new WorkflowInputsGalaxy(inputs));
}
Also used : IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) IridaWorkflowInput(ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowInput) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) CollectionResponse(com.github.jmchilton.blend4j.galaxy.beans.collection.response.CollectionResponse) WorkflowInputs(com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputs) GalaxyProjectName(ca.corefacility.bioinformatics.irida.model.upload.galaxy.GalaxyProjectName) History(com.github.jmchilton.blend4j.galaxy.beans.History) WorkflowInputsGalaxy(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) SampleAnalysisDuplicateException(ca.corefacility.bioinformatics.irida.exceptions.SampleAnalysisDuplicateException) WorkflowDetails(com.github.jmchilton.blend4j.galaxy.beans.WorkflowDetails) PreparedWorkflowGalaxy(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.PreparedWorkflowGalaxy) Library(com.github.jmchilton.blend4j.galaxy.beans.Library)

Example 8 with WorkflowDetails

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

the class GalaxyWorkflowServiceTest method testGetWorkflowInputIdValid.

/**
 * Tests getting a valid workflow input id from a workflow details.
 * @throws WorkflowException
 */
@Test
public void testGetWorkflowInputIdValid() throws WorkflowException {
    WorkflowDetails details = new WorkflowDetails();
    WorkflowInputDefinition validDefinition = new WorkflowInputDefinition();
    validDefinition.setLabel("valid");
    Map<String, WorkflowInputDefinition> workflowInputMap = new HashMap<>();
    workflowInputMap.put("validInputId", validDefinition);
    details.setInputs(workflowInputMap);
    assertEquals("validInputId", galaxyWorkflowService.getWorkflowInputId(details, "valid"));
}
Also used : WorkflowInputDefinition(com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputDefinition) HashMap(java.util.HashMap) WorkflowDetails(com.github.jmchilton.blend4j.galaxy.beans.WorkflowDetails) Test(org.junit.Test)

Example 9 with WorkflowDetails

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

the class GalaxyWorkflowServiceTest method testGetWorkflowInputIdInvalid.

/**
 * Tests failing to find a valid workflow input id from a workflow details.
 * @throws WorkflowException
 */
@Test(expected = WorkflowException.class)
public void testGetWorkflowInputIdInvalid() throws WorkflowException {
    WorkflowDetails details = new WorkflowDetails();
    WorkflowInputDefinition validDefinition = new WorkflowInputDefinition();
    validDefinition.setLabel("valid");
    Map<String, WorkflowInputDefinition> workflowInputMap = new HashMap<>();
    workflowInputMap.put("validInputId", validDefinition);
    details.setInputs(workflowInputMap);
    galaxyWorkflowService.getWorkflowInputId(details, "invalid");
}
Also used : WorkflowInputDefinition(com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputDefinition) HashMap(java.util.HashMap) WorkflowDetails(com.github.jmchilton.blend4j.galaxy.beans.WorkflowDetails) Test(org.junit.Test)

Aggregations

WorkflowDetails (com.github.jmchilton.blend4j.galaxy.beans.WorkflowDetails)9 Test (org.junit.Test)5 WorkflowInputs (com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputs)4 Dataset (com.github.jmchilton.blend4j.galaxy.beans.Dataset)3 History (com.github.jmchilton.blend4j.galaxy.beans.History)3 WorkflowOutputs (com.github.jmchilton.blend4j.galaxy.beans.WorkflowOutputs)3 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)2 WorkflowInputDefinition (com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputDefinition)2 CollectionResponse (com.github.jmchilton.blend4j.galaxy.beans.collection.response.CollectionResponse)2 HashMap (java.util.HashMap)2 WithMockUser (org.springframework.security.test.context.support.WithMockUser)2 SampleAnalysisDuplicateException (ca.corefacility.bioinformatics.irida.exceptions.SampleAnalysisDuplicateException)1 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)1 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)1 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)1 GalaxyProjectName (ca.corefacility.bioinformatics.irida.model.upload.galaxy.GalaxyProjectName)1 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)1 IridaWorkflowInput (ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowInput)1 PreparedWorkflowGalaxy (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.PreparedWorkflowGalaxy)1 WorkflowInputsGalaxy (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy)1