use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis 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());
}
use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis 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());
}
use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyIT method testGetAnalysisResultsTestAnalysisSinglePairedSuccess.
/**
* Tests out successfully getting results for an analysis (TestAnalysis)
* consisting of both single and paired sequence reads.
*
* @throws InterruptedException
* @throws ExecutionManagerException
* @throws IridaWorkflowNotFoundException
* @throws IOException
* @throws IridaWorkflowAnalysisTypeException
* @throws TimeoutException
*/
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testGetAnalysisResultsTestAnalysisSinglePairedSuccess() throws InterruptedException, ExecutionManagerException, IridaWorkflowNotFoundException, IOException, IridaWorkflowAnalysisTypeException, TimeoutException {
History history = new History();
history.setName("testGetAnalysisResultsTestAnalysisSinglePairedSuccess");
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(validWorkflowIdSinglePaired);
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.setupSinglePairSubmissionInDatabaseSameSample(1L, paths1, paths2, sequenceFilePath3, referenceFilePath, validWorkflowIdSinglePaired);
Set<SingleEndSequenceFile> singleFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SingleEndSequenceFile.class);
Set<SequenceFilePair> pairedFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SequenceFilePair.class);
assertEquals("invalid number of single end input files", 1, singleFiles.size());
assertEquals("invalid number of paired end inputs", 1, pairedFiles.size());
SequenceFilePair submittedSp = pairedFiles.iterator().next();
Set<SequenceFile> submittedSf = submittedSp.getFiles();
assertEquals("invalid number of files for paired input", 2, submittedSf.size());
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());
}
use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyTest method testGetAnalysisResultsSuccessNoSample.
/**
* Tests successfully getting analysis results from Galaxy where there's no
* sample associated with the sequence files (no label is prefixed to output
* file name).
*
* @throws IridaWorkflowNotFoundException
* @throws IOException
* @throws ExecutionManagerException
* @throws IridaWorkflowAnalysisTypeException
*/
@Test
public void testGetAnalysisResultsSuccessNoSample() throws IridaWorkflowNotFoundException, IridaWorkflowAnalysisTypeException, ExecutionManagerException, IOException {
submission = AnalysisSubmission.builder(workflowId).name("my analysis").inputFiles(pairedInputFiles).referenceFile(referenceFile).build();
submission.setRemoteWorkflowId(WORKFLOW_ID);
submission.setRemoteAnalysisId(HISTORY_ID);
when(iridaWorkflowsService.getIridaWorkflow(workflowId)).thenReturn(iridaWorkflowSingle);
when(galaxyHistoriesService.getDatasetForFileInHistory(output1Filename, HISTORY_ID)).thenReturn(output1Dataset);
when(galaxyHistoriesService.getDatasetForFileInHistory(output2Filename, HISTORY_ID)).thenReturn(output2Dataset);
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 testGetAnalysisResultsSuccessPairedEnd.
/**
* Tests successfully getting analysis results from Galaxy with paired end
* input files.
*
* @throws IridaWorkflowNotFoundException
* @throws IOException
* @throws ExecutionManagerException
* @throws IridaWorkflowAnalysisTypeException
*/
@Test
public void testGetAnalysisResultsSuccessPairedEnd() throws IridaWorkflowNotFoundException, IridaWorkflowAnalysisTypeException, ExecutionManagerException, IOException {
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(iridaWorkflowsService.getIridaWorkflow(workflowId)).thenReturn(iridaWorkflowSingle);
when(galaxyHistoriesService.getDatasetForFileInHistory(output1Filename, HISTORY_ID)).thenReturn(output1Dataset);
when(galaxyHistoriesService.getDatasetForFileInHistory(output2Filename, HISTORY_ID)).thenReturn(output2Dataset);
when(sequencingObjectService.getSequencingObjectsForAnalysisSubmission(submission)).thenReturn(Sets.newHashSet(pairedFiles));
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());
assertEquals("missing label for analysis output file", "SampleB-output1.txt", analysis.getAnalysisOutputFile("output1").getLabel());
assertEquals("missing output file for analysis", "SampleB-output2.txt", analysis.getAnalysisOutputFile("output2").getLabel());
verify(galaxyHistoriesService).getDatasetForFileInHistory("output1.txt", HISTORY_ID);
verify(galaxyHistoriesService).getDatasetForFileInHistory("output2.txt", HISTORY_ID);
}
Aggregations