Search in sources :

Example 86 with AnalysisSubmission

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");
    }
}
Also used : IridaWorkflowNotFoundException(ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowNotFoundException) Project(ca.corefacility.bioinformatics.irida.model.project.Project) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) FileProcessorException(ca.corefacility.bioinformatics.irida.processing.FileProcessorException) User(ca.corefacility.bioinformatics.irida.model.user.User) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) Builder(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission.Builder) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) UUID(java.util.UUID)

Example 87 with AnalysisSubmission

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;
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) JobDetails(com.github.jmchilton.blend4j.galaxy.beans.JobDetails) Tool(com.github.jmchilton.blend4j.galaxy.beans.Tool) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) ToolsClient(com.github.jmchilton.blend4j.galaxy.ToolsClient) JobError(ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError) Map(java.util.Map) HistoryDetails(com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails) GalaxyWorkflowState(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowState) HistoriesClient(com.github.jmchilton.blend4j.galaxy.HistoriesClient) JobsClient(com.github.jmchilton.blend4j.galaxy.JobsClient) HistoryContentsProvenance(com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance) ArrayList(java.util.ArrayList) JobError(ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError) HistoryContentsProvenance(com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance) JobDetails(com.github.jmchilton.blend4j.galaxy.beans.JobDetails) HistoryDetails(com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) Tool(com.github.jmchilton.blend4j.galaxy.beans.Tool)

Example 88 with AnalysisSubmission

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);
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) JobError(ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 89 with AnalysisSubmission

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;
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)

Example 90 with AnalysisSubmission

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;
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) ModelMap(org.springframework.ui.ModelMap) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) ResourceCollection(ca.corefacility.bioinformatics.irida.web.assembler.resource.ResourceCollection) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)183 Test (org.junit.Test)121 WithMockUser (org.springframework.security.test.context.support.WithMockUser)95 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)30 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)30 Path (java.nio.file.Path)25 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)23 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)20 Project (ca.corefacility.bioinformatics.irida.model.project.Project)19 History (com.github.jmchilton.blend4j.galaxy.beans.History)19 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)18 AnalysisOutputFile (ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile)18 WorkflowsClient (com.github.jmchilton.blend4j.galaxy.WorkflowsClient)18 Workflow (com.github.jmchilton.blend4j.galaxy.beans.Workflow)18 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)15 User (ca.corefacility.bioinformatics.irida.model.user.User)15 EntityNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException)12 ExecutionManagerException (ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)12 ProjectAnalysisSubmissionJoin (ca.corefacility.bioinformatics.irida.model.workflow.submission.ProjectAnalysisSubmissionJoin)12 ToolExecution (ca.corefacility.bioinformatics.irida.model.workflow.analysis.ToolExecution)11