Search in sources :

Example 1 with SequencingRun

use of ca.corefacility.bioinformatics.irida.model.run.SequencingRun in project irida by phac-nml.

the class SequencingRunController method getPageDetails.

private Model getPageDetails(Long runId, Model model) {
    SequencingRun run = sequencingRunService.read(runId);
    Set<SequencingObject> sequencingObjectsForSequencingRun = objectService.getSequencingObjectsForSequencingRun(run);
    int fileCount = sequencingObjectsForSequencingRun.stream().mapToInt(o -> o.getFiles().size()).sum();
    model.addAttribute("sequencingObjects", sequencingObjectsForSequencingRun);
    model.addAttribute("fileCount", fileCount);
    model.addAttribute("run", run);
    return model;
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) java.util(java.util) SequencingObjectService(ca.corefacility.bioinformatics.irida.service.SequencingObjectService) ImmutableMap(com.google.common.collect.ImmutableMap) DataTablesRequest(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.config.DataTablesRequest) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) DTSequencingRun(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTSequencingRun) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) Controller(org.springframework.stereotype.Controller) SequencingRunService(ca.corefacility.bioinformatics.irida.service.SequencingRunService) Page(org.springframework.data.domain.Page) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) Collectors(java.util.stream.Collectors) SequencingRun(ca.corefacility.bioinformatics.irida.model.run.SequencingRun) Model(org.springframework.ui.Model) DataTablesResponseModel(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) User(ca.corefacility.bioinformatics.irida.model.user.User) Sort(org.springframework.data.domain.Sort) DataTablesParams(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams) MessageSource(org.springframework.context.MessageSource) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) DTSequencingRun(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTSequencingRun) SequencingRun(ca.corefacility.bioinformatics.irida.model.run.SequencingRun)

Example 2 with SequencingRun

use of ca.corefacility.bioinformatics.irida.model.run.SequencingRun 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 3 with SequencingRun

use of ca.corefacility.bioinformatics.irida.model.run.SequencingRun in project irida by phac-nml.

the class SequencingRunServiceImplIT method testAddDetachedRunToSequenceFile.

/**
 * This test simulates a bug that happens from the REST API when uploading
 * sequence files to samples, where a new sequence file is created, then
 * detached from a transaction.
 *
 * @throws IOException
 * @throws InterruptedException
 */
@Test
@WithMockUser(username = "fbristow", password = "password1", roles = "ADMIN")
public void testAddDetachedRunToSequenceFile() throws IOException, InterruptedException {
    final String SEQUENCE = "ACGTACGTN";
    final byte[] FASTQ_FILE_CONTENTS = ("@testread\n" + SEQUENCE + "\n+\n?????????\n@testread2\n" + SEQUENCE + "\n+\n?????????").getBytes();
    Path p = Files.createTempFile(null, null);
    Files.write(p, FASTQ_FILE_CONTENTS);
    SequenceFile sf = new SequenceFile();
    sf.setFile(p);
    SingleEndSequenceFile so = new SingleEndSequenceFile(sf);
    Sample sample = sampleService.read(1L);
    SequencingRun run = miseqRunService.read(2L);
    objectService.createSequencingObjectInSample(so, sample);
    miseqRunService.addSequencingObjectToSequencingRun(run, so);
    AnalysisFastQC analysis = null;
    do {
        try {
            analysis = analysisService.getFastQCAnalysisForSequenceFile(so, sf.getId());
        } catch (final EntityNotFoundException e) {
            logger.info("Fastqc still isn't finished, sleeping a bit.");
            Thread.sleep(1000);
        }
    } while (analysis == null);
    assertNotNull("FastQC analysis should have been created for sequence file.", analysis);
}
Also used : Path(java.nio.file.Path) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SequencingRun(ca.corefacility.bioinformatics.irida.model.run.SequencingRun) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) EntityNotFoundException(ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) AnalysisFastQC(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 4 with SequencingRun

use of ca.corefacility.bioinformatics.irida.model.run.SequencingRun in project irida by phac-nml.

the class SequencingRunServiceImplIT method testFindAll.

@Test
@WithMockUser(username = "user", password = "password1", roles = "USER")
public void testFindAll() {
    Iterable<SequencingRun> findAll = miseqRunService.findAll();
    List<SequencingRun> runs = Lists.newArrayList(findAll);
    assertEquals("user should be able to see 1 run", 1, runs.size());
    SequencingRun run = runs.iterator().next();
    assertEquals("id should be 1", new Long(1), run.getId());
}
Also used : SequencingRun(ca.corefacility.bioinformatics.irida.model.run.SequencingRun) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 5 with SequencingRun

use of ca.corefacility.bioinformatics.irida.model.run.SequencingRun in project irida by phac-nml.

the class SequencingRunServiceImplIT method testUpdateMiseqRunAsUserFail.

@Test(expected = AccessDeniedException.class)
@WithMockUser(username = "user", password = "password1", roles = "USER")
public void testUpdateMiseqRunAsUserFail() {
    // run 2 is not owned by "user"
    SequencingRun mr = miseqRunService.read(2L);
    mr.setDescription("different description");
    miseqRunService.update(mr);
}
Also used : SequencingRun(ca.corefacility.bioinformatics.irida.model.run.SequencingRun) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

SequencingRun (ca.corefacility.bioinformatics.irida.model.run.SequencingRun)25 Test (org.junit.Test)17 WithMockUser (org.springframework.security.test.context.support.WithMockUser)13 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)9 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)8 SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)8 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)8 MiseqRun (ca.corefacility.bioinformatics.irida.model.run.MiseqRun)7 Path (java.nio.file.Path)6 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)3 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)3 ModelMap (org.springframework.ui.ModelMap)3 EntityNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException)2 CoverageQCEntry (ca.corefacility.bioinformatics.irida.model.sample.CoverageQCEntry)2 FileProcessorErrorQCEntry (ca.corefacility.bioinformatics.irida.model.sample.FileProcessorErrorQCEntry)2 QCEntry (ca.corefacility.bioinformatics.irida.model.sample.QCEntry)2 User (ca.corefacility.bioinformatics.irida.model.user.User)2 AnalysisFastQC (ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC)2