use of ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin in project irida by phac-nml.
the class SequencingObjectServiceImplIT method testGetUnpairedFilesForSampleWithNoPairs.
@Test
@WithMockUser(username = "admin", roles = "ADMIN")
public void testGetUnpairedFilesForSampleWithNoPairs() {
Sample s = sampleService.read(1L);
Collection<SampleSequencingObjectJoin> sequencesForSampleOfType = objectService.getSequencesForSampleOfType(s, SingleEndSequenceFile.class);
assertEquals(1, sequencesForSampleOfType.size());
SampleSequencingObjectJoin join = sequencesForSampleOfType.iterator().next();
assertEquals(new Long(2), join.getObject().getId());
}
use of ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin in project irida by phac-nml.
the class SampleServiceImplTest method testGetTotalBasesForSampleSuccessTwo.
/**
* Tests out successfully getting the total bases from a sample with two
* sequence files.
*
* @throws SequenceFileAnalysisException
* @throws AnalysisAlreadySetException
*/
@Test
public void testGetTotalBasesForSampleSuccessTwo() throws SequenceFileAnalysisException, AnalysisAlreadySetException {
Sample s1 = new Sample();
s1.setId(1L);
SequenceFile sf1 = new SequenceFile();
sf1.setId(2222L);
SequenceFile sf2 = new SequenceFile();
sf1.setId(3333L);
SampleSequencingObjectJoin join1 = new SampleSequencingObjectJoin(s1, new SingleEndSequenceFile(sf1));
SampleSequencingObjectJoin join2 = new SampleSequencingObjectJoin(s1, new SingleEndSequenceFile(sf2));
AnalysisFastQC analysisFastQC1 = AnalysisFastQC.sloppyBuilder().executionManagerAnalysisId("id").totalBases(1000L).build();
sf1.setFastQCAnalysis(analysisFastQC1);
AnalysisFastQC analysisFastQC2 = AnalysisFastQC.sloppyBuilder().executionManagerAnalysisId("id2").totalBases(1000L).build();
sf2.setFastQCAnalysis(analysisFastQC2);
when(ssoRepository.getSequencesForSample(s1)).thenReturn(Arrays.asList(join1, join2));
when(analysisRepository.findFastqcAnalysisForSequenceFile(sf1)).thenReturn(analysisFastQC1);
when(analysisRepository.findFastqcAnalysisForSequenceFile(sf2)).thenReturn(analysisFastQC2);
long actualBases = sampleService.getTotalBasesForSample(s1);
assertEquals(2000, actualBases);
}
use of ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin in project irida by phac-nml.
the class SampleServiceImplTest method testGetTotalBasesForSampleFailNoFastQC.
/**
* Tests out failing to get the total bases from a sample with one sequence
* file due to missing FastQC
*
* @throws SequenceFileAnalysisException
*/
@Test(expected = SequenceFileAnalysisException.class)
public void testGetTotalBasesForSampleFailNoFastQC() throws SequenceFileAnalysisException {
Sample s1 = new Sample();
s1.setId(1L);
SequenceFile sf1 = new SequenceFile();
sf1.setId(2222L);
SampleSequencingObjectJoin join = new SampleSequencingObjectJoin(s1, new SingleEndSequenceFile(sf1));
when(ssoRepository.getSequencesForSample(s1)).thenReturn(Arrays.asList(join));
sampleService.getTotalBasesForSample(s1);
}
use of ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin in project irida by phac-nml.
the class SequencingObjectServiceImpl method createSequencingObjectInSample.
/**
* {@inheritDoc}
*/
@Override
@Transactional
@PreAuthorize("hasPermission(#sample, 'canUpdateSample')")
@LaunchesProjectEvent(DataAddedToSampleProjectEvent.class)
public SampleSequencingObjectJoin createSequencingObjectInSample(SequencingObject seqObject, Sample sample) {
// create the sequencing object
seqObject = create(seqObject);
// save the new join
SampleSequencingObjectJoin sampleSequencingObjectJoin = new SampleSequencingObjectJoin(sample, seqObject);
return ssoRepository.save(sampleSequencingObjectJoin);
}
use of ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin in project irida by phac-nml.
the class SequencingObjectServiceImpl method concatenateSequences.
/**
* {@inheritDoc}
*/
@Override
@PreAuthorize("hasPermission(#toJoin, 'canReadSequencingObject') and hasPermission(#targetSample, 'canUpdateSample')")
@Transactional
public SampleSequencingObjectJoin concatenateSequences(List<SequencingObject> toJoin, String filename, Sample targetSample, boolean removeOriginals) throws ConcatenateException {
SequencingObjectConcatenator<? extends SequencingObject> concatenator = SequencingObjectConcatenatorFactory.getConcatenator(toJoin);
SequencingObject concatenated = concatenator.concatenateFiles(toJoin, filename);
SampleSequencingObjectJoin created = createSequencingObjectInSample(concatenated, targetSample);
concatenationRepository.save(new SequenceConcatenation(created.getObject(), toJoin));
if (removeOriginals) {
for (SequencingObject obj : toJoin) {
SampleSequencingObjectJoin sampleForSequencingObject = ssoRepository.getSampleForSequencingObject(obj);
ssoRepository.delete(sampleForSequencingObject);
}
}
return created;
}
Aggregations