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);
}
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;
}
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);
}
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);
}
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);
}
Aggregations