use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject in project irida by phac-nml.
the class TestDataFactory method constructAnalysisSubmission.
public static AnalysisSubmission constructAnalysisSubmission() {
Set<SequencingObject> files = new HashSet<>();
files.add(constructSingleEndSequenceFile());
Long id = 5L;
final ReferenceFile rf = new ReferenceFile(files.iterator().next().getFiles().iterator().next().getFile());
rf.setId(id);
AnalysisSubmission analysisSubmission = AnalysisSubmission.builder(UUID.randomUUID()).name("submission-" + id).inputFiles(files).referenceFile(rf).build();
analysisSubmission.setId(id);
analysisSubmission.setAnalysisState(AnalysisState.COMPLETED);
try {
analysisSubmission.setAnalysis(constructAnalysis());
} catch (final AnalysisAlreadySetException e) {
// this should *never* happen, we just constructed
// AnalysisSubmission above.
fail();
}
return analysisSubmission;
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject in project irida by phac-nml.
the class SequencingObjectServiceImpl method create.
/**
* {@inheritDoc}
*/
@Override
@Transactional
@PreAuthorize("hasAnyRole('ROLE_SEQUENCER', 'ROLE_USER')")
public SequencingObject create(SequencingObject object) throws ConstraintViolationException, EntityExistsException {
SequencingRun sequencingRun = object.getSequencingRun();
if (sequencingRun != null) {
if (object instanceof SingleEndSequenceFile && sequencingRun.getLayoutType() != LayoutType.SINGLE_END) {
throw new IllegalArgumentException("Attempting to add a single end file to a non single end run");
} else if (object instanceof SequenceFilePair && sequencingRun.getLayoutType() != LayoutType.PAIRED_END) {
throw new IllegalArgumentException("Attempting to add a paired end file to a non paired end run");
}
}
for (SequenceFile file : object.getFiles()) {
file = sequenceFileRepository.save(file);
}
SequencingObject so = super.create(object);
fileProcessingChainExecutor.execute(new SequenceFileProcessorLauncher(fileProcessingChain, so.getId(), SecurityContextHolder.getContext()));
return so;
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject in project irida by phac-nml.
the class SampleServiceImpl method mergeSamples.
/**
* {@inheritDoc}
*/
@Override
@Transactional
@PreAuthorize("hasPermission(#project, 'isProjectOwner') and hasPermission(#mergeInto, 'canUpdateSample') and hasPermission(#toMerge, 'canUpdateSample')")
public Sample mergeSamples(Project project, Sample mergeInto, Collection<Sample> toMerge) {
// confirm that all samples are part of the same project:
confirmProjectSampleJoin(project, mergeInto);
logger.debug("Merging samples " + toMerge.stream().map(t -> t.getId()).collect(Collectors.toList()) + " into sample [" + mergeInto.getId() + "]");
for (Sample s : toMerge) {
confirmProjectSampleJoin(project, s);
List<SampleSequencingObjectJoin> sequencesForSample = ssoRepository.getSequencesForSample(s);
for (SampleSequencingObjectJoin join : sequencesForSample) {
SequencingObject sequencingObject = join.getObject();
ssoRepository.delete(join);
addSequencingObjectToSample(mergeInto, sequencingObject);
}
Collection<SampleGenomeAssemblyJoin> genomeAssemblyJoins = getAssembliesForSample(s);
for (SampleGenomeAssemblyJoin join : genomeAssemblyJoins) {
GenomeAssembly genomeAssembly = join.getObject();
logger.trace("Removing genome assembly [" + genomeAssembly.getId() + "] from sample [" + s.getId() + "]");
sampleGenomeAssemblyJoinRepository.delete(join);
logger.trace("Adding genome assembly [" + genomeAssembly.getId() + "] to sample [" + mergeInto.getId() + "]");
SampleGenomeAssemblyJoin newJoin = new SampleGenomeAssemblyJoin(mergeInto, genomeAssembly);
sampleGenomeAssemblyJoinRepository.save(newJoin);
}
// have to remove the sample to be deleted from its project:
ProjectSampleJoin readSampleForProject = psjRepository.readSampleForProject(project, s);
psjRepository.delete(readSampleForProject);
sampleRepository.delete(s.getId());
}
return mergeInto;
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject in project irida by phac-nml.
the class RESTAnalysisSubmissionController method getAnalysisInputUnpairedFiles.
/**
* get the {@link SequenceFile}s not in {@link SequenceFilePair}s used for
* the {@link AnalysisSubmission}
*
* @param identifier
* the {@link AnalysisSubmission} id
* @return list of {@link SequenceFile}s
*/
@RequestMapping("/{identifier}/sequenceFiles/unpaired")
public ModelMap getAnalysisInputUnpairedFiles(@PathVariable Long identifier) {
ModelMap map = new ModelMap();
AnalysisSubmission analysisSubmission = analysisSubmissionService.read(identifier);
Set<SingleEndSequenceFile> inputFilesSingleEnd = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SingleEndSequenceFile.class);
ResourceCollection<SequencingObject> resources = new ResourceCollection<>(inputFilesSingleEnd.size());
for (SingleEndSequenceFile file : inputFilesSingleEnd) {
SampleSequencingObjectJoin join = sampleService.getSampleForSequencingObject(file);
if (join != null) {
SequencingObject sequencingObject = join.getObject();
RESTSampleSequenceFilesController.addSequencingObjectLinks(sequencingObject, join.getSubject().getId());
resources.add(sequencingObject);
}
}
resources.add(linkTo(methodOn(RESTAnalysisSubmissionController.class).getAnalysisInputUnpairedFiles(identifier)).withSelfRel());
map.addAttribute(RESTGenericController.RESOURCE_NAME, resources);
return map;
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject in project irida by phac-nml.
the class AssemblyFileProcessor method shouldAssemble.
/**
* Check whether any {@link Project} associated with the
* {@link SequencingObject} is set to assemble
*
* @param object
* {@link SequencingObject} to check ot assemble
* @return true if it should assemble, false otherwise
*/
private boolean shouldAssemble(SequencingObject object) {
boolean assemble = false;
SampleSequencingObjectJoin sampleForSequencingObject = ssoRepository.getSampleForSequencingObject(object);
/*
* This is something that should only ever happen in tests, but added
* check with a warning
*/
if (sampleForSequencingObject != null) {
List<Join<Project, Sample>> projectForSample = psjRepository.getProjectForSample(sampleForSequencingObject.getSubject());
assemble = projectForSample.stream().anyMatch(j -> j.getSubject().getAssembleUploads());
} else {
logger.warn("Cannot find sample for sequencing object. Not assembling");
}
return assemble;
}
Aggregations