Search in sources :

Example 51 with SequenceFile

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

the class ExportUploadServiceTest method createFakeSubmission.

/**
 * Create a fake submission for test uploads
 *
 * @return a {@link NcbiExportSubmission}
 * @throws IOException
 *             if the test file couldn't be created
 */
private NcbiExportSubmission createFakeSubmission() throws IOException {
    NcbiExportSubmission submission = new NcbiExportSubmission();
    submission.setId(1L);
    NcbiBioSampleFiles ncbiBioSampleFiles = new NcbiBioSampleFiles();
    Path tempFile = Files.createTempFile("sequencefile", ".fastq");
    SequenceFile sequenceFile = new SequenceFile(tempFile);
    sequenceFile.setId(1L);
    SingleEndSequenceFile singleFile = new SingleEndSequenceFile(sequenceFile);
    singleFile.setId(1L);
    ncbiBioSampleFiles.setFiles(Lists.newArrayList(singleFile));
    submission.setBioSampleFiles(Lists.newArrayList(ncbiBioSampleFiles));
    return submission;
}
Also used : Path(java.nio.file.Path) NcbiExportSubmission(ca.corefacility.bioinformatics.irida.model.NcbiExportSubmission) NcbiBioSampleFiles(ca.corefacility.bioinformatics.irida.model.export.NcbiBioSampleFiles) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)

Example 52 with SequenceFile

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

the class NcbiExportSubmissionServceTest method testCreatePairs.

@Test
public void testCreatePairs() {
    SequenceFile sequenceFile = new SequenceFile();
    NcbiBioSampleFiles ncbiBioSampleFiles = new NcbiBioSampleFiles("sample", Lists.newArrayList(), Lists.newArrayList(new SequenceFilePair(sequenceFile, sequenceFile)), null, "library_name", null, null, null, "library_construction_protocol", "namespace");
    NcbiExportSubmission submission = new NcbiExportSubmission(null, null, "bioProjectId", "organization", "ncbiNamespace", new Date(), Lists.newArrayList(ncbiBioSampleFiles));
    service.create(submission);
    verify(repository).save(submission);
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) NcbiBioSampleFiles(ca.corefacility.bioinformatics.irida.model.export.NcbiBioSampleFiles) NcbiExportSubmission(ca.corefacility.bioinformatics.irida.model.NcbiExportSubmission) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Date(java.util.Date) Test(org.junit.Test)

Example 53 with SequenceFile

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

the class SamplesControllerTest method testGetSampleFiles.

@SuppressWarnings("unchecked")
@Test
public void testGetSampleFiles() throws IOException {
    ExtendedModelMap model = new ExtendedModelMap();
    Long sampleId = 1L;
    Sample sample = new Sample();
    SequenceFile file = new SequenceFile(Paths.get("/tmp"));
    file.setId(2L);
    Project project = new Project();
    List<SampleSequencingObjectJoin> files = Lists.newArrayList(new SampleSequencingObjectJoin(sample, new SingleEndSequenceFile(file)));
    when(sampleService.read(sampleId)).thenReturn(sample);
    when(sequencingObjectService.getSequencesForSampleOfType(sample, SingleEndSequenceFile.class)).thenReturn(files);
    when(projectService.getProjectsForSample(sample)).thenReturn(Lists.newArrayList(new ProjectSampleJoin(project, sample, true)));
    when(updateSamplePermission.isAllowed(any(Authentication.class), eq(sample))).thenReturn(true);
    String sampleFiles = controller.getSampleFilesWithoutProject(model, sampleId);
    assertEquals(SamplesController.SAMPLE_FILES_PAGE, sampleFiles);
    assertTrue((boolean) model.get(SamplesController.MODEL_ATTR_CAN_MANAGE_SAMPLE));
    verify(sampleService).read(sampleId);
    verify(sequencingObjectService).getSequencesForSampleOfType(sample, SingleEndSequenceFile.class);
    verify(sequencingObjectService).getSequencesForSampleOfType(sample, SequenceFilePair.class);
}
Also used : ProjectSampleJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin) Project(ca.corefacility.bioinformatics.irida.model.project.Project) ExtendedModelMap(org.springframework.ui.ExtendedModelMap) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) Authentication(org.springframework.security.core.Authentication) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Test(org.junit.Test)

Example 54 with SequenceFile

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

the class SamplesControllerTest method testGetSampleFilesAsAdmin.

@Test
public void testGetSampleFilesAsAdmin() throws IOException {
    ExtendedModelMap model = new ExtendedModelMap();
    Long sampleId = 1L;
    Sample sample = new Sample();
    SequenceFile file = new SequenceFile(Paths.get("/tmp"));
    file.setId(2L);
    List<SampleSequencingObjectJoin> files = Lists.newArrayList(new SampleSequencingObjectJoin(sample, new SingleEndSequenceFile(file)));
    when(sampleService.read(sampleId)).thenReturn(sample);
    when(sequencingObjectService.getSequencesForSampleOfType(sample, SingleEndSequenceFile.class)).thenReturn(files);
    when(updateSamplePermission.isAllowed(any(Authentication.class), eq(sample))).thenReturn(true);
    String sampleFiles = controller.getSampleFilesWithoutProject(model, sampleId);
    assertEquals(SamplesController.SAMPLE_FILES_PAGE, sampleFiles);
    assertTrue((boolean) model.get(SamplesController.MODEL_ATTR_CAN_MANAGE_SAMPLE));
    verify(sampleService).read(sampleId);
    verify(sequencingObjectService).getSequencesForSampleOfType(sample, SingleEndSequenceFile.class);
    verify(sequencingObjectService).getSequencesForSampleOfType(sample, SequenceFilePair.class);
    verifyZeroInteractions(projectService);
}
Also used : ExtendedModelMap(org.springframework.ui.ExtendedModelMap) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) Authentication(org.springframework.security.core.Authentication) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Test(org.junit.Test)

Example 55 with SequenceFile

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

the class SamplesControllerTest method testRemoveFileFromSample.

@Test
public void testRemoveFileFromSample() {
    Long sampleId = 1L;
    Long fileId = 2L;
    Sample sample = new Sample();
    SequencingObject file = new SingleEndSequenceFile(new SequenceFile(Paths.get("/tmp")));
    when(sampleService.read(sampleId)).thenReturn(sample);
    when(sequencingObjectService.readSequencingObjectForSample(sample, fileId)).thenReturn(file);
    RedirectAttributesModelMap attributes = new RedirectAttributesModelMap();
    HttpServletRequest request = new MockHttpServletRequest();
    controller.removeSequencingObjectFromSample(attributes, sampleId, fileId, request, Locale.US);
    verify(sampleService).removeSequencingObjectFromSample(sample, file);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) RedirectAttributesModelMap(org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Test(org.junit.Test)

Aggregations

SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)111 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)84 Test (org.junit.Test)61 Path (java.nio.file.Path)50 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)39 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)31 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)25 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)20 Project (ca.corefacility.bioinformatics.irida.model.project.Project)15 AnalysisFastQC (ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC)15 WithMockUser (org.springframework.security.test.context.support.WithMockUser)13 IOException (java.io.IOException)11 SequencingRun (ca.corefacility.bioinformatics.irida.model.run.SequencingRun)9 ArrayList (java.util.ArrayList)9 ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)8 GZIPOutputStream (java.util.zip.GZIPOutputStream)8 Link (org.springframework.hateoas.Link)8 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)7 OutputStream (java.io.OutputStream)7 Before (org.junit.Before)7