use of ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyIT method testGetAnalysisResultsTestAnalysisPairedSingleSampleSuccess.
/**
* Tests out successfully getting results for an analysis (TestAnalysis)
* consisting only of paired sequence reads.
*
* @throws InterruptedException
* @throws ExecutionManagerException
* @throws IridaWorkflowNotFoundException
* @throws IOException
* @throws IridaWorkflowAnalysisTypeException
* @throws TimeoutException
*/
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testGetAnalysisResultsTestAnalysisPairedSingleSampleSuccess() throws InterruptedException, ExecutionManagerException, IridaWorkflowNotFoundException, IOException, IridaWorkflowAnalysisTypeException, TimeoutException {
History history = new History();
history.setName("testGetAnalysisResultsTestAnalysisPairedSingleSampleSuccess");
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);
Set<SingleEndSequenceFile> submittedSingleFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SingleEndSequenceFile.class);
Set<SequenceFilePair> pairedFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SequenceFilePair.class);
assertEquals("the created submission should have no single input files", 0, submittedSingleFiles.size());
assertEquals("the created submission has an invalid number of paired input files", 1, pairedFiles.size());
SequenceFilePair submittedSp = pairedFiles.iterator().next();
Set<SequenceFile> submittedSf = submittedSp.getFiles();
assertEquals("the paired input should have 2 files", 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", SAMPLE1_NAME + "-" + 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", SAMPLE1_NAME + "-" + OUTPUT2_NAME, analysis.getAnalysisOutputFile(OUTPUT2_KEY).getLabel());
}
use of ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyIT method testPrepareAnalysisFilesSingleFail.
/**
* Tests out failing to prepare single workflow input files for execution
* (duplicate samples).
*
* @throws InterruptedException
* @throws ExecutionManagerException
* @throws IOException
* @throws IridaWorkflowException
*/
@Test(expected = DuplicateSampleException.class)
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testPrepareAnalysisFilesSingleFail() throws InterruptedException, ExecutionManagerException, IOException, IridaWorkflowException {
History history = new History();
history.setName("testPrepareAnalysisFilesSingleFail");
HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
WorkflowsClient workflowsClient = localGalaxy.getGalaxyInstanceAdmin().getWorkflowsClient();
History createdHistory = historiesClient.create(history);
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);
List<SingleEndSequenceFile> sequenceFiles = analysisExecutionGalaxyITService.setupSequencingObjectInDatabase(1L, sequenceFilePathA, sequenceFilePath2A);
AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupSubmissionInDatabase(1L, Sets.newHashSet(sequenceFiles), referenceFilePath, validWorkflowIdSingle);
analysisSubmission.setRemoteAnalysisId(createdHistory.getId());
analysisSubmission.setRemoteWorkflowId(galaxyWorkflow.getId());
analysisWorkspaceService.prepareAnalysisFiles(analysisSubmission);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyIT method testGetAnalysisResultsTestAnalysisPairedSuccess.
/**
* Tests out successfully getting results for an analysis (TestAnalysis)
* consisting only of paired sequence reads.
*
* @throws InterruptedException
* @throws ExecutionManagerException
* @throws IridaWorkflowNotFoundException
* @throws IOException
* @throws IridaWorkflowAnalysisTypeException
* @throws TimeoutException
*/
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testGetAnalysisResultsTestAnalysisPairedSuccess() throws InterruptedException, ExecutionManagerException, IridaWorkflowNotFoundException, IOException, IridaWorkflowAnalysisTypeException, TimeoutException {
History history = new History();
history.setName("testGetAnalysisResultsTestAnalysisPairedSuccess");
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(validWorkflowIdPaired);
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, validWorkflowIdPaired, false);
Set<SingleEndSequenceFile> submittedSingleFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SingleEndSequenceFile.class);
Set<SequenceFilePair> pairedFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SequenceFilePair.class);
assertEquals("the created submission should have no single input files", 0, submittedSingleFiles.size());
assertEquals("the created submission has an invalid number of paired input files", 1, pairedFiles.size());
SequenceFilePair submittedSp = pairedFiles.iterator().next();
Set<SequenceFile> submittedSf = submittedSp.getFiles();
assertEquals("the paired input should have 2 files", 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.IridaWorkflow in project irida by phac-nml.
the class AnalysisControllerTest method testGetAnalysisDetailsTree.
@Test
public void testGetAnalysisDetailsTree() throws IOException, IridaWorkflowNotFoundException {
Long submissionId = 1L;
ExtendedModelMap model = new ExtendedModelMap();
Locale locale = Locale.ENGLISH;
final IridaWorkflowInput input = new IridaWorkflowInput("single", "paired", "reference", true);
AnalysisSubmission submission = TestDataFactory.constructAnalysisSubmission();
IridaWorkflowDescription description = new IridaWorkflowDescription(submission.getWorkflowId(), "My Workflow", "V1", AnalysisType.PHYLOGENOMICS, input, Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList());
IridaWorkflow iridaWorkflow = new IridaWorkflow(description, null);
submission.setAnalysisState(AnalysisState.COMPLETED);
when(analysisSubmissionServiceMock.read(submissionId)).thenReturn(submission);
when(iridaWorkflowsServiceMock.getIridaWorkflow(submission.getWorkflowId())).thenReturn(iridaWorkflow);
String detailsPage = analysisController.getDetailsPage(submissionId, model, locale);
assertEquals("should be details page", AnalysisController.PAGE_DETAILS_DIRECTORY + "tree", detailsPage);
assertEquals("Tree preview should be set", "tree", model.get("preview"));
assertEquals("submission should be in model", submission, model.get("analysisSubmission"));
assertEquals("submission reference file should be in model.", submission.getReferenceFile().get(), model.get("referenceFile"));
}
use of ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxy method getAnalysisResults.
/**
* {@inheritDoc}
*/
@Override
public Analysis getAnalysisResults(AnalysisSubmission analysisSubmission) throws ExecutionManagerException, IridaWorkflowNotFoundException, IOException, IridaWorkflowAnalysisTypeException {
checkNotNull(analysisSubmission, "analysisSubmission is null");
checkNotNull(analysisSubmission.getWorkflowId(), "workflowId is null");
checkNotNull(analysisSubmission.getRemoteWorkflowId(), "remoteWorkflowId is null");
Path outputDirectory = Files.createTempDirectory("analysis-output");
logger.trace("Created temporary directory " + outputDirectory + " for analysis output files");
IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(analysisSubmission.getWorkflowId());
String analysisId = analysisSubmission.getRemoteAnalysisId();
Map<String, IridaWorkflowOutput> outputsMap = iridaWorkflow.getWorkflowDescription().getOutputsMap();
String labelPrefix = getLabelPrefix(analysisSubmission, iridaWorkflow);
Map<String, AnalysisOutputFile> analysisOutputFiles = Maps.newHashMap();
for (String analysisOutputName : outputsMap.keySet()) {
String outputFileName = outputsMap.get(analysisOutputName).getFileName();
Dataset outputDataset = galaxyHistoriesService.getDatasetForFileInHistory(outputFileName, analysisId);
AnalysisOutputFile analysisOutput = buildOutputFile(analysisId, labelPrefix, outputDataset, outputDirectory);
analysisOutputFiles.put(analysisOutputName, analysisOutput);
}
AnalysisType analysisType = iridaWorkflow.getWorkflowDescription().getAnalysisType();
return new Analysis(analysisId, analysisOutputFiles, analysisType);
}
Aggregations