use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.
the class ProjectEventHandler method handleSampleRemovedEvent.
/**
* Create {@link SampleRemovedProjectEvent}s for any {@link Sample}s removed
* from a {@link Project}
*
* @param event
* the {@link MethodEvent} containing params from the method call
* @return a collectino of {@link SampleRemovedProjectEvent}s
*/
private Collection<SampleRemovedProjectEvent> handleSampleRemovedEvent(MethodEvent event) {
Collection<SampleRemovedProjectEvent> events = new ArrayList<>();
Optional<Object> projectOpt = Arrays.stream(event.getArgs()).filter(e -> e instanceof Project).findAny();
Optional<Object> sampleOpt = Arrays.stream(event.getArgs()).filter(e -> e instanceof Sample).findAny();
Optional<Object> sampleListOpt = Arrays.stream(event.getArgs()).filter(e -> e instanceof Iterable).findAny();
if (projectOpt.isPresent()) {
Project project = (Project) projectOpt.get();
if (sampleOpt.isPresent()) {
Sample sample = (Sample) sampleOpt.get();
events.add(eventRepository.save(new SampleRemovedProjectEvent(project, sample.getSampleName())));
} else if (sampleListOpt.isPresent()) {
@SuppressWarnings("unchecked") Iterable<Sample> samples = (Iterable<Sample>) sampleListOpt.get();
for (Sample sample : samples) {
events.add(eventRepository.save(new SampleRemovedProjectEvent(project, sample.getSampleName())));
}
}
}
return events;
}
use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.
the class ProjectEventHandler method handleIndividualSequenceFileAddedEvent.
/**
* Create {@link DataAddedToSampleProjectEvent} for all {@link Project}s a
* {@link Sample} belongs to
*
* @param join
* a {@link SampleSequencingObjectJoin} to turn into a
* {@link DataAddedToSampleProjectEvent}
*/
private Collection<DataAddedToSampleProjectEvent> handleIndividualSequenceFileAddedEvent(SampleSequencingObjectJoin join) {
Sample subject = join.getSubject();
Collection<DataAddedToSampleProjectEvent> events = new ArrayList<>();
List<Join<Project, Sample>> projectForSample = psjRepository.getProjectForSample(subject);
for (Join<Project, Sample> psj : projectForSample) {
events.add(eventRepository.save(new DataAddedToSampleProjectEvent(psj.getSubject(), subject)));
}
return events;
}
use of ca.corefacility.bioinformatics.irida.model.project.Project 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));
}
use of ca.corefacility.bioinformatics.irida.model.project.Project 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));
}
use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.
the class CoverageFileProcessorTest method testBadCoverage.
@Test
public void testBadCoverage() {
Project p = new Project();
p.setGenomeSize(100L);
p.setMinimumCoverage(5);
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 bad coverage", QCEntryStatus.NEGATIVE, qc.getStatus());
}
Aggregations