use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile in project irida by phac-nml.
the class AnalysisServiceTest method testCreateAnalysisWithMultipleOutputFile.
@Test
public void testCreateAnalysisWithMultipleOutputFile() throws IOException {
Path outputFile1 = Files.createTempFile(null, null);
Path outputFile2 = Files.createTempFile(null, null);
Path outputFile3 = Files.createTempFile(null, null);
AnalysisOutputFile report1 = new AnalysisOutputFile(outputFile1, "", "", null);
AnalysisOutputFile report2 = new AnalysisOutputFile(outputFile2, "", "", null);
AnalysisOutputFile report3 = new AnalysisOutputFile(outputFile3, "", "", null);
Map<String, AnalysisOutputFile> analysisOutputFiles = new ImmutableMap.Builder<String, AnalysisOutputFile>().put("tree", report1).put("matrix", report2).put("table", report3).build();
Analysis analysis = new Analysis("something", analysisOutputFiles, AnalysisType.PHYLOGENOMICS);
analysisService.create(analysis);
verify(analysisOutputFileRepository, times(3)).save(any(AnalysisOutputFile.class));
verify(analysisRepository).save(analysis);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile in project irida by phac-nml.
the class AnalysisServiceImplIT method testCreatePhylogenomicsAnalysis.
@Test
@WithMockUser(username = "admin", roles = "ADMIN")
public void testCreatePhylogenomicsAnalysis() throws IOException {
Path treePath = Files.createTempFile(null, null);
Path tablePath = Files.createTempFile(null, null);
Path matrixPath = Files.createTempFile(null, null);
Map<String, String> params = new HashMap<>();
params.put("param", "value");
ToolExecution toolExecutionTree = new ToolExecution(null, "ls", "1.0", "executionManagerId", params, "/bin/ls -lrth");
ToolExecution toolExecutionTable = new ToolExecution(null, "ls", "1.0", "executionManagerId", params, "/bin/ls -lrth");
ToolExecution toolExecutionMatrix = new ToolExecution(null, "ls", "1.0", "executionManagerId", params, "/bin/ls -lrth");
AnalysisOutputFile tree = new AnalysisOutputFile(treePath, "internal-galaxy-tree-identifier", "", toolExecutionTree);
AnalysisOutputFile table = new AnalysisOutputFile(tablePath, "internal-galaxy-table-identifier", "", toolExecutionTable);
AnalysisOutputFile matrix = new AnalysisOutputFile(matrixPath, "internal-galaxy-matrix-identifier", "", toolExecutionMatrix);
Map<String, AnalysisOutputFile> analysisOutputFiles = new ImmutableMap.Builder<String, AnalysisOutputFile>().put("tree", tree).put("matrix", matrix).put("table", table).build();
Analysis pipeline = new Analysis(EXECUTION_MANAGER_ID, analysisOutputFiles, AnalysisType.PHYLOGENOMICS);
// make sure that we're not falsely putting the files into the correct
// directory in the first place.
assertFalse("file was stored in the wrong directory.", pipeline.getAnalysisOutputFile(TREE_KEY).getFile().startsWith(outputFileBaseDirectory));
assertFalse("file was stored in the wrong directory.", pipeline.getAnalysisOutputFile(MATRIX_KEY).getFile().startsWith(outputFileBaseDirectory));
assertFalse("file was stored in the wrong directory.", pipeline.getAnalysisOutputFile(TABLE_KEY).getFile().startsWith(outputFileBaseDirectory));
Analysis analysis = analysisService.create(pipeline);
// make sure that we put the analysis output files into the correct
// directory.
assertEquals("returned analysis was of the wrong type.", AnalysisType.PHYLOGENOMICS, analysis.getAnalysisType());
assertTrue("file was stored in the wrong directory.", analysis.getAnalysisOutputFile(TREE_KEY).getFile().startsWith(outputFileBaseDirectory));
assertTrue("file was stored in the wrong directory.", analysis.getAnalysisOutputFile(MATRIX_KEY).getFile().startsWith(outputFileBaseDirectory));
assertTrue("file was stored in the wrong directory.", analysis.getAnalysisOutputFile(TABLE_KEY).getFile().startsWith(outputFileBaseDirectory));
}
use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile in project irida by phac-nml.
the class TestDataFactory method constructAnalysisOutputFile.
private static AnalysisOutputFile constructAnalysisOutputFile(String name, Long id) {
if (id == null) {
id = 1L;
}
ToolExecution toolExecution = new ToolExecution(1L, null, "testTool", "0.0.12", "executionManagersId", ImmutableMap.of());
final AnalysisOutputFile of = new AnalysisOutputFile(Paths.get(FAKE_FILE_PATH.replace("{name}", name)), "", FAKE_EXECUTION_MANAGER_ID, toolExecution);
final DirectFieldAccessor dfa = new DirectFieldAccessor(of);
dfa.setPropertyValue("id", id);
return of;
}
use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile 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);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile in project irida by phac-nml.
the class RESTAnalysisSubmissionController method getAnalysisOutputFile.
/**
* Get an analysis output file for a given submission
*
* @param submissionId
* The {@link AnalysisSubmission} id
* @param fileType
* The {@link AnalysisOutputFile} type as defined in the
* {@link Analysis} subclass
* @return {@link ModelMap} containing the {@link AnalysisOutputFile}
*/
@RequestMapping("/{submissionId}/analysis/file/{fileType}")
public ModelMap getAnalysisOutputFile(@PathVariable Long submissionId, @PathVariable String fileType) {
ModelMap model = new ModelMap();
AnalysisSubmission read = analysisSubmissionService.read(submissionId);
if (read.getAnalysisState() != AnalysisState.COMPLETED) {
throw new EntityNotFoundException("Analysis is not completed");
}
AnalysisOutputFile analysisOutputFile = read.getAnalysis().getAnalysisOutputFile(fileType);
analysisOutputFile.add(linkTo(methodOn(RESTAnalysisSubmissionController.class).getAnalysisOutputFile(submissionId, fileType)).withSelfRel());
model.addAttribute(RESOURCE_NAME, analysisOutputFile);
return model;
}
Aggregations