Search in sources :

Example 26 with IridaWorkflow

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");
    }
}
Also used : IridaWorkflowNotFoundException(ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowNotFoundException) 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) Transactional(org.springframework.transaction.annotation.Transactional)

Example 27 with IridaWorkflow

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");
    }
}
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 28 with IridaWorkflow

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

Example 29 with IridaWorkflow

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;
}
Also used : Path(java.nio.file.Path) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) Lazy(org.springframework.context.annotation.Lazy) Bean(org.springframework.context.annotation.Bean)

Example 30 with IridaWorkflow

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);
}
Also used : Path(java.nio.file.Path) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) HistoryContents(com.github.jmchilton.blend4j.galaxy.beans.HistoryContents) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) WorkflowInputs(com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputs) Workflow(com.github.jmchilton.blend4j.galaxy.beans.Workflow) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) History(com.github.jmchilton.blend4j.galaxy.beans.History) WorkflowInputsGalaxy(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy) HistoriesClient(com.github.jmchilton.blend4j.galaxy.HistoriesClient) WorkflowsClient(com.github.jmchilton.blend4j.galaxy.WorkflowsClient) PreparedWorkflowGalaxy(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.PreparedWorkflowGalaxy) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)50 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)27 Test (org.junit.Test)27 Path (java.nio.file.Path)25 History (com.github.jmchilton.blend4j.galaxy.beans.History)19 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)18 WorkflowsClient (com.github.jmchilton.blend4j.galaxy.WorkflowsClient)18 Workflow (com.github.jmchilton.blend4j.galaxy.beans.Workflow)18 WithMockUser (org.springframework.security.test.context.support.WithMockUser)18 AnalysisType (ca.corefacility.bioinformatics.irida.model.enums.AnalysisType)10 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)10 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)9 ArrayList (java.util.ArrayList)9 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)8 IridaWorkflowDescription (ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowDescription)8 ToolsClient (com.github.jmchilton.blend4j.galaxy.ToolsClient)8 IridaWorkflowNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowNotFoundException)7 PreparedWorkflowGalaxy (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.PreparedWorkflowGalaxy)7 WorkflowInputsGalaxy (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy)6 HistoryContents (com.github.jmchilton.blend4j.galaxy.beans.HistoryContents)6