Search in sources :

Example 1 with QCEntry

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);
}
Also used : QCEntry(ca.corefacility.bioinformatics.irida.model.sample.QCEntry)

Example 2 with QCEntry

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());
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) CoverageQCEntry(ca.corefacility.bioinformatics.irida.model.sample.CoverageQCEntry) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) CoverageQCEntry(ca.corefacility.bioinformatics.irida.model.sample.CoverageQCEntry) QCEntry(ca.corefacility.bioinformatics.irida.model.sample.QCEntry) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) AnalysisFastQC(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC) Test(org.junit.Test)

Example 3 with QCEntry

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());
}
Also used : Path(java.nio.file.Path) Project(ca.corefacility.bioinformatics.irida.model.project.Project) CoverageQCEntry(ca.corefacility.bioinformatics.irida.model.sample.CoverageQCEntry) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SequencingRun(ca.corefacility.bioinformatics.irida.model.run.SequencingRun) GZIPOutputStream(java.util.zip.GZIPOutputStream) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) GZIPOutputStream(java.util.zip.GZIPOutputStream) OutputStream(java.io.OutputStream) CoverageQCEntry(ca.corefacility.bioinformatics.irida.model.sample.CoverageQCEntry) FileProcessorErrorQCEntry(ca.corefacility.bioinformatics.irida.model.sample.FileProcessorErrorQCEntry) QCEntry(ca.corefacility.bioinformatics.irida.model.sample.QCEntry) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 4 with QCEntry

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());
}
Also used : Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) QCEntry(ca.corefacility.bioinformatics.irida.model.sample.QCEntry) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 5 with QCEntry

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);
}
Also used : Path(java.nio.file.Path) FileProcessorErrorQCEntry(ca.corefacility.bioinformatics.irida.model.sample.FileProcessorErrorQCEntry) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) GZIPOutputStream(java.util.zip.GZIPOutputStream) OutputStream(java.io.OutputStream) CoverageQCEntry(ca.corefacility.bioinformatics.irida.model.sample.CoverageQCEntry) FileProcessorErrorQCEntry(ca.corefacility.bioinformatics.irida.model.sample.FileProcessorErrorQCEntry) QCEntry(ca.corefacility.bioinformatics.irida.model.sample.QCEntry) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

QCEntry (ca.corefacility.bioinformatics.irida.model.sample.QCEntry)8 Test (org.junit.Test)6 CoverageQCEntry (ca.corefacility.bioinformatics.irida.model.sample.CoverageQCEntry)4 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)4 SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)4 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)4 WithMockUser (org.springframework.security.test.context.support.WithMockUser)4 Project (ca.corefacility.bioinformatics.irida.model.project.Project)3 FileProcessorErrorQCEntry (ca.corefacility.bioinformatics.irida.model.sample.FileProcessorErrorQCEntry)3 OutputStream (java.io.OutputStream)3 Path (java.nio.file.Path)3 GZIPOutputStream (java.util.zip.GZIPOutputStream)3 SequencingRun (ca.corefacility.bioinformatics.irida.model.run.SequencingRun)2 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)1 AnalysisFastQC (ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC)1 FileProcessingChain (ca.corefacility.bioinformatics.irida.processing.FileProcessingChain)1 FileProcessorException (ca.corefacility.bioinformatics.irida.processing.FileProcessorException)1 DefaultFileProcessingChain (ca.corefacility.bioinformatics.irida.processing.impl.DefaultFileProcessingChain)1 DTProjectSamples (ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTProjectSamples)1