Search in sources :

Example 11 with SequencingObject

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

the class AnalysisSubmissionRepositoryIT method testCreateAnalysisSingleAndPairedAndReference.

/**
 * Tests creating an analysis with both single and paired files and a
 * reference genome.
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testCreateAnalysisSingleAndPairedAndReference() {
    Set<SequencingObject> inputs = Sets.newHashSet(sequenceFilePair, singleEndFile);
    AnalysisSubmission analysisSubmissionPaired = AnalysisSubmission.builder(workflowId).name("submission paired 1").inputFiles(inputs).referenceFile(referenceFile).build();
    analysisSubmissionPaired.setSubmitter(submitter1);
    AnalysisSubmission savedSubmission = analysisSubmissionRepository.save(analysisSubmissionPaired);
    Set<SequencingObject> inputsSaved = objectRepository.findSequencingObjectsForAnalysisSubmission(savedSubmission);
    assertTrue("should have single end file in collection", inputsSaved.contains(singleEndFile));
    assertTrue("should have pair file in collection", inputsSaved.contains(sequenceFilePair));
    assertEquals(referenceFile, savedSubmission.getReferenceFile().get());
}
Also used : SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 12 with SequencingObject

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

the class AnalysisExecutionServiceGalaxyTest method setup.

/**
 * Setup variables for tests.
 *
 * @throws IridaWorkflowNotFoundException
 * @throws IOException
 * @throws ExecutionManagerException
 * @throws NoSuchValueException
 * @throws IridaWorkflowAnalysisTypeException
 */
@Before
public void setup() throws IridaWorkflowNotFoundException, IOException, ExecutionManagerException, NoSuchValueException, IridaWorkflowAnalysisTypeException, AnalysisAlreadySetException {
    MockitoAnnotations.initMocks(this);
    String submissionName = "name";
    Set<SequencingObject> submissionInputFiles = Sets.newHashSet(new SingleEndSequenceFile(new SequenceFile()));
    analysisSubmission = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "intial").inputFiles(submissionInputFiles).build();
    analysisPreparing = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "preparing").inputFiles(submissionInputFiles).build();
    analysisPrepared = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "prepared").inputFiles(submissionInputFiles).build();
    analysisSubmitting = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "submitting").inputFiles(submissionInputFiles).build();
    analysisRunning = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "running").inputFiles(submissionInputFiles).build();
    analysisFinishedRunning = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "finishedrunning").inputFiles(submissionInputFiles).build();
    analysisCompleting = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "completing").inputFiles(submissionInputFiles).build();
    analysisCompleted = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "completed").inputFiles(submissionInputFiles).build();
    analysisCompletedCleaning = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "cleaning").inputFiles(submissionInputFiles).build();
    analysisCompletedCleaned = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "cleaned").inputFiles(submissionInputFiles).build();
    analysisError = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "error").inputFiles(submissionInputFiles).build();
    analysisErrorCleaning = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "errorcleaning").inputFiles(submissionInputFiles).build();
    analysisErrorCleaned = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "errorcleaned").inputFiles(submissionInputFiles).build();
    AnalysisExecutionServiceGalaxyAsync workflowManagementAsync = new AnalysisExecutionServiceGalaxyAsync(analysisSubmissionService, analysisService, galaxyWorkflowService, analysisWorkspaceService, iridaWorkflowsService, analysisSubmissionSampleProcessor);
    AnalysisExecutionServiceGalaxyCleanupAsync analysisExecutionServiceGalaxyCleanupAsync = new AnalysisExecutionServiceGalaxyCleanupAsync(analysisSubmissionService, galaxyWorkflowService, galaxyHistoriesService, galaxyLibrariesService);
    workflowManagement = new AnalysisExecutionServiceGalaxy(analysisSubmissionService, galaxyHistoriesService, workflowManagementAsync, analysisExecutionServiceGalaxyCleanupAsync);
    when(iridaWorkflowsService.getIridaWorkflow(WORKFLOW_ID)).thenReturn(iridaWorkflow);
    when(iridaWorkflow.getWorkflowStructure()).thenReturn(iridaWorkflowStructure);
    when(iridaWorkflowStructure.getWorkflowFile()).thenReturn(workflowFile);
    when(analysisSubmissionService.create(analysisSubmission)).thenReturn(analysisSubmission);
    when(analysisSubmissionService.read(INTERNAL_ANALYSIS_ID)).thenReturn(analysisSubmission);
    analysisSubmission.setId(INTERNAL_ANALYSIS_ID);
    analysisPreparing.setId(INTERNAL_ANALYSIS_ID);
    analysisPreparing.setAnalysisState(AnalysisState.PREPARING);
    when(analysisWorkspaceService.prepareAnalysisWorkspace(analysisPreparing)).thenReturn(ANALYSIS_ID);
    analysisPrepared.setId(INTERNAL_ANALYSIS_ID);
    analysisPrepared.setAnalysisState(AnalysisState.PREPARED);
    analysisPrepared.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisPrepared.setRemoteAnalysisId(ANALYSIS_ID);
    analysisSubmitting.setId(INTERNAL_ANALYSIS_ID);
    analysisSubmitting.setAnalysisState(AnalysisState.SUBMITTING);
    analysisSubmitting.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisSubmitting.setRemoteAnalysisId(ANALYSIS_ID);
    analysisRunning.setId(INTERNAL_ANALYSIS_ID);
    analysisRunning.setAnalysisState(AnalysisState.RUNNING);
    analysisRunning.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisRunning.setRemoteAnalysisId(ANALYSIS_ID);
    analysisRunning.setRemoteInputDataId(LIBRARY_ID);
    analysisFinishedRunning.setId(INTERNAL_ANALYSIS_ID);
    analysisFinishedRunning.setAnalysisState(AnalysisState.FINISHED_RUNNING);
    analysisFinishedRunning.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisFinishedRunning.setRemoteAnalysisId(ANALYSIS_ID);
    analysisFinishedRunning.setRemoteInputDataId(LIBRARY_ID);
    analysisCompleting.setId(INTERNAL_ANALYSIS_ID);
    analysisCompleting.setAnalysisState(AnalysisState.COMPLETING);
    analysisCompleting.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisCompleting.setRemoteAnalysisId(ANALYSIS_ID);
    analysisCompleting.setRemoteInputDataId(LIBRARY_ID);
    when(analysisWorkspaceService.getAnalysisResults(analysisCompleting)).thenReturn(analysisResults);
    when(analysisService.create(analysisResults)).thenReturn(analysisResults);
    analysisCompleted.setId(INTERNAL_ANALYSIS_ID);
    analysisCompleted.setAnalysisState(AnalysisState.COMPLETED);
    analysisCompleted.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisCompleted.setRemoteAnalysisId(ANALYSIS_ID);
    analysisCompleted.setAnalysisCleanedState(AnalysisCleanedState.NOT_CLEANED);
    analysisCompleted.setAnalysis(analysisResults);
    analysisCompleted.setRemoteInputDataId(LIBRARY_ID);
    analysisCompleted.setUpdateSamples(true);
    analysisCompletedCleaning.setId(INTERNAL_ANALYSIS_ID);
    analysisCompletedCleaning.setAnalysisState(AnalysisState.COMPLETED);
    analysisCompletedCleaning.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisCompletedCleaning.setRemoteAnalysisId(ANALYSIS_ID);
    analysisCompletedCleaning.setAnalysisCleanedState(AnalysisCleanedState.CLEANING);
    analysisCompletedCleaning.setAnalysis(analysisResults);
    analysisCompletedCleaning.setRemoteInputDataId(LIBRARY_ID);
    analysisCompletedCleaned.setId(INTERNAL_ANALYSIS_ID);
    analysisCompletedCleaned.setAnalysisState(AnalysisState.COMPLETED);
    analysisCompletedCleaned.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisCompletedCleaned.setRemoteAnalysisId(ANALYSIS_ID);
    analysisCompletedCleaned.setAnalysisCleanedState(AnalysisCleanedState.CLEANED);
    analysisCompletedCleaned.setAnalysis(analysisResults);
    analysisCompletedCleaned.setRemoteInputDataId(LIBRARY_ID);
    analysisError.setId(INTERNAL_ANALYSIS_ID);
    analysisError.setAnalysisState(AnalysisState.ERROR);
    analysisError.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisError.setAnalysisCleanedState(AnalysisCleanedState.NOT_CLEANED);
    analysisErrorCleaning.setId(INTERNAL_ANALYSIS_ID);
    analysisErrorCleaning.setAnalysisState(AnalysisState.ERROR);
    analysisErrorCleaning.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisErrorCleaning.setAnalysisCleanedState(AnalysisCleanedState.CLEANING);
    analysisErrorCleaned.setId(INTERNAL_ANALYSIS_ID);
    analysisErrorCleaned.setAnalysisState(AnalysisState.ERROR);
    analysisErrorCleaned.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisErrorCleaned.setAnalysisCleanedState(AnalysisCleanedState.CLEANED);
    analysisPrepared.setRemoteAnalysisId(ANALYSIS_ID);
    preparedWorkflow = new PreparedWorkflowGalaxy(ANALYSIS_ID, LIBRARY_ID, workflowInputsGalaxy);
    when(galaxyWorkflowService.uploadGalaxyWorkflow(workflowFile)).thenReturn(REMOTE_WORKFLOW_ID);
    when(galaxyHistoriesService.deleteHistory(ANALYSIS_ID)).thenReturn(new HistoryDeleteResponse());
}
Also used : AnalysisExecutionServiceGalaxyAsync(ca.corefacility.bioinformatics.irida.service.analysis.execution.galaxy.AnalysisExecutionServiceGalaxyAsync) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) AnalysisExecutionServiceGalaxy(ca.corefacility.bioinformatics.irida.service.analysis.execution.galaxy.AnalysisExecutionServiceGalaxy) AnalysisExecutionServiceGalaxyCleanupAsync(ca.corefacility.bioinformatics.irida.service.analysis.execution.galaxy.AnalysisExecutionServiceGalaxyCleanupAsync) PreparedWorkflowGalaxy(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.PreparedWorkflowGalaxy) HistoryDeleteResponse(com.github.jmchilton.blend4j.galaxy.beans.HistoryDeleteResponse) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Before(org.junit.Before)

Example 13 with SequencingObject

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

the class AnalysisCollectionServiceGalaxyIT method testGetSequenceFileSingleSamplesSuccess.

/**
 * Tests successfully getting a map of samples and sequence files (single).
 *
 * @throws DuplicateSampleException
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testGetSequenceFileSingleSamplesSuccess() throws DuplicateSampleException {
    Set<SequencingObject> sequenceFiles = Sets.newHashSet(databaseSetupGalaxyITService.setupSequencingObjectInDatabase(1L, sequenceFilePathA));
    Sample sample = sampleRepository.findOne(1L);
    SequencingObject sequenceFile = sequenceFiles.iterator().next();
    Map<Sample, SequencingObject> sampleSequenceFiles = sequencingObjectService.getUniqueSamplesForSequencingObjects(sequenceFiles);
    assertEquals("sampleSequenceFiles map has size != 1", 1, sampleSequenceFiles.size());
    assertEquals("sampleSequenceFiles map does not have sequenceFile " + sequenceFile + " corresponding to sample " + sample, sequenceFile, sampleSequenceFiles.get(sample));
}
Also used : SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 14 with SequencingObject

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

the class ProjectServiceImplIT method testGetProjectForSequencingObjectsAsUser.

@Test
@WithMockUser(username = "analysisuser", password = "password1", roles = "USER")
public void testGetProjectForSequencingObjectsAsUser() {
    SequencingObject read = sequencingObjectService.read(1L);
    Set<Project> projectsForSequencingObjects = projectService.getProjectsForSequencingObjects(ImmutableList.of(read));
    assertEquals("should have found 1 project", 1, projectsForSequencingObjects.size());
    Project project = projectsForSequencingObjects.iterator().next();
    assertEquals("should have found project 2", new Long(2), project.getId());
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 15 with SequencingObject

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

the class ProjectServiceImplIT method testGetProjectsForSequencingObjectsAsAdmin.

@Test
@WithMockUser(username = "admin", roles = "ADMIN")
public void testGetProjectsForSequencingObjectsAsAdmin() {
    SequencingObject read = sequencingObjectService.read(1L);
    Set<Project> projectsForSequencingObjects = projectService.getProjectsForSequencingObjects(ImmutableList.of(read));
    assertEquals("should have found 2 projects", 2, projectsForSequencingObjects.size());
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)61 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)29 SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)25 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)24 Test (org.junit.Test)24 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)16 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)14 WithMockUser (org.springframework.security.test.context.support.WithMockUser)14 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 Project (ca.corefacility.bioinformatics.irida.model.project.Project)11 AnalysisFastQC (ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC)11 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)10 SequencingRun (ca.corefacility.bioinformatics.irida.model.run.SequencingRun)8 Path (java.nio.file.Path)8 ModelMap (org.springframework.ui.ModelMap)8 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)6 Transactional (org.springframework.transaction.annotation.Transactional)6 IOException (java.io.IOException)5 List (java.util.List)5 Logger (org.slf4j.Logger)5