Search in sources :

Example 66 with SingleEndSequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.

the class DatabaseSetupGalaxyITService method setupSubmissionInDatabase.

/**
 * Sets up an AnalysisSubmission and saves all dependencies in database.
 * Saves with the given {@link AnalysisState}
 *
 * @param sampleId          The id of the sample to associate with the given sequence
 *                          file.
 * @param sequenceFilePath  The path to an input sequence file for this test.
 * @param referenceFilePath The path to an input reference file for this test.
 * @param iridaWorkflowId   The id of an irida workflow.
 * @param state             {@link AnalysisState} of the workflow
 * @param updateSamples     whether to run the sampleUpdater for this analysis
 * @return An {@link AnalysisSubmission} which has been saved to the
 * database.
 */
public AnalysisSubmission setupSubmissionInDatabase(long sampleId, Path sequenceFilePath, Path referenceFilePath, UUID iridaWorkflowId, AnalysisState state, boolean updateSamples) {
    SingleEndSequenceFile sequencingObject = (SingleEndSequenceFile) setupSequencingObjectInDatabase(sampleId, sequenceFilePath).get(0);
    waitForFilesToSettle(sequencingObject);
    sequencingObject = (SingleEndSequenceFile) sequencingObjectService.read(sequencingObject.getId());
    ReferenceFile referenceFile = referenceFileRepository.save(new ReferenceFile(referenceFilePath));
    AnalysisSubmission submission = AnalysisSubmission.builder(iridaWorkflowId).name("my analysis").inputFiles(Sets.newHashSet(sequencingObject)).referenceFile(referenceFile).updateSamples(updateSamples).build();
    submission.setAnalysisState(state);
    analysisSubmissionService.create(submission);
    return analysisSubmissionRepository.findOne(submission.getId());
}
Also used : ReferenceFile(ca.corefacility.bioinformatics.irida.model.project.ReferenceFile) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)

Example 67 with SingleEndSequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.

the class SequencingRunControllerTest method testGetFilesPage.

@SuppressWarnings("rawtypes")
@Test
public void testGetFilesPage() throws IOException {
    Long runId = 1L;
    ExtendedModelMap model = new ExtendedModelMap();
    SequencingRun sequencingRunEntity = new MiseqRun(SequencingRun.LayoutType.PAIRED_END, "");
    ImmutableSet<SequencingObject> files = ImmutableSet.of(new SingleEndSequenceFile(new SequenceFile()));
    when(sequencingRunService.read(runId)).thenReturn(sequencingRunEntity);
    when(objectService.getSequencingObjectsForSequencingRun(sequencingRunEntity)).thenReturn(files);
    String filesPage = controller.getFilesPage(runId, model);
    assertEquals(SequencingRunController.FILES_VIEW, filesPage);
    assertFalse(((Collection) model.get("sequencingObjects")).isEmpty());
    assertEquals(sequencingRunEntity, model.get("run"));
    assertTrue(model.containsKey("fileCount"));
    verify(sequencingRunService).read(runId);
    verify(objectService).getSequencingObjectsForSequencingRun(sequencingRunEntity);
}
Also used : MiseqRun(ca.corefacility.bioinformatics.irida.model.run.MiseqRun) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) ExtendedModelMap(org.springframework.ui.ExtendedModelMap) SequencingRun(ca.corefacility.bioinformatics.irida.model.run.SequencingRun) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Test(org.junit.Test)

Example 68 with SingleEndSequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.

the class TestDataFactory method generateSequencingObjectsForSample.

public static List<SampleSequencingObjectJoin> generateSequencingObjectsForSample(Sample sample) {
    List<SampleSequencingObjectJoin> join = new ArrayList<>();
    for (long i = 0; i < 5; i++) {
        Path path = Paths.get("/tmp/sequence-files/fake-file" + Math.random() + ".fast");
        SequenceFile file = new SequenceFile(path);
        file.setId(i);
        SingleEndSequenceFile obj = new SingleEndSequenceFile(file);
        obj.setId(i);
        join.add(new SampleSequencingObjectJoin(sample, obj));
    }
    return join;
}
Also used : Path(java.nio.file.Path) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) ArrayList(java.util.ArrayList) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)

Example 69 with SingleEndSequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile 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)

Example 70 with SingleEndSequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.

the class SequencingObjectServiceImplIT method testConcatenateSequenceFiles.

@Test
@WithMockUser(username = "admin", roles = "ADMIN")
public void testConcatenateSequenceFiles() throws IOException, InterruptedException, ConcatenateException {
    String newFileName = "newname";
    Sample sample = sampleService.read(1L);
    SequenceFile file1 = createSequenceFile("file1");
    SequenceFile file2 = createSequenceFile("file2");
    long originalLength = file1.getFile().toFile().length();
    SequencingObject so1 = new SingleEndSequenceFile(file1);
    SequencingObject so2 = new SingleEndSequenceFile(file2);
    SampleSequencingObjectJoin join1 = objectService.createSequencingObjectInSample(so1, sample);
    SampleSequencingObjectJoin join2 = objectService.createSequencingObjectInSample(so2, sample);
    // Wait 5 seconds. file processing should have run by then.
    Thread.sleep(5000);
    // re-read the original files so file processing will be complete
    so1 = objectService.read(join1.getObject().getId());
    so2 = objectService.read(join2.getObject().getId());
    Collection<SampleSequencingObjectJoin> originalSeqs = objectService.getSequencingObjectsForSample(sample);
    List<SequencingObject> fileSet = Lists.newArrayList(so1, so2);
    SampleSequencingObjectJoin concatenateSequences = objectService.concatenateSequences(fileSet, newFileName, sample, false);
    // Wait 5 seconds. file processing should have run by then.
    Thread.sleep(5000);
    Collection<SampleSequencingObjectJoin> newSeqs = objectService.getSequencingObjectsForSample(sample);
    // re-read the concatenated file so file processing will be complete
    concatenateSequences = sampleService.getSampleForSequencingObject(concatenateSequences.getObject());
    assertTrue("new seq collection should contain originals", newSeqs.containsAll(originalSeqs));
    assertTrue("new seq collection should contain new object", newSeqs.contains(concatenateSequences));
    assertEquals("new seq collection should have 1 more object", originalSeqs.size() + 1, newSeqs.size());
    SequencingObject newSeqObject = concatenateSequences.getObject();
    SequenceFile newFile = newSeqObject.getFiles().iterator().next();
    assertTrue("new file should contain new name", newFile.getFileName().contains(newFileName));
    long newFileSize = newFile.getFile().toFile().length();
    assertEquals("new file should be 2x size of originals", originalLength * 2, newFileSize);
}
Also used : SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)99 Test (org.junit.Test)72 SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)61 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)44 Path (java.nio.file.Path)33 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)24 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)22 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)20 WithMockUser (org.springframework.security.test.context.support.WithMockUser)18 Project (ca.corefacility.bioinformatics.irida.model.project.Project)17 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)17 AnalysisFastQC (ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC)12 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)11 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)10 ArrayList (java.util.ArrayList)10 SequencingRun (ca.corefacility.bioinformatics.irida.model.run.SequencingRun)8 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)8 History (com.github.jmchilton.blend4j.galaxy.beans.History)8 GZIPOutputStream (java.util.zip.GZIPOutputStream)8 ModelMap (org.springframework.ui.ModelMap)8