Class UISampleService


  • @Component
    public class UISampleService
    extends java.lang.Object
    UI Service for samples
    • Method Detail

      • getSampleDetails

        public SampleDetails getSampleDetails​(java.lang.Long id,
                                              java.lang.Long projectId)
        Get full details for a Sample
        Parameters:
        id - Identifier for a Sample
        projectId - Idenfitifer for a Project
        Returns:
        SampleDetails
      • getSampleMetadata

        public SampleMetadata getSampleMetadata​(java.lang.Long id,
                                                java.lang.Long projectId)
        Get all the metadata for a Sample
        Parameters:
        id - Identifier for a Sample
        projectId - Identifier for a Project
        Returns:
        SampleMetadata
      • updateSampleDetails

        public java.lang.String updateSampleDetails​(java.lang.Long id,
                                                    UpdateSampleAttributeRequest request,
                                                    java.util.Locale locale)
        Update a field within the sample details.
        Parameters:
        id - Long identifier for the sample
        request - UpdateSampleAttributeRequest details about which field to update
        locale - Locale for the currently logged in user
        Returns:
        message indicating update status
      • updateDefaultSequencingObjectForSample

        public java.lang.String updateDefaultSequencingObjectForSample​(java.lang.Long sampleId,
                                                                       java.lang.Long sequencingObjectId,
                                                                       java.util.Locale locale)
        Update the default sequencing object for the sample
        Parameters:
        sampleId - The sample identifier
        sequencingObjectId - The sequencing object identifier
        locale - Locale for the currently logged in user
        Returns:
        message indicating if update was successful or not
      • updateDefaultGenomeAssemblyForSample

        public java.lang.String updateDefaultGenomeAssemblyForSample​(java.lang.Long sampleId,
                                                                     java.lang.Long genomeAssemblyId,
                                                                     java.util.Locale locale)
        Update the default genome assembly for the sample
        Parameters:
        sampleId - The sample identifier
        genomeAssemblyId - The genome assembly identifier
        locale - Locale for the currently logged in user
        Returns:
        message indicating if update was successful or not
      • addSampleMetadata

        public AddSampleMetadataResponse addSampleMetadata​(java.lang.Long sampleId,
                                                           AddSampleMetadataRequest addSampleMetadataRequest,
                                                           java.util.Locale locale)
        Add metadata for the sample
        Parameters:
        sampleId - Long identifier for the sample
        addSampleMetadataRequest - DTO containing sample metadata to add params
        locale - Locale for the currently logged in user
        Returns:
        AddSampleMetadataResponse with added metadata field, entry, restriction, and response message
      • removeSampleMetadata

        public java.lang.String removeSampleMetadata​(java.lang.Long projectId,
                                                     java.lang.Long metadataFieldId,
                                                     java.lang.Long metadataEntryId,
                                                     java.util.Locale locale)
        Remove metadata from the sample
        Parameters:
        projectId - The project id
        metadataFieldId - The metadata field id
        metadataEntryId - The metadata entry id
        locale - Locale for the currently logged in user
        Returns:
        message indicating deletion status
      • updateSampleMetadata

        public java.lang.String updateSampleMetadata​(java.lang.Long sampleId,
                                                     UpdateSampleMetadataRequest updateSampleMetadataRequest,
                                                     java.util.Locale locale)
        Update metadata for the sample
        Parameters:
        sampleId - The sample identifier
        updateSampleMetadataRequest - DTO containing sample metadata update params
        locale - Locale for the currently logged in user
        Returns:
        message indicating update status
      • getSampleFiles

        public SampleFiles getSampleFiles​(java.lang.Long sampleId,
                                          java.lang.Long projectId)
        Get the sequence files associated with a sample
        Parameters:
        sampleId - Identifier for a sample
        projectId - Identifier for the project the sample belong to
        Returns:
        All the sequencing files associated with the sample
      • getSampleExportFiles

        public SampleExportFiles getSampleExportFiles​(java.lang.Long sampleId,
                                                      java.lang.Long projectId)
      • getUpdatedSequencingObjects

        public SampleFiles getUpdatedSequencingObjects​(java.lang.Long sampleId,
                                                       java.util.List<java.lang.Long> sequencingObjectIds,
                                                       java.lang.Long projectId)
        Get updated sample sequencing objects for given sequencing object ids
        Parameters:
        sampleId - Identifier for a sample
        sequencingObjectIds - Identifiers for updated sequencing objects to get
        projectId - Identifier for the project the sample belongs to
        Returns:
        list of SampleFiles objects
      • deleteSequencingObjectFromSample

        public java.lang.String deleteSequencingObjectFromSample​(java.lang.Long sampleId,
                                                                 java.lang.Long sequencingObjectId,
                                                                 java.util.Locale locale)
        Remove a sequencing object linked to a Sample
        Parameters:
        sampleId - Identifier for a sample
        sequencingObjectId - Identifier for the sequencingObject
        locale - Locale for the currently logged in user
        Returns:
        String explaining to the user the results of the delete.
      • deleteGenomeAssemblyFromSample

        public java.lang.String deleteGenomeAssemblyFromSample​(java.lang.Long sampleId,
                                                               java.lang.Long genomeAssemblyId,
                                                               java.util.Locale locale)
        Remove a genome assembly linked to a Sample
        Parameters:
        sampleId - Identifier for a sample
        genomeAssemblyId - Identifier for the GenomeAssembly
        locale - Locale for the currently logged in user
        Returns:
        String explaining to the user the results of the delete.
      • downloadAssembly

        public void downloadAssembly​(java.lang.Long sampleId,
                                     java.lang.Long genomeAssemblyId,
                                     javax.servlet.http.HttpServletResponse response)
                              throws java.io.IOException
        Download a GenomeAssembly file
        Parameters:
        sampleId - Identifier for a sample
        genomeAssemblyId - Identifier for the genome assembly
        response - HttpServletResponse
        Throws:
        java.io.IOException - if the file cannot be read
      • getFilesForSamples

        public SampleFilesResponse getFilesForSamples​(java.util.List<java.lang.Long> sampleIds,
                                                      java.lang.Long projectId)
        Get details about the files belonging to a list of samples
        Parameters:
        sampleIds - - List of sample identifiers to get file details for
        projectId - - the project id that these samples belong to
        Returns:
        A map of sample id and their related file information
      • getPairedSequenceFilesForSample

        public java.util.List<SampleSequencingObjectFileModel> getPairedSequenceFilesForSample​(Sample sample,
                                                                                               Project project,
                                                                                               java.util.List<java.lang.Long> sequencingObjectIds)
        Get a list of paired end sequence files for a sample
        Parameters:
        sample - the Sample to get the files for.
        project - the Project the sample belongs to
        sequencingObjectIds - The ids of the sequencing objects to return
        Returns:
        list of paired end sequence files
      • getSingleEndSequenceFilesForSample

        public java.util.List<SampleSequencingObjectFileModel> getSingleEndSequenceFilesForSample​(Sample sample,
                                                                                                  Project project,
                                                                                                  java.util.List<java.lang.Long> sequencingObjectIds)
        Get a list of single end sequence files for a sample
        Parameters:
        sample - the Sample to get the files for.
        project - the Project the sample belongs to
        sequencingObjectIds - The ids of the sequencing objects to return
        Returns:
        list of single end sequence files
      • getFast5FilesForSample

        public java.util.List<SampleSequencingObjectFileModel> getFast5FilesForSample​(Sample sample,
                                                                                      Project project,
                                                                                      java.util.List<java.lang.Long> sequencingObjectIds)
        Get a list of fast5 sequence files for a sample
        Parameters:
        sample - the Sample to get the files for.
        project - the Project the sample belongs to
        sequencingObjectIds - The ids of the sequencing objects to return
        Returns:
        list of fast5 sequence files
      • getGenomeAssembliesForSample

        public java.util.List<SampleGenomeAssemblyFileModel> getGenomeAssembliesForSample​(Sample sample)
        Get any genome assemblies that are available for a sample
        Parameters:
        sample - the Sample to get the assemblies for
        Returns:
        a list of genome assembly files
      • uploadSequenceFiles

        public java.util.List<SampleSequencingObjectFileModel> uploadSequenceFiles​(java.lang.Long sampleId,
                                                                                   org.springframework.web.multipart.MultipartHttpServletRequest request)
                                                                            throws java.io.IOException
        Upload SequenceFile's to a sample
        Parameters:
        sampleId - The Sample id to upload to
        request - The current request which contains MultipartFile
        Returns:
        list of SampleSequencingObjectFileModel containing the newly created sequencing objects
        Throws:
        java.io.IOException - Exception thrown if there is an error handling the file.
      • uploadFast5Files

        public java.util.List<SampleSequencingObjectFileModel> uploadFast5Files​(java.lang.Long sampleId,
                                                                                org.springframework.web.multipart.MultipartHttpServletRequest request)
                                                                         throws java.io.IOException
        Upload Fast5Object's to a sample
        Parameters:
        sampleId - the ID of the sample to upload to
        request - The current request which contains MultipartFile
        Returns:
        list SampleSequencingObjectFileModel containing the newly created sequencing objects
        Throws:
        java.io.IOException - Exception thrown if there is an error handling the file.
      • getPagedProjectSamples

        public AntTableResponse<ProjectSampleTableItem> getPagedProjectSamples​(java.lang.Long projectId,
                                                                               ProjectSamplesTableRequest request,
                                                                               java.util.Locale locale)
        Get a page of samples based on the current state of the table options (filters, sort, and pagination)
        Parameters:
        projectId - Identifier for the current project.
        request - Information about the state of the table (filters, sort, and pagination).
        locale - current users Locale
        Returns:
        a page of samples
      • getMinimalSampleDetailsForFilteredProject

        @Transactional(readOnly=true)
        public java.util.List<ProjectCartSample> getMinimalSampleDetailsForFilteredProject​(java.lang.Long projectId,
                                                                                           ProjectSamplesTableRequest request)
        Get a list of all samples in the current project and associated project that have been filtered, return a minimal * representation of them.
        Parameters:
        projectId - Identifier for the current project.
        request - Details about the filters and associated projects
        Returns:
        list containing a minimal representation of the samples based on the filters
      • mergeSamples

        public java.lang.String mergeSamples​(java.lang.Long projectId,
                                             MergeRequest request,
                                             java.util.Locale locale)
                                      throws SampleMergeException
        Merge 1 or more samples into another sample
        Parameters:
        projectId - identifier for the current project
        request - details about the samples to merge
        locale - current users locale information
        Returns:
        result of the merge
        Throws:
        SampleMergeException - thrown if there is an error during the merge
      • uploadAssemblies

        public java.util.List<SampleGenomeAssemblyFileModel> uploadAssemblies​(java.lang.Long sampleId,
                                                                              org.springframework.web.multipart.MultipartHttpServletRequest request)
                                                                       throws java.io.IOException
        Upload GenomeAssembly's to a sample
        Parameters:
        sampleId - the ID of the sample to upload to
        request - The current request which contains MultipartFile
        Returns:
        list SampleGenomeAssemblyFileModel containing the newly created genome assemblies
        Throws:
        java.io.IOException - Exception thrown if there is an error handling the file.
      • removeSamplesFromProject

        public java.lang.String removeSamplesFromProject​(java.lang.Long projectId,
                                                         java.util.List<java.lang.Long> sampleIds)
        Remove 1 or more samples from a project.
        Parameters:
        projectId - identifier for the project
        sampleIds - list of sampleIds to remove
        Returns:
        result of the removal of samples
      • downloadSamples

        public org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody downloadSamples​(java.lang.Long projectId,
                                                                                                           java.util.List<java.lang.Long> sampleIds,
                                                                                                           javax.servlet.http.HttpServletResponse response)
        Get the sequence files for a list of samples
        Parameters:
        projectId - Identifier for the project
        sampleIds - List of identifiers for samples
        response - HttpServletResponse
        Returns:
        Zip File containing sequence files for listed samples
      • downloadSamplesSpreadsheet

        @Transactional(readOnly=true)
        public void downloadSamplesSpreadsheet​(java.lang.Long projectId,
                                               java.lang.String type,
                                               ProjectSamplesTableRequest request,
                                               javax.servlet.http.HttpServletResponse response,
                                               java.util.Locale locale)
                                        throws java.io.IOException
        Download the currently filtered project samples table as either an xlsx or csv file.
        Parameters:
        projectId - Identifier for the project
        type - The type of file to generate (either excel or csv)
        request - The project samples table request
        response - The response
        locale - The current locale
        Throws:
        java.io.IOException - If there is an error writing the file
      • getPairedSequenceFilesForExportSample

        public java.util.List<SequencingObject> getPairedSequenceFilesForExportSample​(Sample sample,
                                                                                      Project project)
        Get a list of paired end sequence files for a sample
        Parameters:
        sample - the Sample to get the files for.
        project - the Project the sample belongs to
        Returns:
        list of paired end sequence files
      • getSingleEndSequenceFilesForExportSample

        public java.util.List<SequencingObject> getSingleEndSequenceFilesForExportSample​(Sample sample,
                                                                                         Project project)
        Get a list of single end sequence files for a sample
        Parameters:
        sample - the Sample to get the files for.
        project - the Project the sample belongs to
        Returns:
        list of single end sequence files
      • getFast5FilesForExportSample

        public java.util.List<SequencingObject> getFast5FilesForExportSample​(Sample sample)
        Get a list of fast5 sequence files for a sample
        Parameters:
        sample - the Sample to get the files for.
        Returns:
        list of fast5 sequence files
      • getGenomeAssembliesForExportSample

        public java.util.List<GenomeAssembly> getGenomeAssembliesForExportSample​(Sample sample)
        Get any genome assemblies that are available for a sample
        Parameters:
        sample - the Sample to get the assemblies for
        Returns:
        a list of genome assembly files