use of ca.corefacility.bioinformatics.irida.model.sample.Sample in project irida by phac-nml.
the class SampleServiceImplIT method testGetSampleByExternalIdDuplicates.
@Test
@WithMockUser(username = "fbristow", roles = "ADMIN")
@DatabaseSetup("/ca/corefacility/bioinformatics/irida/service/impl/SampleServiceImplIT_duplicateSampleIds.xml")
public void testGetSampleByExternalIdDuplicates() {
Project p = projectService.read(7L);
Sample s = sampleService.getSampleBySampleName(p, "sample");
assertEquals("Should have retrieved sample with ID 1L.", Long.valueOf(7L), s.getId());
}
use of ca.corefacility.bioinformatics.irida.model.sample.Sample in project irida by phac-nml.
the class SampleServiceImplIT method testMergeSamplesIntoSample1.
/**
* Straightforward merging of samples all belonging to the same project.
*/
@Test
@WithMockUser(username = "fbristow", roles = "ADMIN")
public void testMergeSamplesIntoSample1() {
Sample mergeInto = sampleService.read(1L);
Sample sample2 = sampleService.read(2L);
Sample sample3 = sampleService.read(3L);
Project p = projectService.read(1L);
assertEquals("Sample 1 should only have genome assembly 1", Lists.newArrayList(1L), sampleGenomeAssemblyJoinRepository.findBySample(mergeInto).stream().map(t -> t.getObject().getId()).collect(Collectors.toList()));
assertEquals("Sample 2 should only have genome assembly 2", Lists.newArrayList(2L), sampleGenomeAssemblyJoinRepository.findBySample(sample2).stream().map(t -> t.getObject().getId()).collect(Collectors.toList()));
assertTrue("Sample 3 should have no genome assemblies before", sampleGenomeAssemblyJoinRepository.findBySample(sample3).isEmpty());
assertNotNull("Join between sample 2 and genome assembly 2 should exist", sampleGenomeAssemblyJoinRepository.findBySampleAndAssemblyId(2L, 2L));
Sample merged = sampleService.mergeSamples(p, mergeInto, Lists.newArrayList(sample2, sample3));
assertEquals("Merged sample should be same as mergeInto.", mergeInto, merged);
// merged samples should be deleted
assertSampleNotFound(2L);
assertSampleNotFound(3L);
assertNull("Join between sample 2 and genome assembly 2 should not exist", sampleGenomeAssemblyJoinRepository.findBySampleAndAssemblyId(2L, 2L));
// the merged sample should have 3 sequence files
assertEquals("Merged sample should have 3 sequence files", 3, objectService.getSequencingObjectsForSample(merged).size());
assertEquals("Sample 1 should only have genome assemblies 1 and 2", Lists.newArrayList(1L, 2L), sampleGenomeAssemblyJoinRepository.findBySample(mergeInto).stream().map(t -> t.getObject().getId()).collect(Collectors.toList()));
}
use of ca.corefacility.bioinformatics.irida.model.sample.Sample in project irida by phac-nml.
the class SampleServiceImplIT method testMergeSampleReject.
/**
* Sample merging should be rejected when samples are attempted to be joined
* where they do not share the same project.
*/
@Test(expected = IllegalArgumentException.class)
@WithMockUser(username = "fbristow", roles = "ADMIN")
public void testMergeSampleReject() {
Sample mergeInto = sampleService.read(1L);
Project p = projectService.read(1L);
sampleService.mergeSamples(p, mergeInto, Lists.newArrayList(sampleService.read(4L)));
}
use of ca.corefacility.bioinformatics.irida.model.sample.Sample in project irida by phac-nml.
the class SampleServiceImplIT method testEstimateCoverageForSampleAsUser.
/**
* Tests getting the coverage as a regular user.
*
* @throws SequenceFileAnalysisException
*/
@Test
@WithMockUser(username = "fbristow", roles = "USER")
public void testEstimateCoverageForSampleAsUser() throws SequenceFileAnalysisException {
Long sampleID = 1L;
Sample s = sampleService.read(sampleID);
double coverage = sampleService.estimateCoverageForSample(s, 500);
assertEquals(2.0, coverage, deltaFloatEquality);
}
use of ca.corefacility.bioinformatics.irida.model.sample.Sample in project irida by phac-nml.
the class SampleServiceImplIT method testGetGenomeAssemblyForSampleSuccess.
@Test
@WithMockUser(username = "fbristow", roles = "USER")
public void testGetGenomeAssemblyForSampleSuccess() throws AnalysisAlreadySetException {
Path expectedAssemblyPath = outputFileBaseDirectory.resolve("testfile.fasta");
Sample s = sampleService.read(1L);
GenomeAssembly genomeAssembly = sampleService.getGenomeAssemblyForSample(s, 1L);
assertEquals("should have same path for assembly", expectedAssemblyPath, genomeAssembly.getFile());
}
Aggregations