Search in sources :

Example 21 with SequenceFilePair

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair in project irida by phac-nml.

the class ProjectSynchronizationServiceTest method testSyncFiles.

@Test
public void testSyncFiles() {
    Sample sample = new Sample();
    SequenceFilePair pair = new SequenceFilePair();
    RemoteStatus pairStatus = new RemoteStatus("http://pair", api);
    pair.setRemoteStatus(pairStatus);
    pair.setId(1L);
    when(pairRemoteService.mirrorSequencingObject(pair)).thenReturn(pair);
    syncService.syncSequenceFilePair(pair, sample);
    verify(pairRemoteService).mirrorSequencingObject(pair);
    verify(objectService).createSequencingObjectInSample(pair, sample);
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) RemoteStatus(ca.corefacility.bioinformatics.irida.model.remote.RemoteStatus) Test(org.junit.Test)

Example 22 with SequenceFilePair

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair in project irida by phac-nml.

the class SequencingObjectServiceImpl method create.

/**
 * {@inheritDoc}
 */
@Override
@Transactional
@PreAuthorize("hasAnyRole('ROLE_SEQUENCER', 'ROLE_USER')")
public SequencingObject create(SequencingObject object) throws ConstraintViolationException, EntityExistsException {
    SequencingRun sequencingRun = object.getSequencingRun();
    if (sequencingRun != null) {
        if (object instanceof SingleEndSequenceFile && sequencingRun.getLayoutType() != LayoutType.SINGLE_END) {
            throw new IllegalArgumentException("Attempting to add a single end file to a non single end run");
        } else if (object instanceof SequenceFilePair && sequencingRun.getLayoutType() != LayoutType.PAIRED_END) {
            throw new IllegalArgumentException("Attempting to add a paired end file to a non paired end run");
        }
    }
    for (SequenceFile file : object.getFiles()) {
        file = sequenceFileRepository.save(file);
    }
    SequencingObject so = super.create(object);
    fileProcessingChainExecutor.execute(new SequenceFileProcessorLauncher(fileProcessingChain, so.getId(), SecurityContextHolder.getContext()));
    return so;
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) SequencingRun(ca.corefacility.bioinformatics.irida.model.run.SequencingRun) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SequenceFileProcessorLauncher(ca.corefacility.bioinformatics.irida.service.impl.processor.SequenceFileProcessorLauncher) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Example 23 with SequenceFilePair

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair in project irida by phac-nml.

the class AnalysisSubmissionServiceImpl method createSingleSampleSubmission.

/**
 * {@inheritDoc}
 */
@Override
@Transactional
@PreAuthorize("hasRole('ROLE_USER')")
public Collection<AnalysisSubmission> createSingleSampleSubmission(IridaWorkflow workflow, Long ref, List<SingleEndSequenceFile> sequenceFiles, List<SequenceFilePair> sequenceFilePairs, Map<String, String> params, IridaWorkflowNamedParameters namedParameters, String name, String analysisDescription, List<Project> projectsToShare, boolean writeResultsToSamples) {
    final Collection<AnalysisSubmission> createdSubmissions = new HashSet<AnalysisSubmission>();
    // Single end reads
    IridaWorkflowDescription description = workflow.getWorkflowDescription();
    if (description.acceptsSingleSequenceFiles()) {
        final Map<Sample, SingleEndSequenceFile> samplesMap = sequencingObjectService.getUniqueSamplesForSequencingObjects(Sets.newHashSet(sequenceFiles));
        for (final Map.Entry<Sample, SingleEndSequenceFile> entry : samplesMap.entrySet()) {
            Sample s = entry.getKey();
            SingleEndSequenceFile file = entry.getValue();
            // Build the analysis submission
            AnalysisSubmission.Builder builder = AnalysisSubmission.builder(workflow.getWorkflowIdentifier());
            builder.name(name + "_" + s.getSampleName());
            builder.inputFiles(ImmutableSet.of(file));
            builder.updateSamples(writeResultsToSamples);
            builder.priority(AnalysisSubmission.Priority.MEDIUM);
            // Add reference file
            if (ref != null && description.requiresReference()) {
                // Note: This cannot be empty if through the UI if the
                // pipeline required a reference file.
                ReferenceFile referenceFile = referenceFileRepository.findOne(ref);
                builder.referenceFile(referenceFile);
            }
            if (description.acceptsParameters()) {
                if (namedParameters != null) {
                    builder.withNamedParameters(namedParameters);
                } else {
                    if (!params.isEmpty()) {
                        // Note: This cannot be empty if through the UI if
                        // the pipeline required params.
                        builder.inputParameters(params);
                    }
                }
            }
            // Create the submission
            createdSubmissions.add(create(builder.build()));
        }
    }
    // Paired end reads
    if (description.acceptsPairedSequenceFiles()) {
        final Map<Sample, SequenceFilePair> samplesMap = sequencingObjectService.getUniqueSamplesForSequencingObjects(Sets.newHashSet(sequenceFilePairs));
        for (final Map.Entry<Sample, SequenceFilePair> entry : samplesMap.entrySet()) {
            Sample s = entry.getKey();
            SequenceFilePair filePair = entry.getValue();
            // Build the analysis submission
            AnalysisSubmission.Builder builder = AnalysisSubmission.builder(workflow.getWorkflowIdentifier());
            builder.name(name + "_" + s.getSampleName());
            builder.inputFiles(ImmutableSet.of(filePair));
            builder.updateSamples(writeResultsToSamples);
            // Add reference file
            if (ref != null && description.requiresReference()) {
                ReferenceFile referenceFile = referenceFileRepository.findOne(ref);
                builder.referenceFile(referenceFile);
            }
            if (description.acceptsParameters()) {
                if (namedParameters != null) {
                    builder.withNamedParameters(namedParameters);
                } else {
                    if (!params.isEmpty()) {
                        // Note: This cannot be empty if through the UI if
                        // the pipeline required params.
                        builder.inputParameters(params);
                    }
                }
            }
            // Add description to submission, can be null
            builder.analysisDescription(analysisDescription);
            // Create the submission
            createdSubmissions.add(create(builder.build()));
        }
    }
    // Share with the required projects
    for (AnalysisSubmission submission : createdSubmissions) {
        for (Project project : projectsToShare) {
            pasRepository.save(new ProjectAnalysisSubmissionJoin(project, submission));
        }
    }
    return createdSubmissions;
}
Also used : ReferenceFile(ca.corefacility.bioinformatics.irida.model.project.ReferenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) Project(ca.corefacility.bioinformatics.irida.model.project.Project) IridaWorkflowDescription(ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowDescription) ProjectAnalysisSubmissionJoin(ca.corefacility.bioinformatics.irida.model.workflow.submission.ProjectAnalysisSubmissionJoin) ImmutableMap(com.google.common.collect.ImmutableMap) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(javax.transaction.Transactional)

Example 24 with SequenceFilePair

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair 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 25 with SequenceFilePair

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair 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)

Aggregations

SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)59 Test (org.junit.Test)33 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)28 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)23 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)22 SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)19 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)13 Project (ca.corefacility.bioinformatics.irida.model.project.Project)12 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)12 WithMockUser (org.springframework.security.test.context.support.WithMockUser)12 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)11 Path (java.nio.file.Path)11 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)9 History (com.github.jmchilton.blend4j.galaxy.beans.History)8 User (ca.corefacility.bioinformatics.irida.model.user.User)7 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)7 ArrayList (java.util.ArrayList)7 IridaWorkflowNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowNotFoundException)5 ReferenceFile (ca.corefacility.bioinformatics.irida.model.project.ReferenceFile)5 ImmutableMap (com.google.common.collect.ImmutableMap)5