use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission 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.submission.AnalysisSubmission in project irida by phac-nml.
the class GalaxyJobErrorsService method createNewJobErrors.
/**
* Get any {@link JobError} associated with an {@link AnalysisSubmission}
*
* @param analysisSubmission {@link AnalysisSubmission} to search for job failures
* @return List of {@link JobError} objects associated with {@link AnalysisSubmission}
*/
public List<JobError> createNewJobErrors(AnalysisSubmission analysisSubmission) {
String historyId = analysisSubmission.getRemoteAnalysisId();
HistoryDetails historyDetails = historiesClient.showHistory(historyId);
List<String> erroredDatasetIds = historyDetails.getStateIds().get(GalaxyWorkflowState.ERROR.toString());
List<HistoryContentsProvenance> provenances = erroredDatasetIds.stream().map((x) -> historiesClient.showProvenance(historyId, x)).collect(Collectors.toList());
Map<String, List<HistoryContentsProvenance>> jobIdProvenancesMap = provenances.stream().collect(Collectors.groupingBy(HistoryContentsProvenance::getJobId));
List<JobError> jobErrors = new ArrayList<>();
for (Map.Entry<String, List<HistoryContentsProvenance>> entry : jobIdProvenancesMap.entrySet()) {
String jobId = entry.getKey();
JobDetails jobDetails = jobsClient.showJob(jobId);
HistoryContentsProvenance p = entry.getValue().iterator().next();
Tool tool = toolsClient.showTool(p.getToolId());
jobErrors.add(new JobError(analysisSubmission, jobDetails, p, tool));
}
return jobErrors;
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class GalaxyJobErrorsServiceIT method testFailingAnalysisReturnsJobError.
/**
* Test that a failure producing Galaxy workflow analysis returns a {@link JobError}
*/
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testFailingAnalysisReturnsJobError() throws Exception {
databaseSetupGalaxyITService.setupSubmissionInDatabase(1L, sequenceFilePath, referenceFilePath, iridaWorkflowIdWithError, false);
AnalysisSubmission submission = runAnalysis();
assertEquals(AnalysisState.ERROR, submission.getAnalysisState());
List<JobError> errors = galaxyJobErrorsService.createNewJobErrors(submission);
assertTrue("There should only be one JobError", errors.size() == 1);
JobError jobError = errors.get(0);
assertTrue("JobError should have some stderr message", jobError.getStandardError() != null && !jobError.getStandardError().equals(""));
assertTrue("JobError should be triggered by 'IndexError: list index out of range'", jobError.getStandardError().contains("IndexError: list index out of range"));
assertTrue("JobError tool ID should be 'Filter1'", jobError.getToolId().equals("Filter1"));
assertTrue("JobError exit code should be '1'", jobError.getExitCode() == 1);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class RESTSampleSequenceFilesController method addSequencingObjectLinks.
/**
* Add the links for a {@link SequencingObject} to its sample, self, to each
* individual {@link SequenceFile}
*
* @param sequencingObject {@link SequencingObject} to enhance
* @param sampleId ID of the {@link Sample} for the object
* @param <T> The subclass of {@link SequencingObject} being enhanced by this method
* @return the enhanced {@link SequencingObject}
*/
@SuppressWarnings("unchecked")
public static <T extends SequencingObject> T addSequencingObjectLinks(T sequencingObject, Long sampleId) {
String objectType = objectLabels.get(sequencingObject.getClass());
// link to self
sequencingObject.add(linkTo(methodOn(RESTSampleSequenceFilesController.class).readSequencingObject(sampleId, objectType, sequencingObject.getId())).withSelfRel());
// link to the sample
sequencingObject.add(linkTo(methodOn(RESTProjectSamplesController.class).getSample(sampleId)).withRel(RESTSampleSequenceFilesController.REL_SAMPLE));
// link to the individual files
for (SequenceFile file : sequencingObject.getFiles()) {
file.add(linkTo(methodOn(RESTSampleSequenceFilesController.class).readSequenceFileForSequencingObject(sampleId, objectType, sequencingObject.getId(), file.getId())).withSelfRel());
}
AnalysisSubmission automatedAssembly = sequencingObject.getAutomatedAssembly();
if (automatedAssembly != null) {
sequencingObject.add(linkTo(methodOn(RESTAnalysisSubmissionController.class).getResource(automatedAssembly.getId())).withRel(REL_AUTOMATED_ASSEMBLY));
}
AnalysisSubmission sistrTyping = sequencingObject.getSistrTyping();
if (sistrTyping != null) {
sequencingObject.add(linkTo(methodOn(RESTAnalysisSubmissionController.class).getResource(sistrTyping.getId())).withRel(REL_SISTR_TYPING));
}
// if it's a pair, add forward/reverse links
if (sequencingObject instanceof SequenceFilePair) {
sequencingObject = (T) addSequenceFilePairLinks((SequenceFilePair) sequencingObject, sampleId);
}
return sequencingObject;
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class RESTProjectAnalysisController method getProjectAnalyses.
/**
* Get the list of {@link AnalysisSubmission}s associated with this
* {@link Project}.
*
* @param projectId
* the identifier of the {@link Project} to get the
* {@link AnalysisSubmission}s for.
* @return the list of {@link AnalysisSubmission}s associated with this
* {@link Project}.
*/
@RequestMapping(value = "/api/projects/{projectId}/analyses", method = RequestMethod.GET)
public ModelMap getProjectAnalyses(@PathVariable Long projectId) {
logger.debug("Loading analyses for project [" + projectId + "]");
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) {
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).getProjectAnalyses(projectId)).withSelfRel());
modelMap.addAttribute(ANALYSIS_RESOURCES, analysisResources);
return modelMap;
}
Aggregations