Search in sources :

Example 46 with Sample

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

the class SISTRSampleUpdaterTest method testUpdaterNoFile.

@Test(expected = PostProcessingException.class)
public void testUpdaterNoFile() throws PostProcessingException, AnalysisAlreadySetException {
    ImmutableMap<String, String> expectedResults = ImmutableMap.of("SISTR serovar", "Enteritidis", "SISTR cgMLST Subspecies", "enterica", "SISTR QC Status", "PASS");
    Path outputPath = Paths.get("src/test/resources/files/not_really_a_file.txt");
    AnalysisOutputFile outputFile = new AnalysisOutputFile(outputPath, null, null, null);
    Analysis analysis = new Analysis(null, ImmutableMap.of("sistr-predictions", outputFile), null, null);
    AnalysisSubmission submission = AnalysisSubmission.builder(UUID.randomUUID()).inputFiles(ImmutableSet.of(new SingleEndSequenceFile(null))).build();
    submission.setAnalysis(analysis);
    Sample sample = new Sample();
    sample.setId(1L);
    updater.update(Lists.newArrayList(sample), submission);
}
Also used : Path(java.nio.file.Path) Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) AnalysisOutputFile(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Test(org.junit.Test)

Example 47 with Sample

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

the class AssemblyFileProcessorTest method testAssembleFile.

@Test
public void testAssembleFile() {
    Long sequenceFileId = 1L;
    SequenceFilePair pair = new SequenceFilePair(new SequenceFile(Paths.get("file_R1_1.fastq.gz")), new SequenceFile(Paths.get("file_R2_1.fastq.gz")));
    Sample sample = new Sample();
    Project project = new Project();
    project.setAssembleUploads(true);
    when(objectRepository.findOne(sequenceFileId)).thenReturn(pair);
    when(ssoRepository.getSampleForSequencingObject(pair)).thenReturn(new SampleSequencingObjectJoin(sample, pair));
    when(psjRepository.getProjectForSample(sample)).thenReturn(ImmutableList.of(new ProjectSampleJoin(project, sample, true)));
    assertTrue("should want to assemble file", processor.shouldProcessFile(sequenceFileId));
    processor.process(pair);
    verify(submissionRepository).save(any(AnalysisSubmission.class));
}
Also used : ProjectSampleJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) Project(ca.corefacility.bioinformatics.irida.model.project.Project) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) Test(org.junit.Test)

Example 48 with Sample

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

the class AssemblyFileProcessorTest method testOneProjectEnabled.

@Test
public void testOneProjectEnabled() {
    SequenceFilePair pair = new SequenceFilePair(new SequenceFile(Paths.get("file_R1_1.fastq.gz")), new SequenceFile(Paths.get("file_R2_1.fastq.gz")));
    Sample sample = new Sample();
    Project project = new Project();
    project.setAssembleUploads(true);
    Project disabledProject = new Project();
    disabledProject.setAssembleUploads(false);
    when(ssoRepository.getSampleForSequencingObject(pair)).thenReturn(new SampleSequencingObjectJoin(sample, pair));
    when(psjRepository.getProjectForSample(sample)).thenReturn(ImmutableList.of(new ProjectSampleJoin(disabledProject, sample, true), new ProjectSampleJoin(project, sample, true)));
    processor.process(pair);
    verify(submissionRepository).save(any(AnalysisSubmission.class));
}
Also used : ProjectSampleJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) Project(ca.corefacility.bioinformatics.irida.model.project.Project) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) Test(org.junit.Test)

Example 49 with Sample

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

the class RESTProjectSamplesController method updateSample.

/**
 * Update a {@link Sample} details.
 *
 * @param sampleId
 *            the identifier of the {@link Sample}.
 * @param updatedFields
 *            the updated fields of the {@link Sample}.
 * @return a response including links to the {@link Project} and
 *         {@link Sample}.
 */
@RequestMapping(value = "/api/samples/{sampleId}", method = RequestMethod.PATCH, consumes = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE })
public ModelMap updateSample(@PathVariable Long sampleId, @RequestBody Map<String, Object> updatedFields) {
    ModelMap modelMap = new ModelMap();
    // issue an update request
    final Sample s = sampleService.updateFields(sampleId, updatedFields);
    addLinksForSample(Optional.empty(), s);
    modelMap.addAttribute(RESTGenericController.RESOURCE_NAME, s);
    return modelMap;
}
Also used : Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) ModelMap(org.springframework.ui.ModelMap) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 50 with Sample

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

the class RESTProjectSamplesController method getSample.

/**
 * Read a {@link Sample} by its id
 *
 * @param sampleId
 *            the id of the {@link Sample} to read
 * @return representation of the sample
 */
@RequestMapping(value = "/api/samples/{sampleId}", method = RequestMethod.GET)
public ModelMap getSample(@PathVariable Long sampleId) {
    ModelMap modelMap = new ModelMap();
    Sample s = sampleService.read(sampleId);
    addLinksForSample(Optional.empty(), s);
    modelMap.addAttribute(RESTGenericController.RESOURCE_NAME, s);
    return modelMap;
}
Also used : Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) ModelMap(org.springframework.ui.ModelMap) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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