use of ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow in project irida by phac-nml.
the class AssemblyFileProcessor method process.
/**
* {@inheritDoc}
*/
@Override
@Transactional
public void process(SequencingObject sequencingObject) {
logger.debug("Setting up automated assembly for sequence " + sequencingObject.getId());
// assembly run by admin
User admin = userRepository.loadUserByUsername("admin");
// assembled
if (sequencingObject instanceof SequenceFilePair) {
IridaWorkflow defaultWorkflowByType;
// get the workflow
try {
defaultWorkflowByType = workflowsService.getDefaultWorkflowByType(AnalysisType.ASSEMBLY_ANNOTATION);
} catch (IridaWorkflowNotFoundException e) {
throw new FileProcessorException("Cannot find assembly workflow", e);
}
UUID pipelineUUID = defaultWorkflowByType.getWorkflowIdentifier();
// build an AnalysisSubmission
Builder builder = new AnalysisSubmission.Builder(pipelineUUID);
AnalysisSubmission submission = builder.inputFiles(Sets.newHashSet((SequenceFilePair) sequencingObject)).priority(AnalysisSubmission.Priority.LOW).name("Automated Assembly " + sequencingObject.toString()).updateSamples(true).build();
submission.setSubmitter(admin);
submission = submissionRepository.save(submission);
// Associate the submission with the seqobject
sequencingObject.setAutomatedAssembly(submission);
objectRepository.save(sequencingObject);
logger.debug("Automated assembly submission created for sequencing object " + sequencingObject.getId());
} else {
logger.warn("Could not assemble sequencing object " + sequencingObject.getId() + " because it's not paired end");
}
}
use of ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow in project irida by phac-nml.
the class SistrTypingFileProcessor method process.
/**
* {@inheritDoc}
*/
@Override
public void process(SequencingObject sequencingObject) {
logger.debug("Setting up SISTR typing for sequence " + sequencingObject.getId());
User admin = userRepository.loadUserByUsername("admin");
Project.AutomatedSISTRSetting automatedSISTRSetting = shouldTypeWithSISTR(sequencingObject);
// assembled/typed.
if (sequencingObject instanceof SequenceFilePair) {
IridaWorkflow defaultWorkflowByType;
// get the workflow
try {
defaultWorkflowByType = workflowsService.getDefaultWorkflowByType(AnalysisType.SISTR_TYPING);
} catch (IridaWorkflowNotFoundException e) {
throw new FileProcessorException("Cannot find assembly workflow", e);
}
UUID pipelineUUID = defaultWorkflowByType.getWorkflowIdentifier();
// build an AnalysisSubmission
Builder builder = new AnalysisSubmission.Builder(pipelineUUID);
if (automatedSISTRSetting.equals(Project.AutomatedSISTRSetting.AUTO_METADATA)) {
builder.updateSamples(true);
} else if (automatedSISTRSetting.equals(Project.AutomatedSISTRSetting.AUTO)) {
builder.updateSamples(false);
}
AnalysisSubmission submission = builder.inputFiles(Sets.newHashSet((SequenceFilePair) sequencingObject)).priority(AnalysisSubmission.Priority.LOW).name("Automated SISTR Typing " + sequencingObject.toString()).build();
submission.setSubmitter(admin);
submission = submissionRepository.save(submission);
// Associate the submission with the seqobject
sequencingObject.setSistrTyping(submission);
objectRepository.save(sequencingObject);
logger.debug("Automated SISTR typing submission created for sequencing object " + sequencingObject.getId());
} else {
logger.warn("Could not run SISTR typing for sequencing object " + sequencingObject.getId() + " because it's not paired end");
}
}
use of ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow in project irida by phac-nml.
the class RESTProjectAnalysisController method getProjectAnalysesByType.
/**
* Get the list of {@link AnalysisSubmission}s for this {@link Project} by
* type of analysis.
*
* @param projectId
* The {@link Project} to search.
* @param type
* The analysis type to search for.
* @return A list of {@link AnalysisSubmission}s for the given
* {@link Project} by the given type.
* @throws IridaWorkflowNotFoundException
* If the {@link AnalysisSubmission} is linked to a workflow not
* found in IRIDA.
*/
@RequestMapping(value = "/api/projects/{projectId}/analyses/{type}", method = RequestMethod.GET)
public ModelMap getProjectAnalysesByType(@PathVariable Long projectId, @PathVariable String type) throws IridaWorkflowNotFoundException {
logger.debug("Loading analyses for project [" + projectId + "] by type [" + type + "]");
if (!RESTAnalysisSubmissionController.ANALYSIS_TYPES.containsKey(type)) {
throw new EntityNotFoundException("Analysis type [" + type + "] not found");
}
AnalysisType analysisType = RESTAnalysisSubmissionController.ANALYSIS_TYPES.get(type);
ModelMap modelMap = new ModelMap();
Project p = projectService.read(projectId);
Collection<AnalysisSubmission> analysisSubmissions = analysisSubmissionService.getAnalysisSubmissionsSharedToProject(p);
ResourceCollection<AnalysisSubmission> analysisResources = new ResourceCollection<>(analysisSubmissions.size());
for (AnalysisSubmission submission : analysisSubmissions) {
IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(submission.getWorkflowId());
AnalysisType submissionAnalysisType = iridaWorkflow.getWorkflowDescription().getAnalysisType();
if (analysisType.equals(submissionAnalysisType)) {
submission.add(linkTo(methodOn(RESTAnalysisSubmissionController.class, Long.class).getResource(submission.getId())).withSelfRel());
analysisResources.add(submission);
}
}
analysisResources.add(linkTo(methodOn(RESTProjectsController.class, Long.class).getResource(projectId)).withRel(PROJECT_REL));
analysisResources.add(linkTo(methodOn(RESTProjectAnalysisController.class, Long.class).getProjectAnalysesByType(projectId, type)).withSelfRel());
modelMap.addAttribute(ANALYSIS_RESOURCES, analysisResources);
return modelMap;
}
use of ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow in project irida by phac-nml.
the class IridaWorkflowsGalaxyIntegrationTestConfig method snvPhylWorkflow.
/**
* Registers a production SNVPhyl workflow for testing.
*
* @return A production {@link IridaWorkflow} for testing.
* @throws IOException
* @throws URISyntaxException
* @throws IridaWorkflowException
*/
@Lazy
@Bean
public IridaWorkflow snvPhylWorkflow() throws IOException, URISyntaxException, IridaWorkflowException {
Path snvPhylProductionPath = Paths.get(AnalysisType.class.getResource("workflows/SNVPhyl").toURI());
Set<IridaWorkflow> snvPhylWorkflows = iridaWorkflowLoaderService.loadAllWorkflowImplementations(snvPhylProductionPath);
iridaWorkflowsService.registerWorkflows(snvPhylWorkflows);
IridaWorkflow snvPhylWorkflow = iridaWorkflowsService.getIridaWorkflow(UUID.fromString(snvPhylWorkflowId));
return snvPhylWorkflow;
}
use of ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyIT method testPrepareAnalysisFilesParametersSuccessWithNoParameters.
/**
* Tests out successfully preparing paired workflow input files for
* execution, no parameters set.
*
* @throws InterruptedException
* @throws ExecutionManagerException
* @throws IOException
* @throws IridaWorkflowException
*/
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testPrepareAnalysisFilesParametersSuccessWithNoParameters() throws InterruptedException, ExecutionManagerException, IOException, IridaWorkflowException {
History history = new History();
history.setName("testPrepareAnalysisFilesParametersSuccessWithNoParameters");
HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
WorkflowsClient workflowsClient = localGalaxy.getGalaxyInstanceAdmin().getWorkflowsClient();
History createdHistory = historiesClient.create(history);
IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(validWorkflowIdPairedWithParameters);
Path workflowPath = iridaWorkflow.getWorkflowStructure().getWorkflowFile();
String workflowString = new String(Files.readAllBytes(workflowPath), StandardCharsets.UTF_8);
Workflow galaxyWorkflow = workflowsClient.importWorkflow(workflowString);
AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupPairSubmissionInDatabase(1L, pairSequenceFiles1A, pairSequenceFiles2A, referenceFilePath, validWorkflowIdPairedWithParameters, false);
analysisSubmission.setRemoteAnalysisId(createdHistory.getId());
analysisSubmission.setRemoteWorkflowId(galaxyWorkflow.getId());
PreparedWorkflowGalaxy preparedWorkflow = analysisWorkspaceService.prepareAnalysisFiles(analysisSubmission);
assertEquals("the response history id should match the input history id", createdHistory.getId(), preparedWorkflow.getRemoteAnalysisId());
WorkflowInputsGalaxy workflowInputsGalaxy = preparedWorkflow.getWorkflowInputs();
assertNotNull("the returned workflow inputs should not be null", workflowInputsGalaxy);
assertNotNull("the returned library id should not be null", preparedWorkflow.getRemoteDataId());
// verify correct files have been uploaded
List<HistoryContents> historyContents = historiesClient.showHistoryContents(createdHistory.getId());
assertEquals("the created history has an invalid number of elements", 4, historyContents.size());
WorkflowInputs workflowInputs = preparedWorkflow.getWorkflowInputs().getInputsObject();
assertNotNull("created workflowInputs is null", workflowInputs);
Map<String, Object> toolParameters = workflowInputs.getParameters().get("core_pipeline_outputs_paired_with_parameters");
assertNotNull("toolParameters is null", toolParameters);
String coverageMinValue = (String) toolParameters.get("coverageMin");
assertEquals("coverageMinValue should have been changed to default", "10", coverageMinValue);
assertEquals("coverageMidValue should have been changed to default", ImmutableMap.of("coverageMid", "10"), toolParameters.get("conditional"));
String coverageMaxValue = (String) toolParameters.get("coverageMin");
assertEquals("coverageMaxValue should have been changed to default", "10", coverageMaxValue);
}
Aggregations