use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile 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.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class CoverageFileProcessorTest method testGoodCoverage.
@Test
public void testGoodCoverage() {
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;
when(analysisRepository.findFastqcAnalysisForSequenceFile(file)).thenReturn(fqc);
when(fqc.getTotalBases()).thenReturn(baseCount);
processor.process(o);
ArgumentCaptor<CoverageQCEntry> qcCaptor = ArgumentCaptor.forClass(CoverageQCEntry.class);
verify(qcEntryRepository, times(0)).delete(any(QCEntry.class));
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.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class GzipFileProcessorTest method handleCompressedFileWithoutGzExtension.
@Test
public void handleCompressedFileWithoutGzExtension() throws IOException {
// the file processor should decompress the file, then update the
// sequence file in the database.
SequenceFile sf = constructSequenceFile();
SequenceFile sfUpdated = new SequenceFile();
sfUpdated.setFile(sf.getFile());
final Long id = 1L;
sf.setId(id);
// compress the file, update the sequence file reference
Path uncompressed = sf.getFile();
Path compressed = Files.createTempFile(null, null);
GZIPOutputStream out = new GZIPOutputStream(Files.newOutputStream(compressed));
Files.copy(uncompressed, out);
out.close();
sf.setFile(compressed);
SingleEndSequenceFile so = new SingleEndSequenceFile(sf);
fileProcessor.process(so);
ArgumentCaptor<SequenceFile> argument = ArgumentCaptor.forClass(SequenceFile.class);
verify(sequenceFileRepository).save(argument.capture());
SequenceFile modified = argument.getValue();
String uncompressedFileContents = new String(Files.readAllBytes(modified.getFile()));
assertEquals("uncompressed file and file in database should be the same.", FILE_CONTENTS, uncompressedFileContents);
Files.delete(uncompressed);
if (Files.exists(compressed)) {
Files.delete(compressed);
}
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class ProjectEventHandlerTest method testHandleSequenceFileAddedEventMultipleReturn.
@SuppressWarnings("unchecked")
@Test
public void testHandleSequenceFileAddedEventMultipleReturn() {
Class<? extends ProjectEvent> clazz = DataAddedToSampleProjectEvent.class;
Project project = new Project();
Sample sample = new Sample();
SequenceFile file = new SequenceFile();
SingleEndSequenceFile seqObj1 = new SingleEndSequenceFile(file);
SingleEndSequenceFile seqObj2 = new SingleEndSequenceFile(file);
SampleSequencingObjectJoin join1 = new SampleSequencingObjectJoin(sample, seqObj1);
SampleSequencingObjectJoin join2 = new SampleSequencingObjectJoin(sample, seqObj2);
when(psjRepository.getProjectForSample(sample)).thenReturn(Lists.newArrayList(new ProjectSampleJoin(project, sample, true)));
when(eventRepository.save(any(ProjectEvent.class))).thenReturn(new DataAddedToSampleProjectEvent(project, sample));
Object[] args = {};
MethodEvent methodEvent = new MethodEvent(clazz, Lists.newArrayList(join1, join2), args);
handler.delegate(methodEvent);
ArgumentCaptor<ProjectEvent> captor = ArgumentCaptor.forClass(ProjectEvent.class);
verify(eventRepository).save(captor.capture());
ProjectEvent event = captor.getValue();
assertTrue(event instanceof DataAddedToSampleProjectEvent);
verify(projectRepository).save(any(Project.class));
verify(sampleRepository).save(any(Sample.class));
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class GzipFileProcessorTest method handleUncompressedFile.
@Test
public void handleUncompressedFile() throws IOException {
// the file processor just shouldn't do *anything*.
SequenceFile sf = constructSequenceFile();
Path original = sf.getFile();
SingleEndSequenceFile so = new SingleEndSequenceFile(sf);
fileProcessor.process(so);
verify(sequenceFileRepository, times(0)).save(any(SequenceFile.class));
Files.deleteIfExists(sf.getFile());
Files.deleteIfExists(original);
}
Aggregations