Search in sources :

Example 21 with SequenceFile

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

the class SequenceFilePairConcatenatorTest method testConcatenateFiles.

@Test
public void testConcatenateFiles() throws IOException, ConcatenateException {
    String newFileName = "newFile";
    SequenceFile original1 = createSequenceFile("testFile_F");
    SequenceFile original2 = createSequenceFile("testFile_R");
    SequenceFile original3 = createSequenceFile("testFile2_F");
    SequenceFile original4 = createSequenceFile("testFile2_R");
    long originalLength = original1.getFile().toFile().length();
    SequenceFilePair f1 = new SequenceFilePair(original1, original2);
    SequenceFilePair f2 = new SequenceFilePair(original3, original4);
    SequenceFilePair concatenateFiles = concat.concatenateFiles(Lists.newArrayList(f1, f2), newFileName);
    SequenceFile forward = concatenateFiles.getForwardSequenceFile();
    SequenceFile reverse = concatenateFiles.getReverseSequenceFile();
    assertTrue("file exists", Files.exists(forward.getFile()));
    assertTrue("file exists", Files.exists(reverse.getFile()));
    long newFileSize = forward.getFile().toFile().length();
    assertEquals("new file should be 2x size of originals", originalLength * 2, newFileSize);
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) Test(org.junit.Test)

Example 22 with SequenceFile

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

the class SingleEndSequenceFileConcatenatorTest method testConcatenateFiles.

@Test
public void testConcatenateFiles() throws IOException, ConcatenateException {
    String newFileName = "newFile";
    SequenceFile original1 = createSequenceFile("testFile");
    SequenceFile original2 = createSequenceFile("testFile2");
    long originalLength = original1.getFile().toFile().length();
    SingleEndSequenceFile f1 = new SingleEndSequenceFile(original1);
    SingleEndSequenceFile f2 = new SingleEndSequenceFile(original2);
    SingleEndSequenceFile concatenateFiles = concat.concatenateFiles(Lists.newArrayList(f1, f2), newFileName);
    SequenceFile newSeqFile = concatenateFiles.getSequenceFile();
    assertTrue("file exists", Files.exists(newSeqFile.getFile()));
    long newFileSize = newSeqFile.getFile().toFile().length();
    assertEquals("new file should be 2x size of originals", originalLength * 2, newFileSize);
}
Also used : 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 23 with SequenceFile

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

the class AssemblyFileProcessorTest method testAssembleFile.

@Test
public void testAssembleFile() {
    Long sequenceFileId = 1L;
    SequenceFilePair pair = new SequenceFilePair(new SequenceFile(Paths.get("file_R1_1.fastq.gz")), new SequenceFile(Paths.get("file_R2_1.fastq.gz")));
    Sample sample = new Sample();
    Project project = new Project();
    project.setAssembleUploads(true);
    when(objectRepository.findOne(sequenceFileId)).thenReturn(pair);
    when(ssoRepository.getSampleForSequencingObject(pair)).thenReturn(new SampleSequencingObjectJoin(sample, pair));
    when(psjRepository.getProjectForSample(sample)).thenReturn(ImmutableList.of(new ProjectSampleJoin(project, sample, true)));
    assertTrue("should want to assemble file", processor.shouldProcessFile(sequenceFileId));
    processor.process(pair);
    verify(submissionRepository).save(any(AnalysisSubmission.class));
}
Also used : ProjectSampleJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) Project(ca.corefacility.bioinformatics.irida.model.project.Project) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) Test(org.junit.Test)

Example 24 with SequenceFile

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

the class AssemblyFileProcessorTest method testOneProjectEnabled.

@Test
public void testOneProjectEnabled() {
    SequenceFilePair pair = new SequenceFilePair(new SequenceFile(Paths.get("file_R1_1.fastq.gz")), new SequenceFile(Paths.get("file_R2_1.fastq.gz")));
    Sample sample = new Sample();
    Project project = new Project();
    project.setAssembleUploads(true);
    Project disabledProject = new Project();
    disabledProject.setAssembleUploads(false);
    when(ssoRepository.getSampleForSequencingObject(pair)).thenReturn(new SampleSequencingObjectJoin(sample, pair));
    when(psjRepository.getProjectForSample(sample)).thenReturn(ImmutableList.of(new ProjectSampleJoin(disabledProject, sample, true), new ProjectSampleJoin(project, sample, true)));
    processor.process(pair);
    verify(submissionRepository).save(any(AnalysisSubmission.class));
}
Also used : ProjectSampleJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) Project(ca.corefacility.bioinformatics.irida.model.project.Project) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) Test(org.junit.Test)

Example 25 with SequenceFile

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

the class ChecksumFileProcessorTest method testChecksumCreated.

@Test
public void testChecksumCreated() throws IOException {
    final SequenceFile sf = constructSequenceFile();
    SingleEndSequenceFile so = new SingleEndSequenceFile(sf);
    fileProcessor.process(so);
    ArgumentCaptor<SequenceFile> fileCaptor = ArgumentCaptor.forClass(SequenceFile.class);
    verify(sequenceFileRepository).saveMetadata(fileCaptor.capture());
    SequenceFile file = fileCaptor.getValue();
    assertEquals("checksums should be equal", CHECKSUM, file.getUploadSha256());
}
Also used : 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)

Aggregations

SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)111 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)84 Test (org.junit.Test)61 Path (java.nio.file.Path)50 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)39 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)31 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)25 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)20 Project (ca.corefacility.bioinformatics.irida.model.project.Project)15 AnalysisFastQC (ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC)15 WithMockUser (org.springframework.security.test.context.support.WithMockUser)13 IOException (java.io.IOException)11 SequencingRun (ca.corefacility.bioinformatics.irida.model.run.SequencingRun)9 ArrayList (java.util.ArrayList)9 ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)8 GZIPOutputStream (java.util.zip.GZIPOutputStream)8 Link (org.springframework.hateoas.Link)8 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)7 OutputStream (java.io.OutputStream)7 Before (org.junit.Before)7