use of ca.corefacility.bioinformatics.irida.model.sample.QCEntry in project irida by phac-nml.
the class SamplesController method enhanceQcEntries.
/**
* Adds the {@link Project} to any {@link QCEntry} within a
* {@link SequencingObject}. If the {@link QCEntry} reports as
* {@link QCEntryStatus#UNAVAILABLE} after being enhanced it is removed from
* the list
*
* @param obj
* the {@link SequencingObject} to enhance
* @param project
* the {@link Project} to add
*/
private void enhanceQcEntries(SequencingObject obj, Project project) {
Set<QCEntry> availableEntries = new HashSet<>();
if (obj.getQcEntries() != null) {
for (QCEntry q : obj.getQcEntries()) {
q.addProjectSettings(project);
if (!q.getStatus().equals(QCEntryStatus.UNAVAILABLE)) {
availableEntries.add(q);
}
}
}
obj.setQcEntries(availableEntries);
}
use of ca.corefacility.bioinformatics.irida.model.sample.QCEntry in project irida by phac-nml.
the class CoverageFileProcessorTest method testRemoveExistingEntry.
@Test
public void testRemoveExistingEntry() {
Project p = new Project();
p.setGenomeSize(100L);
p.setMinimumCoverage(2);
SequenceFile file = new SequenceFile();
SequencingObject o = new SingleEndSequenceFile(file);
AnalysisFastQC fqc = mock(AnalysisFastQC.class);
Long baseCount = 300L;
QCEntry existingQc = new CoverageQCEntry();
o.setQcEntries(Sets.newHashSet(existingQc));
when(analysisRepository.findFastqcAnalysisForSequenceFile(file)).thenReturn(fqc);
when(fqc.getTotalBases()).thenReturn(baseCount);
processor.process(o);
ArgumentCaptor<CoverageQCEntry> qcCaptor = ArgumentCaptor.forClass(CoverageQCEntry.class);
verify(qcEntryRepository).delete(existingQc);
verify(qcEntryRepository).save(qcCaptor.capture());
CoverageQCEntry qc = qcCaptor.getValue();
qc.addProjectSettings(p);
assertEquals("should show 3 times coverage", 3, qc.getCoverage());
assertEquals("should be positive coverage", QCEntryStatus.POSITIVE, qc.getStatus());
}
use of ca.corefacility.bioinformatics.irida.model.sample.QCEntry in project irida by phac-nml.
the class SequencingObjectServiceImplIT method testCoverage.
@Test
@WithMockUser(username = "admin", roles = "ADMIN")
public void testCoverage() throws IOException, InterruptedException {
Project project = projectService.read(1L);
project.setGenomeSize(3L);
project.setMinimumCoverage(2);
project = projectService.update(project);
Sample s = sampleService.read(1L);
SequenceFile sf = new SequenceFile();
Path sequenceFile = Files.createTempFile("TEMPORARY-SEQUENCE-FILE", ".gz");
OutputStream gzOut = new GZIPOutputStream(Files.newOutputStream(sequenceFile));
gzOut.write(FASTQ_FILE_CONTENTS);
gzOut.close();
sf.setFile(sequenceFile);
SingleEndSequenceFile so = new SingleEndSequenceFile(sf);
objectService.createSequencingObjectInSample(so, s);
SequencingRun mr = sequencingRunService.read(1L);
sequencingRunService.addSequencingObjectToSequencingRun(mr, so);
// Wait 10 seconds. file processing should have run by then.
Thread.sleep(10000);
Sample readSample = sampleService.read(s.getId());
List<QCEntry> qcEntries = sampleService.getQCEntriesForSample(readSample);
assertEquals("should be one qc entry", 1, qcEntries.size());
QCEntry qcEntry = qcEntries.iterator().next();
qcEntry.addProjectSettings(project);
assertTrue("should be coverage entry", qcEntry instanceof CoverageQCEntry);
assertEquals("qc should have passed", QCEntryStatus.POSITIVE, qcEntry.getStatus());
assertEquals("should be 6x coverage", "6x", qcEntry.getMessage());
project.setMinimumCoverage(10);
project = projectService.update(project);
// Wait 10 seconds. file processing should have run by then.
Thread.sleep(10000);
qcEntries = sampleService.getQCEntriesForSample(readSample);
assertEquals("should be one qc entry", 1, qcEntries.size());
qcEntry = qcEntries.iterator().next();
qcEntry.addProjectSettings(project);
assertTrue("should be coverage entry", qcEntry instanceof CoverageQCEntry);
assertEquals("qc should have failed", QCEntryStatus.NEGATIVE, qcEntry.getStatus());
}
use of ca.corefacility.bioinformatics.irida.model.sample.QCEntry in project irida by phac-nml.
the class SampleServiceImplIT method testGetQCEntiresForSample.
@Test
@WithMockUser(username = "fbristow", roles = "ADMIN")
public void testGetQCEntiresForSample() {
Sample s = sampleService.read(1L);
List<QCEntry> qcEntriesForSample = sampleService.getQCEntriesForSample(s);
assertEquals("should be 1 qc entry", 1L, qcEntriesForSample.size());
}
use of ca.corefacility.bioinformatics.irida.model.sample.QCEntry in project irida by phac-nml.
the class SequencingObjectServiceImplIT method testCreateCorruptSequenceFileInSample.
@Test
@WithMockUser(username = "fbristow", roles = "SEQUENCER")
public void testCreateCorruptSequenceFileInSample() throws IOException, InterruptedException {
Sample s = sampleService.read(1L);
SequenceFile sf = new SequenceFile();
Path sequenceFile = Files.createTempFile("TEMPORARY-SEQUENCE-FILE", ".gz");
OutputStream gzOut = Files.newOutputStream(sequenceFile);
gzOut.write("not a file".getBytes());
gzOut.close();
sf.setFile(sequenceFile);
SingleEndSequenceFile so = new SingleEndSequenceFile(sf);
objectService.createSequencingObjectInSample(so, s);
// Wait 5 seconds. file processing should have failed by then.
Thread.sleep(5000);
Sample readSample = sampleService.read(s.getId());
List<QCEntry> qcEntries = sampleService.getQCEntriesForSample(readSample);
assertFalse("should be a qc entry", qcEntries.isEmpty());
QCEntry qc = qcEntries.iterator().next();
assertTrue("should be a FileProcessorErrorQCEntry", qc instanceof FileProcessorErrorQCEntry);
}
Aggregations