use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject in project irida by phac-nml.
the class SequencingRunController method getPageDetails.
private Model getPageDetails(Long runId, Model model) {
SequencingRun run = sequencingRunService.read(runId);
Set<SequencingObject> sequencingObjectsForSequencingRun = objectService.getSequencingObjectsForSequencingRun(run);
int fileCount = sequencingObjectsForSequencingRun.stream().mapToInt(o -> o.getFiles().size()).sum();
model.addAttribute("sequencingObjects", sequencingObjectsForSequencingRun);
model.addAttribute("fileCount", fileCount);
model.addAttribute("run", run);
return model;
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject in project irida by phac-nml.
the class SamplesController method getConcatenatePage.
/**
* Get the page for concatenating {@link SequencingObject}s in a
* {@link Sample}
*
* @param sampleId
* the {@link Sample} to get files for
* @param model
* model for the view
* @return name of the files concatenate page
*/
@RequestMapping(value = { "/samples/{sampleId}/concatenate", "/projects/{projectId}/samples/{sampleId}/concatenate" }, method = RequestMethod.GET)
public String getConcatenatePage(@PathVariable Long sampleId, Model model) {
Sample sample = sampleService.read(sampleId);
model.addAttribute("sampleId", sampleId);
Collection<SampleSequencingObjectJoin> filePairJoins = sequencingObjectService.getSequencesForSampleOfType(sample, SequenceFilePair.class);
Collection<SampleSequencingObjectJoin> singleFileJoins = sequencingObjectService.getSequencesForSampleOfType(sample, SingleEndSequenceFile.class);
List<SequencingObject> filePairs = filePairJoins.stream().map(SampleSequencingObjectJoin::getObject).collect(Collectors.toList());
// SequenceFile
model.addAttribute("paired_end", filePairs);
model.addAttribute("single_end", singleFileJoins);
model.addAttribute(MODEL_ATTR_SAMPLE, sample);
model.addAttribute(MODEL_ATTR_CAN_MANAGE_SAMPLE, isProjectManagerForSample(sample));
model.addAttribute(MODEL_ATTR_ACTIVE_NAV, ACTIVE_NAV_FILES);
return FILES_CONCATENATE_PAGE;
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject in project irida by phac-nml.
the class SamplesController method concatenateSequenceFiles.
/**
* Concatenate a collection of {@link SequencingObject}s
*
* @param sampleId
* the id of the {@link Sample} to concatenate in
* @param objectIds
* the {@link SequencingObject} ids
* @param filename
* base of the new filename to create
* @param removeOriginals
* boolean whether to remove the original files
* @param model
* model for the view
* @param request
* the incoming {@link HttpServletRequest}
* @return redirect to the files page if successul
*/
@RequestMapping(value = { "/samples/{sampleId}/sequenceFiles/concatenate", "/projects/{projectId}/samples/{sampleId}/sequenceFiles/concatenate" }, method = RequestMethod.POST)
public String concatenateSequenceFiles(@PathVariable Long sampleId, @RequestParam(name = "seq") Set<Long> objectIds, @RequestParam(name = "filename") String filename, @RequestParam(name = "remove", defaultValue = "false", required = false) boolean removeOriginals, Model model, HttpServletRequest request) {
Sample sample = sampleService.read(sampleId);
Iterable<SequencingObject> readMultiple = sequencingObjectService.readMultiple(objectIds);
try {
sequencingObjectService.concatenateSequences(Lists.newArrayList(readMultiple), filename, sample, removeOriginals);
} catch (ConcatenateException ex) {
logger.error("Error concatenating files: ", ex);
model.addAttribute("concatenateError", true);
return getConcatenatePage(sampleId, model);
}
final String url = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
final String redirectUrl = url.substring(0, url.indexOf("/concatenate"));
return "redirect:" + redirectUrl;
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject in project irida by phac-nml.
the class SequenceFileController method createDefaultPageInfo.
/**
* Populates the model with the default information for a file.
*
* @param sequenceFileId
* Id for the sequence file.
* @param model
* {@link Model}
*/
private void createDefaultPageInfo(Long sequencingObjectId, Long sequenceFileId, Model model) {
SequencingObject seqObject = sequencingObjectService.read(sequencingObjectId);
SequenceFile file = seqObject.getFileWithId(sequenceFileId);
AnalysisFastQC fastQC = analysisService.getFastQCAnalysisForSequenceFile(seqObject, file.getId());
model.addAttribute("sequencingObject", seqObject);
model.addAttribute("file", file);
model.addAttribute("created", dateFormatter.print(file.getCreatedDate(), LocaleContextHolder.getLocale()));
model.addAttribute("fastQC", fastQC);
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject in project irida by phac-nml.
the class SampleServiceImplTest method testMergeSamples.
@Test
public void testMergeSamples() {
// For every sample in toMerge, the service should:
// 1. call SequenceFileRepository to get the sequence files in that
// sample,
// 2. call SequenceFileRepository to add the sequence files to
// mergeInto,
// 3. call SampleRepository to persist the sample as deleted.
final int SIZE = 3;
Sample s = s(1L);
Project project = p(1L);
Sample[] toMerge = new Sample[SIZE];
SequenceFile[] toMerge_sf = new SequenceFile[SIZE];
SequencingObject[] toMerge_so = new SequencingObject[SIZE];
SampleSequencingObjectJoin[] s_so_joins = new SampleSequencingObjectJoin[SIZE];
SampleSequencingObjectJoin[] s_so_original = new SampleSequencingObjectJoin[SIZE];
ProjectSampleJoin[] p_s_joins = new ProjectSampleJoin[SIZE];
List<Sample> mergeSamples = new ArrayList<>();
for (long i = 0; i < SIZE; i++) {
int p = (int) i;
toMerge[p] = s(i + 2);
mergeSamples.add(toMerge[p]);
toMerge_sf[p] = sf(i + 2);
toMerge_so[p] = so(i + 2);
s_so_joins[p] = new SampleSequencingObjectJoin(s, toMerge_so[p]);
p_s_joins[p] = new ProjectSampleJoin(project, toMerge[p], true);
List<Join<Project, Sample>> projectSampleJoins = new ArrayList<>();
projectSampleJoins.add(p_s_joins[p]);
List<SampleSequencingObjectJoin> sampleSeqObjectJoins = new ArrayList<>();
SampleSequencingObjectJoin join = new SampleSequencingObjectJoin(toMerge[p], toMerge_so[p]);
sampleSeqObjectJoins.add(join);
s_so_original[p] = join;
when(ssoRepository.getSequencesForSample(toMerge[p])).thenReturn(null);
when(ssoRepository.getSequencesForSample(toMerge[p])).thenReturn(sampleSeqObjectJoins);
when(ssoRepository.save(s_so_joins[p])).thenReturn(s_so_joins[p]);
when(ssoRepository.readObjectForSample(toMerge[p], toMerge_so[p].getId())).thenReturn(join);
when(psjRepository.getProjectForSample(toMerge[p])).thenReturn(projectSampleJoins);
// for deletion
when(psjRepository.readSampleForProject(project, toMerge[p])).thenReturn(p_s_joins[p]);
}
List<Join<Project, Sample>> joins = new ArrayList<>();
joins.add(new ProjectSampleJoin(project, s, true));
when(psjRepository.getProjectForSample(s)).thenReturn(joins);
Sample saved = sampleService.mergeSamples(project, s, mergeSamples);
verify(psjRepository).getProjectForSample(s);
for (int i = 0; i < SIZE; i++) {
verify(ssoRepository).getSequencesForSample(toMerge[i]);
verify(ssoRepository).save(s_so_joins[i]);
verify(ssoRepository).delete(s_so_original[i]);
verify(sampleRepository).delete(toMerge[i].getId());
verify(psjRepository).getProjectForSample(toMerge[i]);
verify(psjRepository).delete(p_s_joins[i]);
}
assertEquals("The saved sample should be the same as the sample to merge into.", s, saved);
}
Aggregations