Search in sources :

Example 36 with Analysis

use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis in project irida by phac-nml.

the class AnalysisWorkspaceServiceGalaxyTest method testGetAnalysisResultsSuccessSingleEnd.

/**
 * Tests successfully getting analysis results from Galaxy with single end
 * input files.
 *
 * @throws IridaWorkflowNotFoundException
 * @throws IOException
 * @throws ExecutionManagerException
 * @throws IridaWorkflowAnalysisTypeException
 */
@Test
public void testGetAnalysisResultsSuccessSingleEnd() throws IridaWorkflowNotFoundException, IridaWorkflowAnalysisTypeException, ExecutionManagerException, IOException {
    Set<SingleEndSequenceFile> singleFiles = Sets.newHashSet(sampleSingleSequenceFileMap.values());
    submission = AnalysisSubmission.builder(workflowId).name("my analysis").inputFiles(singleInputFiles).referenceFile(referenceFile).build();
    submission.setRemoteWorkflowId(WORKFLOW_ID);
    submission.setRemoteAnalysisId(HISTORY_ID);
    when(sequencingObjectService.getSequencingObjectsForAnalysisSubmission(submission)).thenReturn(Sets.newHashSet(singleFiles));
    when(iridaWorkflowsService.getIridaWorkflow(workflowId)).thenReturn(iridaWorkflowSingle);
    when(galaxyHistoriesService.getDatasetForFileInHistory(output1Filename, HISTORY_ID)).thenReturn(output1Dataset);
    when(galaxyHistoriesService.getDatasetForFileInHistory(output2Filename, HISTORY_ID)).thenReturn(output2Dataset);
    when(sequencingObjectService.getUniqueSamplesForSequencingObjects(singleFiles)).thenReturn(sampleSingleSequenceFileMap);
    Analysis analysis = workflowPreparation.getAnalysisResults(submission);
    assertNotNull("analysis is not valid", analysis);
    assertEquals("invalid number of output files", 2, analysis.getAnalysisOutputFiles().size());
    assertEquals("missing output file for analysis", Paths.get("output1.txt"), analysis.getAnalysisOutputFile("output1").getFile().getFileName());
    assertEquals("missing label for analysis output file", "SampleA-output1.txt", analysis.getAnalysisOutputFile("output1").getLabel());
    assertEquals("missing output file for analysis", "SampleA-output2.txt", analysis.getAnalysisOutputFile("output2").getLabel());
    verify(galaxyHistoriesService).getDatasetForFileInHistory("output1.txt", HISTORY_ID);
    verify(galaxyHistoriesService).getDatasetForFileInHistory("output2.txt", HISTORY_ID);
}
Also used : Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Test(org.junit.Test)

Example 37 with Analysis

use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis in project irida by phac-nml.

the class TestDataFactory method constructAnalysis.

public static Analysis constructAnalysis() {
    Map<String, AnalysisOutputFile> analysisOutputFiles = new ImmutableMap.Builder<String, AnalysisOutputFile>().put("tree", constructAnalysisOutputFile("snp_tree.tree", null)).put("matrix", constructAnalysisOutputFile("test_file_1.fastq", null)).put("table", constructAnalysisOutputFile("test_file_2.fastq", null)).put("contigs-with-repeats", constructAnalysisOutputFile("test_file.fasta", null)).put("refseq-masher-matches", constructAnalysisOutputFile("refseq-masher-matches.tsv", 9000L)).build();
    Analysis analysis = new Analysis(FAKE_EXECUTION_MANAGER_ID, analysisOutputFiles, AnalysisType.PHYLOGENOMICS);
    return analysis;
}
Also used : GenomeAssemblyFromAnalysis(ca.corefacility.bioinformatics.irida.model.assembly.GenomeAssemblyFromAnalysis) Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) AnalysisOutputFile(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile)

Example 38 with Analysis

use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis in project irida by phac-nml.

the class AnalysisWorkspaceServiceGalaxyTest method testGetAnalysisResultsSuccessMultiSample.

/**
 * Tests successfully getting analysis results from Galaxy where there's
 * multiple samples but workflow should have only accepted single sample (no
 * label on name).
 *
 * @throws IridaWorkflowNotFoundException
 * @throws IOException
 * @throws ExecutionManagerException
 * @throws IridaWorkflowAnalysisTypeException
 */
@Test
public void testGetAnalysisResultsSuccessMultiSample() throws IridaWorkflowNotFoundException, IridaWorkflowAnalysisTypeException, ExecutionManagerException, IOException {
    Set<SingleEndSequenceFile> singleFiles = Sets.newHashSet(sampleSingleSequenceFileMap.values());
    Set<SequenceFilePair> pairedFiles = Sets.newHashSet(sampleSequenceFilePairMap.values());
    submission = AnalysisSubmission.builder(workflowId).name("my analysis").inputFiles(pairedInputFiles).referenceFile(referenceFile).build();
    submission.setRemoteWorkflowId(WORKFLOW_ID);
    submission.setRemoteAnalysisId(HISTORY_ID);
    when(sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(submission, SingleEndSequenceFile.class)).thenReturn(singleFiles);
    when(sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(submission, SequenceFilePair.class)).thenReturn(pairedFiles);
    when(iridaWorkflowsService.getIridaWorkflow(workflowId)).thenReturn(iridaWorkflowSingle);
    when(galaxyHistoriesService.getDatasetForFileInHistory(output1Filename, HISTORY_ID)).thenReturn(output1Dataset);
    when(galaxyHistoriesService.getDatasetForFileInHistory(output2Filename, HISTORY_ID)).thenReturn(output2Dataset);
    when(sequencingObjectService.getUniqueSamplesForSequencingObjects(singleFiles)).thenReturn(sampleSingleSequenceFileMap);
    when(sequencingObjectService.getUniqueSamplesForSequencingObjects(pairedFiles)).thenReturn(sampleSequenceFilePairMap);
    Analysis analysis = workflowPreparation.getAnalysisResults(submission);
    assertNotNull("analysis is not valid", analysis);
    assertEquals("invalid number of output files", 2, analysis.getAnalysisOutputFiles().size());
    assertEquals("missing output file for analysis", Paths.get("output1.txt"), analysis.getAnalysisOutputFile("output1").getFile().getFileName());
    // labels should now not have sample associated with them.
    assertEquals("missing label for analysis output file", "output1.txt", analysis.getAnalysisOutputFile("output1").getLabel());
    assertEquals("missing output file for analysis", "output2.txt", analysis.getAnalysisOutputFile("output2").getLabel());
    verify(galaxyHistoriesService).getDatasetForFileInHistory("output1.txt", HISTORY_ID);
    verify(galaxyHistoriesService).getDatasetForFileInHistory("output2.txt", HISTORY_ID);
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Test(org.junit.Test)

Example 39 with Analysis

use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis in project irida by phac-nml.

the class AnalysisWorkspaceServiceGalaxyTest method testGetAnalysisResultsSuccessSinglePairedEnd.

/**
 * Tests successfully getting analysis results from Galaxy with
 * single/paired end input files.
 *
 * @throws IridaWorkflowNotFoundException
 * @throws IOException
 * @throws ExecutionManagerException
 * @throws IridaWorkflowAnalysisTypeException
 */
@Test
public void testGetAnalysisResultsSuccessSinglePairedEnd() throws IridaWorkflowNotFoundException, IridaWorkflowAnalysisTypeException, ExecutionManagerException, IOException {
    Set<SingleEndSequenceFile> singleFiles = Sets.newHashSet(sampleSingleSequenceFileMap.values());
    Set<SequenceFilePair> pairedFiles = Sets.newHashSet(sampleSequenceFilePairMap.values());
    Set<SequencingObject> joinedFiles = Sets.newHashSet(singleFiles);
    joinedFiles.addAll(pairedFiles);
    Map<Sample, SequencingObject> joinedMap = Maps.newHashMap(sampleSingleSequenceFileMap);
    joinedMap.putAll(sampleSequenceFilePairMap);
    submission = AnalysisSubmission.builder(workflowIdMultiSamples).name("my analysis").inputFiles(singleInputFiles).inputFiles(pairedInputFiles).referenceFile(referenceFile).build();
    submission.setRemoteWorkflowId(WORKFLOW_ID);
    submission.setRemoteAnalysisId(HISTORY_ID);
    when(sequencingObjectService.getSequencingObjectsForAnalysisSubmission(submission)).thenReturn(joinedFiles);
    when(iridaWorkflowsService.getIridaWorkflow(workflowIdMultiSamples)).thenReturn(iridaWorkflowSinglePairedMultipleSamples);
    when(galaxyHistoriesService.getDatasetForFileInHistory(output1Filename, HISTORY_ID)).thenReturn(output1Dataset);
    when(galaxyHistoriesService.getDatasetForFileInHistory(output2Filename, HISTORY_ID)).thenReturn(output2Dataset);
    when(sequencingObjectService.getUniqueSamplesForSequencingObjects(joinedFiles)).thenReturn(joinedMap);
    Analysis analysis = workflowPreparation.getAnalysisResults(submission);
    assertNotNull("analysis is not valid", analysis);
    assertEquals("invalid number of output files", 2, analysis.getAnalysisOutputFiles().size());
    assertEquals("missing output file for analysis", Paths.get("output1.txt"), analysis.getAnalysisOutputFile("output1").getFile().getFileName());
    // labels should now not have sample associated with them.
    assertEquals("missing label for analysis output file", "output1.txt", analysis.getAnalysisOutputFile("output1").getLabel());
    assertEquals("missing output file for analysis", "output2.txt", analysis.getAnalysisOutputFile("output2").getLabel());
    verify(galaxyHistoriesService).getDatasetForFileInHistory("output1.txt", HISTORY_ID);
    verify(galaxyHistoriesService).getDatasetForFileInHistory("output2.txt", HISTORY_ID);
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Test(org.junit.Test)

Example 40 with Analysis

use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis in project irida by phac-nml.

the class AnalysisExecutionServiceGalaxyAsync method transferAnalysisResults.

/**
 * Downloads and saves the results of an {@link AnalysisSubmission} that was
 * previously submitted from an execution manager.
 *
 * @param submittedAnalysis
 *            An {@link AnalysisSubmission} that was previously submitted.
 * @return A {@link Future} with an {@link AnalysisSubmission} object
 *         containing information about the particular analysis.
 * @throws ExecutionManagerException
 *             If there was an issue with the execution manager.
 * @throws IridaWorkflowNotFoundException
 *             If the workflow for this submission could not be found in
 *             IRIDA.
 * @throws IOException
 *             If there was an error loading the analysis results from an
 *             execution manager.
 * @throws IridaWorkflowAnalysisTypeException
 *             If there was an issue building an {@link Analysis} object.
 */
@Transactional
public Future<AnalysisSubmission> transferAnalysisResults(AnalysisSubmission submittedAnalysis) throws ExecutionManagerException, IOException, IridaWorkflowNotFoundException, IridaWorkflowAnalysisTypeException {
    checkNotNull(submittedAnalysis, "submittedAnalysis is null");
    checkNotNull(submittedAnalysis.getRemoteAnalysisId(), "remoteAnalysisId is null");
    if (!analysisSubmissionService.exists(submittedAnalysis.getId())) {
        throw new EntityNotFoundException("Could not find analysis submission for " + submittedAnalysis);
    }
    logger.debug("Getting results for " + submittedAnalysis);
    Analysis analysisResults = workspaceService.getAnalysisResults(submittedAnalysis);
    logger.trace("Saving results for " + submittedAnalysis);
    Analysis savedAnalysis = analysisService.create(analysisResults);
    // if samples should be updated, set to TRANSFERRED.  Otherwise just complete.
    if (submittedAnalysis.getUpdateSamples()) {
        submittedAnalysis.setAnalysisState(AnalysisState.TRANSFERRED);
    } else {
        submittedAnalysis.setAnalysisState(AnalysisState.COMPLETED);
    }
    try {
        submittedAnalysis.setAnalysis(savedAnalysis);
    } catch (AnalysisAlreadySetException e) {
        throw new ExecutionManagerException("Analysis already set", e);
    }
    AnalysisSubmission completedSubmission = analysisSubmissionService.update(submittedAnalysis);
    return new AsyncResult<>(completedSubmission);
}
Also used : Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) AnalysisAlreadySetException(ca.corefacility.bioinformatics.irida.exceptions.AnalysisAlreadySetException) EntityNotFoundException(ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException) AsyncResult(org.springframework.scheduling.annotation.AsyncResult) ExecutionManagerException(ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)41 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)30 Test (org.junit.Test)28 AnalysisOutputFile (ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile)21 WithMockUser (org.springframework.security.test.context.support.WithMockUser)19 Path (java.nio.file.Path)17 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)14 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)12 ToolExecution (ca.corefacility.bioinformatics.irida.model.workflow.analysis.ToolExecution)12 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)11 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)9 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)7 ToolsClient (com.github.jmchilton.blend4j.galaxy.ToolsClient)7 WorkflowsClient (com.github.jmchilton.blend4j.galaxy.WorkflowsClient)7 History (com.github.jmchilton.blend4j.galaxy.beans.History)7 Workflow (com.github.jmchilton.blend4j.galaxy.beans.Workflow)7 EntityNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException)6 AnalysisType (ca.corefacility.bioinformatics.irida.model.enums.AnalysisType)5 Scanner (java.util.Scanner)5 ExecutionManagerException (ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)4