use of ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow in project irida by phac-nml.
the class AnalysisController method getDetailsPage.
/**
* View details about an individual analysis submission
*
* @param submissionId the ID of the submission
* @param model Model for the view
* @param locale User's locale
* @return name of the details page view
*/
@RequestMapping(value = "/{submissionId}", produces = MediaType.TEXT_HTML_VALUE)
public String getDetailsPage(@PathVariable Long submissionId, Model model, Locale locale) {
logger.trace("reading analysis submission " + submissionId);
AnalysisSubmission submission = analysisSubmissionService.read(submissionId);
model.addAttribute("analysisSubmission", submission);
UUID workflowUUID = submission.getWorkflowId();
logger.trace("Workflow ID is " + workflowUUID);
IridaWorkflow iridaWorkflow;
try {
iridaWorkflow = workflowsService.getIridaWorkflow(workflowUUID);
} catch (IridaWorkflowNotFoundException e) {
logger.error("Error finding workflow, ", e);
throw new EntityNotFoundException("Couldn't find workflow for submission " + submission.getId(), e);
}
// Get the name of the workflow
AnalysisType analysisType = iridaWorkflow.getWorkflowDescription().getAnalysisType();
model.addAttribute("analysisType", analysisType);
String viewName = getViewForAnalysisType(analysisType);
String workflowName = messageSource.getMessage("workflow." + analysisType.toString() + ".title", null, locale);
model.addAttribute("workflowName", workflowName);
model.addAttribute("version", iridaWorkflow.getWorkflowDescription().getVersion());
// Input files
// - Paired
Set<SequenceFilePair> inputFilePairs = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(submission, SequenceFilePair.class);
model.addAttribute("paired_end", inputFilePairs);
// Check if user can update analysis
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
model.addAttribute("updatePermission", updateAnalysisPermission.isAllowed(authentication, submission));
if (iridaWorkflow.getWorkflowDescription().requiresReference() && submission.getReferenceFile().isPresent()) {
logger.debug("Adding reference file to page for submission with id [" + submission.getId() + "].");
model.addAttribute("referenceFile", submission.getReferenceFile().get());
} else {
logger.debug("No reference file required for workflow.");
}
/*
* Preview information
*/
try {
if (submission.getAnalysisState().equals(AnalysisState.COMPLETED)) {
if (analysisType.equals(AnalysisType.PHYLOGENOMICS)) {
tree(submission, model);
} else if (analysisType.equals(AnalysisType.SISTR_TYPING)) {
model.addAttribute("sistr", true);
}
}
} catch (IOException e) {
logger.error("Couldn't get preview for analysis", e);
}
return viewName;
}
use of ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow in project irida by phac-nml.
the class AnalysisController method getSistrAnalysis.
/**
* Get the sistr analysis information to display
*
* @param id ID of the analysis submission
* @return Json results for the SISTR analysis
*/
@SuppressWarnings("resource")
@RequestMapping("/ajax/sistr/{id}")
@ResponseBody
public Map<String, Object> getSistrAnalysis(@PathVariable Long id) {
AnalysisSubmission submission = analysisSubmissionService.read(id);
Collection<Sample> samples = sampleService.getSamplesForAnalysisSubmission(submission);
Map<String, Object> result = ImmutableMap.of("parse_results_error", true);
final String sistrFileKey = "sistr-predictions";
// Get details about the workflow
UUID workflowUUID = submission.getWorkflowId();
IridaWorkflow iridaWorkflow;
try {
iridaWorkflow = workflowsService.getIridaWorkflow(workflowUUID);
} catch (IridaWorkflowNotFoundException e) {
logger.error("Error finding workflow, ", e);
throw new EntityNotFoundException("Couldn't find workflow for submission " + submission.getId(), e);
}
AnalysisType analysisType = iridaWorkflow.getWorkflowDescription().getAnalysisType();
if (analysisType.equals(AnalysisType.SISTR_TYPING)) {
Analysis analysis = submission.getAnalysis();
Path path = analysis.getAnalysisOutputFile(sistrFileKey).getFile();
try {
String json = new Scanner(new BufferedReader(new FileReader(path.toFile()))).useDelimiter("\\Z").next();
// verify file is proper json file
ObjectMapper mapper = new ObjectMapper();
List<Map<String, Object>> sistrResults = mapper.readValue(json, new TypeReference<List<Map<String, Object>>>() {
});
if (sistrResults.size() > 0) {
// should only ever be one sample for these results
if (samples.size() == 1) {
Sample sample = samples.iterator().next();
result = sistrResults.get(0);
result.put("parse_results_error", false);
result.put("sample_name", sample.getSampleName());
} else {
logger.error("Invalid number of associated samles for submission " + submission);
}
} else {
logger.error("SISTR results for file [" + path + "] are not correctly formatted");
}
} catch (FileNotFoundException e) {
logger.error("File [" + path + "] not found", e);
} catch (JsonParseException | JsonMappingException e) {
logger.error("Error attempting to parse file [" + path + "] as JSON", e);
} catch (IOException e) {
logger.error("Error reading file [" + path + "]", e);
}
}
return result;
}
use of ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow in project irida by phac-nml.
the class IridaWorkflowLoaderServiceIT method testLoadWorkflowWithParameters.
/**
* Test to make sure we can load a workflow with parameters.
*
* @throws IridaWorkflowLoadException
* @throws IOException
*/
@Test
public void testLoadWorkflowWithParameters() throws IridaWorkflowLoadException, IOException {
IridaWorkflow iridaWorkflowFromFile = workflowLoaderService.loadIridaWorkflowFromDirectory(workflowDirectoryPathWithParameters);
assertTrue("workflow loaded with no parameters", iridaWorkflowFromFile.getWorkflowDescription().acceptsParameters());
List<IridaWorkflowParameter> parameters = iridaWorkflowFromFile.getWorkflowDescription().getParameters();
assertNotNull("parameters should not be null", parameters);
assertEquals("parameters does not have the correct size", 1, parameters.size());
IridaWorkflowParameter parameter = parameters.get(0);
assertEquals("parameter does not have the correct name", "test-parameter", parameter.getName());
assertEquals("default value is not correct", "1", parameter.getDefaultValue());
assertEquals("parameter does not have correct number of tool parameters", 1, parameter.getToolParameters().size());
}
use of ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow in project irida by phac-nml.
the class IridaWorkflowLoaderServiceIT method testLoadWorkflow.
/**
* Tests loading up a workflow from a file.
*
* @throws IOException
* @throws IridaWorkflowLoadException
*/
@Test
public void testLoadWorkflow() throws IOException, IridaWorkflowLoadException {
IridaWorkflow iridaWorkflow = buildTestWorkflowSingle();
IridaWorkflow iridaWorkflowFromFile = workflowLoaderService.loadIridaWorkflow(workflowSingleXmlPath, workflowStructurePath);
assertEquals("irida workflow is invalid", iridaWorkflowFromFile, iridaWorkflow);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow in project irida by phac-nml.
the class IridaWorkflowLoaderServiceIT method testLoadWorkflowWithParametersNoDefaultValueIsRequiredSuccess.
/**
* Test to make sure we fail to load a workflow with no default value and without a required="true" attribute.
*
* @throws IridaWorkflowLoadException
* @throws IOException
*/
@Test
public void testLoadWorkflowWithParametersNoDefaultValueIsRequiredSuccess() throws IridaWorkflowLoadException, IOException {
IridaWorkflow iridaWorkflow = workflowLoaderService.loadIridaWorkflowFromDirectory(workflowDirectoryPathWithParametersNoDefaultIsRequired);
IridaWorkflowParameter parameter = iridaWorkflow.getWorkflowDescription().getParameters().get(0);
assertNull("defaultValue should be null if none provided", parameter.getDefaultValue());
assertTrue("parameter should be required", parameter.isRequired());
}
Aggregations