Search in sources :

Example 81 with AnalysisSubmission

use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.

the class RESTAnalysisSubmissionController method getAnalysisOutputFile.

/**
 * Get an analysis output file for a given submission
 *
 * @param submissionId
 *            The {@link AnalysisSubmission} id
 * @param fileType
 *            The {@link AnalysisOutputFile} type as defined in the
 *            {@link Analysis} subclass
 * @return {@link ModelMap} containing the {@link AnalysisOutputFile}
 */
@RequestMapping("/{submissionId}/analysis/file/{fileType}")
public ModelMap getAnalysisOutputFile(@PathVariable Long submissionId, @PathVariable String fileType) {
    ModelMap model = new ModelMap();
    AnalysisSubmission read = analysisSubmissionService.read(submissionId);
    if (read.getAnalysisState() != AnalysisState.COMPLETED) {
        throw new EntityNotFoundException("Analysis is not completed");
    }
    AnalysisOutputFile analysisOutputFile = read.getAnalysis().getAnalysisOutputFile(fileType);
    analysisOutputFile.add(linkTo(methodOn(RESTAnalysisSubmissionController.class).getAnalysisOutputFile(submissionId, fileType)).withSelfRel());
    model.addAttribute(RESOURCE_NAME, analysisOutputFile);
    return model;
}
Also used : ModelMap(org.springframework.ui.ModelMap) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) EntityNotFoundException(ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException) AnalysisOutputFile(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 82 with AnalysisSubmission

use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.

the class AnalysisExecutionServiceGalaxy method prepareSubmission.

/**
 * {@inheritDoc}
 */
@Override
public Future<AnalysisSubmission> prepareSubmission(final AnalysisSubmission analysisSubmission) throws IridaWorkflowNotFoundException, IOException, ExecutionManagerException {
    checkArgument(AnalysisState.NEW.equals(analysisSubmission.getAnalysisState()), "analysis state should be " + AnalysisState.NEW);
    analysisSubmission.setAnalysisState(AnalysisState.PREPARING);
    AnalysisSubmission preparingAnalysis = analysisSubmissionService.update(analysisSubmission);
    return analysisExecutionServiceGalaxyAsync.prepareSubmission(preparingAnalysis);
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)

Example 83 with AnalysisSubmission

use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.

the class AnalysisExecutionServiceGalaxy method executeAnalysis.

/**
 * {@inheritDoc}
 */
@Override
public Future<AnalysisSubmission> executeAnalysis(AnalysisSubmission analysisSubmission) throws ExecutionManagerException, IridaWorkflowException {
    checkArgument(AnalysisState.PREPARED.equals(analysisSubmission.getAnalysisState()), " analysis should be " + AnalysisState.PREPARED);
    analysisSubmission.setAnalysisState(AnalysisState.SUBMITTING);
    AnalysisSubmission submittingAnalysis = analysisSubmissionService.update(analysisSubmission);
    return analysisExecutionServiceGalaxyAsync.executeAnalysis(submittingAnalysis);
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)

Example 84 with AnalysisSubmission

use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.

the class AnalysisExecutionServiceGalaxyAsync method prepareSubmission.

/**
 * Prepares the given {@link AnalysisSubmission} to be executed within an
 * execution manager. This will persist the submission within the database.
 *
 * @param analysisSubmission
 *            The {@link AnalysisSubmission} to prepare.
 * @return A {@link Future} with an {@link AnalysisSubmission} for the
 *         analysis submitted.
 * @throws IridaWorkflowNotFoundException
 *             If there was an issue getting a workflow.
 * @throws IOException
 *             If there was an issue reading the workflow.
 * @throws ExecutionManagerException
 *             If there was an issue preparing a workspace for the workflow.
 */
@Transactional
public Future<AnalysisSubmission> prepareSubmission(final AnalysisSubmission analysisSubmission) throws IridaWorkflowNotFoundException, IOException, ExecutionManagerException {
    checkNotNull(analysisSubmission, "analysisSubmission is null");
    checkNotNull(analysisSubmission.getId(), "analysisSubmission id is null");
    checkArgument(null == analysisSubmission.getRemoteAnalysisId(), "remote analyis id should be null");
    checkArgument(null == analysisSubmission.getRemoteWorkflowId(), "remoteWorkflowId should be null");
    IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(analysisSubmission.getWorkflowId());
    IridaWorkflowStructure workflowStructure = iridaWorkflow.getWorkflowStructure();
    logger.debug("Preparing submission for " + analysisSubmission);
    String workflowId = galaxyWorkflowService.uploadGalaxyWorkflow(workflowStructure.getWorkflowFile());
    analysisSubmission.setRemoteWorkflowId(workflowId);
    logger.trace("Uploaded workflow for " + analysisSubmission + " to workflow with id=" + workflowId);
    String analysisId = workspaceService.prepareAnalysisWorkspace(analysisSubmission);
    logger.trace("Created Galaxy history for analysis " + " id=" + analysisId + ", " + analysisSubmission);
    analysisSubmission.setAnalysisState(AnalysisState.PREPARED);
    analysisSubmission.setRemoteWorkflowId(workflowId);
    analysisSubmission.setRemoteAnalysisId(analysisId);
    AnalysisSubmission analysisPrepared = analysisSubmissionService.update(analysisSubmission);
    return new AsyncResult<>(analysisPrepared);
}
Also used : IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) IridaWorkflowStructure(ca.corefacility.bioinformatics.irida.model.workflow.structure.IridaWorkflowStructure) AsyncResult(org.springframework.scheduling.annotation.AsyncResult) Transactional(org.springframework.transaction.annotation.Transactional)

Example 85 with AnalysisSubmission

use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission 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)

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