Search in sources :

Example 66 with Sample

use of ca.corefacility.bioinformatics.irida.model.sample.Sample in project irida by phac-nml.

the class AnalysisCollectionServiceGalaxyIT method testUploadSequenceFilesPairedFailForward.

/**
 * Tests failing to upload a paired-end sequence file to Galaxy and
 * constructing a collection due to no found forward file.
 *
 * @throws ExecutionManagerException
 */
@Test(expected = NoSuchElementException.class)
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testUploadSequenceFilesPairedFailForward() throws ExecutionManagerException {
    History history = new History();
    history.setName("testUploadSequenceFilesPairedFailForward");
    HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
    LibrariesClient librariesClient = localGalaxy.getGalaxyInstanceAdmin().getLibrariesClient();
    History createdHistory = historiesClient.create(history);
    Library library = new Library();
    library.setName("testUploadSequenceFilesPairedFailForward");
    Library createdLibrary = librariesClient.createLibrary(library);
    Set<SequenceFilePair> sequenceFiles = Sets.newHashSet(databaseSetupGalaxyITService.setupSampleSequenceFileInDatabase(1L, pairSequenceFiles1AInvalidName, pairSequenceFiles2A));
    Map<Sample, IridaSequenceFilePair> sampleSequenceFilePairs = new HashMap<>(sequencingObjectService.getUniqueSamplesForSequencingObjects(sequenceFiles));
    analysisCollectionServiceGalaxy.uploadSequenceFilesPaired(sampleSequenceFilePairs, createdHistory, createdLibrary);
}
Also used : IridaSequenceFilePair(ca.corefacility.bioinformatics.irida.model.irida.IridaSequenceFilePair) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) IridaSequenceFilePair(ca.corefacility.bioinformatics.irida.model.irida.IridaSequenceFilePair) HashMap(java.util.HashMap) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) Library(com.github.jmchilton.blend4j.galaxy.beans.Library) History(com.github.jmchilton.blend4j.galaxy.beans.History) LibrariesClient(com.github.jmchilton.blend4j.galaxy.LibrariesClient) HistoriesClient(com.github.jmchilton.blend4j.galaxy.HistoriesClient) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 67 with Sample

use of ca.corefacility.bioinformatics.irida.model.sample.Sample 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 68 with Sample

use of ca.corefacility.bioinformatics.irida.model.sample.Sample in project irida by phac-nml.

the class AnalysisWorkspaceServiceGalaxyTest method setup.

/**
 * Sets up variables for testing.
 *
 * @throws IOException
 * @throws GalaxyDatasetException
 * @throws UploadException
 */
@Before
public void setup() throws IOException, UploadException, GalaxyDatasetException {
    MockitoAnnotations.initMocks(this);
    sFileA = new SequenceFile(createTempFile("fileA", "fastq"));
    sFileB = new SequenceFile(createTempFile("fileB", "fastq"));
    sFileC = new SequenceFile(createTempFile("fileC", "fastq"));
    sObjA = new SingleEndSequenceFile(sFileA);
    sObjB = new SingleEndSequenceFile(sFileB);
    sObjC = new SingleEndSequenceFile(sFileC);
    sequenceFilePair = new SequenceFilePair(sFileB, sFileC);
    singleEndSequenceFile = sObjA;
    Sample sampleA = new Sample();
    sampleA.setSampleName("SampleA");
    Sample sampleB = new Sample();
    sampleB.setSampleName("SampleB");
    Sample sampleC = new Sample();
    sampleC.setSampleName("SampleC");
    sampleSingleSequenceFileMap = ImmutableMap.of(sampleA, singleEndSequenceFile);
    sampleSequenceFilePairMap = ImmutableMap.of(sampleB, sequenceFilePair);
    sampleSequenceFilePairMapSampleA = ImmutableMap.of(sampleA, sequenceFilePair);
    refFile = createTempFile("reference", "fasta");
    referenceFile = new ReferenceFile(refFile);
    inputFiles = new HashSet<>();
    inputFiles.addAll(Arrays.asList(sObjA, sObjB, sObjC));
    submission = AnalysisSubmission.builder(workflowId).name("my analysis").inputFiles(inputFiles).referenceFile(referenceFile).build();
    workflowHistory = new History();
    workflowHistory.setId(HISTORY_ID);
    workflowLibrary = new Library();
    workflowLibrary.setId(LIBRARY_ID);
    workflowDetails = new WorkflowDetails();
    workflowDetails.setId(WORKFLOW_ID);
    workflowPreparation = new AnalysisWorkspaceServiceGalaxy(galaxyHistoriesService, galaxyWorkflowService, galaxyLibrariesService, iridaWorkflowsService, analysisCollectionServiceGalaxy, analysisProvenanceServiceGalaxy, analysisParameterServiceGalaxy, sequencingObjectService);
    output1Dataset = new Dataset();
    output1Dataset.setId("1");
    output1Dataset.setName("output1.txt");
    output2Dataset = new Dataset();
    output2Dataset.setId("2");
    output2Dataset.setName("output2.txt");
    collectionResponseSingle = new CollectionResponse();
    collectionResponseSingle.setId(COLLECTION_SINGLE_ID);
    collectionResponsePaired = new CollectionResponse();
    collectionResponsePaired.setId(COLLECTION_PAIRED_ID);
    singleInputFiles = Sets.newHashSet(singleEndSequenceFile);
    pairedInputFiles = Sets.newHashSet(sequenceFilePair);
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) ReferenceFile(ca.corefacility.bioinformatics.irida.model.project.ReferenceFile) AnalysisWorkspaceServiceGalaxy(ca.corefacility.bioinformatics.irida.service.analysis.workspace.galaxy.AnalysisWorkspaceServiceGalaxy) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) CollectionResponse(com.github.jmchilton.blend4j.galaxy.beans.collection.response.CollectionResponse) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Before(org.junit.Before)

Example 69 with Sample

use of ca.corefacility.bioinformatics.irida.model.sample.Sample in project irida by phac-nml.

the class ProjectServiceImplIT method testShareSamplesWithOwner.

@Test
@WithMockUser(username = "user1", roles = "USER")
public void testShareSamplesWithOwner() {
    Project source = projectService.read(2L);
    Project destination = projectService.read(10L);
    Sample sample1 = sampleService.read(1L);
    Set<Sample> samples = Sets.newHashSet(sample1);
    List<ProjectSampleJoin> copiedSamples = projectService.shareSamples(source, destination, samples, true);
    assertEquals(samples.size(), copiedSamples.size());
    copiedSamples.forEach(j -> {
        assertTrue("Project should be owner for sample", j.isOwner());
    });
    assertNotNull("Samples should still exist in source project", projectSampleJoinRepository.readSampleForProject(source, sample1));
    assertNotNull("Sample should exist in destination project", projectSampleJoinRepository.readSampleForProject(destination, sample1));
}
Also used : ProjectSampleJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin) Project(ca.corefacility.bioinformatics.irida.model.project.Project) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 70 with Sample

use of ca.corefacility.bioinformatics.irida.model.sample.Sample in project irida by phac-nml.

the class ProjectServiceImplIT method testMoveLockedSamplesWithOwnerFail.

@Test(expected = AccessDeniedException.class)
@WithMockUser(username = "user1", roles = "USER")
public void testMoveLockedSamplesWithOwnerFail() {
    Project source = projectService.read(2L);
    Project destination = projectService.read(10L);
    List<Join<Project, Sample>> samplesForProject = sampleService.getSamplesForProject(source);
    Set<Sample> samples = samplesForProject.stream().map(j -> j.getObject()).collect(Collectors.toSet());
    projectService.moveSamples(source, destination, samples, true);
}
Also used : ProjectRole(ca.corefacility.bioinformatics.irida.model.enums.ProjectRole) ProjectSampleJoinRepository(ca.corefacility.bioinformatics.irida.repositories.joins.project.ProjectSampleJoinRepository) ReferenceFileService(ca.corefacility.bioinformatics.irida.service.ReferenceFileService) URISyntaxException(java.net.URISyntaxException) Autowired(org.springframework.beans.factory.annotation.Autowired) ActiveProfiles(org.springframework.test.context.ActiveProfiles) ProjectService(ca.corefacility.bioinformatics.irida.service.ProjectService) TestExecutionListeners(org.springframework.test.context.TestExecutionListeners) SpringJUnit4ClassRunner(org.springframework.test.context.junit4.SpringJUnit4ClassRunner) AnalysisSubmissionService(ca.corefacility.bioinformatics.irida.service.AnalysisSubmissionService) Sort(org.springframework.data.domain.Sort) Path(java.nio.file.Path) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) SequencingObjectService(ca.corefacility.bioinformatics.irida.service.SequencingObjectService) ProjectWithoutOwnerException(ca.corefacility.bioinformatics.irida.exceptions.ProjectWithoutOwnerException) Collection(java.util.Collection) Set(java.util.Set) PageRequest(org.springframework.data.domain.PageRequest) IridaApiServicesConfig(ca.corefacility.bioinformatics.irida.config.services.IridaApiServicesConfig) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) List(java.util.List) WithMockUser(org.springframework.security.test.context.support.WithMockUser) RelatedProjectJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.RelatedProjectJoin) User(ca.corefacility.bioinformatics.irida.model.user.User) SampleService(ca.corefacility.bioinformatics.irida.service.sample.SampleService) Revision(org.springframework.data.history.Revision) Revisions(org.springframework.data.history.Revisions) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown) EntityExistsException(ca.corefacility.bioinformatics.irida.exceptions.EntityExistsException) EntityRevisionDeletedException(ca.corefacility.bioinformatics.irida.exceptions.EntityRevisionDeletedException) AnnotationConfigContextLoader(org.springframework.test.context.support.AnnotationConfigContextLoader) RunWith(org.junit.runner.RunWith) EntityNotFoundException(ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException) Join(ca.corefacility.bioinformatics.irida.model.joins.Join) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Direction(org.springframework.data.domain.Sort.Direction) DependencyInjectionTestExecutionListener(org.springframework.test.context.support.DependencyInjectionTestExecutionListener) ReferenceFile(ca.corefacility.bioinformatics.irida.model.project.ReferenceFile) Iterator(java.util.Iterator) WithSecurityContextTestExcecutionListener(org.springframework.security.test.context.support.WithSecurityContextTestExcecutionListener) ProjectSampleJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin) Files(java.nio.file.Files) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) IOException(java.io.IOException) Test(org.junit.Test) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) AccessDeniedException(org.springframework.security.access.AccessDeniedException) UserGroup(ca.corefacility.bioinformatics.irida.model.user.group.UserGroup) Project(ca.corefacility.bioinformatics.irida.model.project.Project) ProjectAnalysisSubmissionJoin(ca.corefacility.bioinformatics.irida.model.workflow.submission.ProjectAnalysisSubmissionJoin) UserGroupService(ca.corefacility.bioinformatics.irida.service.user.UserGroupService) DbUnitTestExecutionListener(com.github.springtestdbunit.DbUnitTestExecutionListener) Paths(java.nio.file.Paths) UserService(ca.corefacility.bioinformatics.irida.service.user.UserService) ContextConfiguration(org.springframework.test.context.ContextConfiguration) UnsupportedReferenceFileContentError(ca.corefacility.bioinformatics.irida.exceptions.UnsupportedReferenceFileContentError) IridaApiJdbcDataSourceConfig(ca.corefacility.bioinformatics.irida.config.data.IridaApiJdbcDataSourceConfig) Assert(org.junit.Assert) Project(ca.corefacility.bioinformatics.irida.model.project.Project) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) RelatedProjectJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.RelatedProjectJoin) Join(ca.corefacility.bioinformatics.irida.model.joins.Join) ProjectSampleJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin) ProjectAnalysisSubmissionJoin(ca.corefacility.bioinformatics.irida.model.workflow.submission.ProjectAnalysisSubmissionJoin) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)243 Test (org.junit.Test)162 Project (ca.corefacility.bioinformatics.irida.model.project.Project)114 WithMockUser (org.springframework.security.test.context.support.WithMockUser)71 ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)62 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)53 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)53 SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)41 Join (ca.corefacility.bioinformatics.irida.model.joins.Join)33 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)33 Path (java.nio.file.Path)28 ModelMap (org.springframework.ui.ModelMap)28 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)24 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)24 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)23 ArrayList (java.util.ArrayList)22 EntityNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException)17 User (ca.corefacility.bioinformatics.irida.model.user.User)14 HashMap (java.util.HashMap)14 RelatedProjectJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.RelatedProjectJoin)13