Search in sources :

Example 6 with SampleGenomeAssemblyJoin

use of ca.corefacility.bioinformatics.irida.model.joins.impl.SampleGenomeAssemblyJoin 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;
}
Also used : SampleGenomeAssemblyJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.SampleGenomeAssemblyJoin) Project(ca.corefacility.bioinformatics.irida.model.project.Project) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) GenomeAssembly(ca.corefacility.bioinformatics.irida.model.assembly.GenomeAssembly) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)

Aggregations

SampleGenomeAssemblyJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.SampleGenomeAssemblyJoin)6 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)5 GenomeAssembly (ca.corefacility.bioinformatics.irida.model.assembly.GenomeAssembly)3 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)2 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)2 Test (org.junit.Test)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 WithMockUser (org.springframework.security.test.context.support.WithMockUser)2 Transactional (org.springframework.transaction.annotation.Transactional)2 GenomeAssemblyFromAnalysis (ca.corefacility.bioinformatics.irida.model.assembly.GenomeAssemblyFromAnalysis)1 ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)1 Project (ca.corefacility.bioinformatics.irida.model.project.Project)1 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)1