use of ca.corefacility.bioinformatics.irida.model.export.NcbiBioSampleFiles.Builder in project irida by phac-nml.
the class ProjectExportController method submitToNcbi.
/**
* Save an NCBI submission to the database
*
* @param projectId
* the ID of the {@link Project} for the submission
* @param submission
* A {@link SubmissionBody} describing the files to upload
* @param principal
* the user submitting the upload
* @return ID of the submission if successful
* @throws InterruptedException
* if thread was not successfully put to sleep
*/
@RequestMapping(value = "/projects/{projectId}/export/ncbi", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> submitToNcbi(@PathVariable Long projectId, @RequestBody SubmissionBody submission, Principal principal) throws InterruptedException {
Project project = projectService.read(projectId);
User submitter = userService.getUserByUsername(principal.getName());
List<NcbiBioSampleFiles> bioSampleFiles = new ArrayList<>();
for (BioSampleBody sample : submission.getSamples()) {
List<SingleEndSequenceFile> singleFiles = new ArrayList<>();
sequencingObjectService.readMultiple(sample.getSingle()).forEach(f -> singleFiles.add((SingleEndSequenceFile) f));
List<SequenceFilePair> paired = new ArrayList<>();
sequencingObjectService.readMultiple(sample.getPaired()).forEach(f -> paired.add((SequenceFilePair) f));
Builder sampleBuilder = new NcbiBioSampleFiles.Builder();
sampleBuilder.bioSample(sample.getBioSample()).files(singleFiles).pairs(paired).instrumentModel(sample.getInstrumentModel()).libraryConstructionProtocol(sample.getLibraryConstructionProtocol()).libraryName(sample.getLibraryName()).librarySelection(sample.getLibrarySelection()).librarySource(sample.getLibrarySource()).libraryStrategy(sample.getLibraryStrategy()).namespace(submission.getNamespace());
NcbiBioSampleFiles build = sampleBuilder.build();
bioSampleFiles.add(build);
}
NcbiExportSubmission ncbiExportSubmission = new NcbiExportSubmission(project, submitter, submission.getBioProject(), submission.getOrganization(), submission.getNamespace(), submission.getReleaseDate(), bioSampleFiles);
ncbiExportSubmission = exportSubmissionService.create(ncbiExportSubmission);
return ImmutableMap.of("submissionId", ncbiExportSubmission.getId());
}
Aggregations