use of ca.corefacility.bioinformatics.irida.model.assembly.GenomeAssembly in project irida by phac-nml.
the class SamplesControllerTest method testRemoveGenomeAssemblyFromSample.
@Test
public void testRemoveGenomeAssemblyFromSample() {
Long sampleId = 1L;
Long assemblyId = 2L;
GenomeAssembly genomeAssembly = TestDataFactory.constructGenomeAssembly();
Sample sample = new Sample();
when(sampleService.read(sampleId)).thenReturn(sample);
when(sampleService.getGenomeAssemblyForSample(sample, assemblyId)).thenReturn(genomeAssembly);
when(updateSamplePermission.isAllowed(any(Authentication.class), eq(sample))).thenReturn(true);
RedirectAttributesModelMap attributes = new RedirectAttributesModelMap();
HttpServletRequest request = new MockHttpServletRequest();
controller.removeGenomeAssemblyFromSample(attributes, sampleId, assemblyId, request, Locale.US);
verify(sampleService).removeGenomeAssemblyFromSample(sample, assemblyId);
}
use of ca.corefacility.bioinformatics.irida.model.assembly.GenomeAssembly in project irida by phac-nml.
the class SamplesController method downloadAssembly.
/**
* Downloads an {@link GenomeAssembly} associated with a sample.
*
* @param sampleId
* Id for the sample containing the assembly to download.
* @param assemblyId
* The id for the assembly.
* @param response
* {@link HttpServletResponse}
* @throws IOException
* if we can't write the file to the response.
*/
@RequestMapping("/samples/download/{sampleId}/assembly/{assemblyId}")
public void downloadAssembly(@PathVariable Long sampleId, @PathVariable Long assemblyId, HttpServletResponse response) throws IOException {
Sample sample = sampleService.read(sampleId);
GenomeAssembly genomeAssembly = sampleService.getGenomeAssemblyForSample(sample, assemblyId);
Path path = genomeAssembly.getFile();
response.setHeader("Content-Disposition", "attachment; filename=\"" + genomeAssembly.getLabel() + "\"");
Files.copy(path, response.getOutputStream());
response.flushBuffer();
}
use of ca.corefacility.bioinformatics.irida.model.assembly.GenomeAssembly in project irida by phac-nml.
the class SamplesController method getSampleFiles.
/**
* Get the page that shows the files belonging to that sample.
*
* @param model
* Spring {@link Model}
* @param projectId
* the id of the {@link Project} the sample is in
* @param sampleId
* Sample id
* @return a Map representing all files (pairs and singles) for the sample.
*/
@RequestMapping(value = { "/projects/{projectId}/samples/{sampleId}/sequenceFiles" })
public String getSampleFiles(final Model model, @PathVariable Long projectId, @PathVariable Long sampleId) {
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);
Collection<SampleGenomeAssemblyJoin> genomeAssemblyJoins = sampleService.getAssembliesForSample(sample);
logger.trace("Assembly joins " + genomeAssemblyJoins);
List<GenomeAssembly> genomeAssemblies = genomeAssemblyJoins.stream().map(SampleGenomeAssemblyJoin::getObject).collect(Collectors.toList());
List<SequencingObject> filePairs = filePairJoins.stream().map(SampleSequencingObjectJoin::getObject).collect(Collectors.toList());
// get the project if available
Project project = null;
if (projectId != null) {
project = projectService.read(projectId);
}
// add project to qc entries and filter any unavailable entries
for (SequencingObject f : filePairs) {
enhanceQcEntries(f, project);
}
for (SampleSequencingObjectJoin f : singleFileJoins) {
enhanceQcEntries(f.getObject(), project);
}
// SequenceFile
model.addAttribute("paired_end", filePairs);
model.addAttribute("single_end", singleFileJoins);
// assemblies
model.addAttribute("assemblies", genomeAssemblies);
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 SAMPLE_FILES_PAGE;
}
Aggregations