Interface SampleService

    • Method Detail

      • updateSampleMetadata

        Sample updateSampleMetadata​(Sample sample,
                                    java.util.Set<MetadataEntry> metadataToSet)
        Set the given set of MetadataEntry on the given Sample and save it to the database
        Parameters:
        sample - the Sample to save metadata for
        metadataToSet - the metadata to save to the sample
        Returns:
        the updated Sample
      • mergeSampleMetadata

        Sample mergeSampleMetadata​(Sample sample,
                                   java.util.Set<MetadataEntry> metadataToAdd)
        Merge the given set of MetadataEntry into the given Sample. This will replace existing metadata that matches and add the new data to the sample.
        Parameters:
        sample - the sample to update
        metadataToAdd - the metadata to add
        Returns:
        the updated Sample
      • getMetadataForSample

        java.util.Set<MetadataEntry> getMetadataForSample​(Sample sample)
        Get the MetadataEntry set associated with the given Sample
        Parameters:
        sample - the Sample to get metadata for
        Returns:
        the metadata associated with the given sample
      • getLockedSamplesInProject

        java.util.List<java.lang.Long> getLockedSamplesInProject​(Project project)
        Get a list of Sample ids that are locked in this project. This method exists as a faster way of determining ownership than getting the full ProjectSampleJoin
        Parameters:
        project - the Project to check
        Returns:
        a List of locked sample IDs.
      • getMetadataForProjectSamples

        ProjectMetadataResponse getMetadataForProjectSamples​(Project project,
                                                             java.util.List<java.lang.Long> sampleIds,
                                                             java.util.List<MetadataTemplateField> fields)
        Get the metadata collections for a set of samples in a project. This will return a Map of Sample ID with a Set of the MetadataEntrys
        Parameters:
        project - the Project to get metadata for
        sampleIds - the Sample ids to get metadata for
        fields - the fields to get metadata from in the project. This must not be empty.
        Returns:
        a map of metadata
      • getSamplesForProject

        java.util.List<Join<Project,​Sample>> getSamplesForProject​(Project project)
        Get the list of Sample that belongs to a specific project.
        Parameters:
        project - the Project to get samples for.
        Returns:
        the collection of samples for the Project.
      • getSamplesForProjectShallow

        java.util.List<Sample> getSamplesForProjectShallow​(Project project)
        Get a shallow listing of the Samples in a Project. Note: This method will not return any metadata or associated objects.
        Parameters:
        project - The Project to get samples for
        Returns:
        a List of Sample
      • getSamplesInProject

        java.util.List<Sample> getSamplesInProject​(Project project,
                                                   java.util.List<java.lang.Long> sampleIds)
        Get a list of Sample in a Project given some Sample ids.
        Parameters:
        project - Project to get samples for.
        sampleIds - List of Sample ids.
        Returns:
        List of Samples from a Project.
      • getSampleOrganismsForProject

        java.util.List<java.lang.String> getSampleOrganismsForProject​(Project project)
        Get a list of the organism fields stored for all Samples in a Project
        Parameters:
        project - the Project to get sample organisms for
        Returns:
        a list of sample organisms
      • getNumberOfSamplesForProject

        java.lang.Long getNumberOfSamplesForProject​(Project project)
        Get the number of Samples for a given Project. This method will be faster than getSamplesForProjects
        Parameters:
        project - The project to get samples for
        Returns:
        The number of Samples in a given Project
      • getSamplesForProjectWithName

        org.springframework.data.domain.Page<ProjectSampleJoin> getSamplesForProjectWithName​(Project project,
                                                                                             java.lang.String name,
                                                                                             int page,
                                                                                             int size,
                                                                                             org.springframework.data.domain.Sort.Direction order,
                                                                                             java.lang.String... sortProperties)
        Get the Samples for a Project in page form
        Parameters:
        project - The project to read from
        name - The sample name to search
        page - The page number
        size - The size of the page
        order - The order of the page
        sortProperties - The properties to sort on
        Returns:
        A Page of Joins between Project and Sample
      • getSampleBySampleName

        Sample getSampleBySampleName​(Project project,
                                     java.lang.String sampleName)
        Get the Sample with the given sample name
        Parameters:
        project - the Project that the Sample belongs to.
        sampleName - The name for the requested sample
        Returns:
        A Sample with the given ID
      • getSampleIdsBySampleNameForProjects

        java.util.Map<java.lang.String,​java.util.List<java.lang.Long>> getSampleIdsBySampleNameForProjects​(java.util.List<java.lang.Long> projectIds,
                                                                                                                 java.util.List<java.lang.String> sampleNames)
        Get the Sample identifiers with the given list of sample names from a list of projects.
        Parameters:
        projectIds - The Project identifiers that the Sample belongs to.
        sampleNames - The list of sample names
        Returns:
        A list of Sample identifiers
      • mergeSamples

        Sample mergeSamples​(Project p,
                            Sample mergeInto,
                            java.util.Collection<Sample> toMerge)
        Merge multiple samples into one. Merging samples copies the SequenceFile references from the set of samples into one sample. The collection of samples in toMerge are marked as deleted. All samples must be associated with the specified project. The relationship between each sample in toMerge and the project p will be deleted.
        Parameters:
        p - the Project that all samples must belong to.
        mergeInto - the Sample to merge other samples into.
        toMerge - the collection of Sample to merge.
        Returns:
        the completely merged Sample (the persisted version of mergeInto).
      • getTotalBasesForSample

        java.lang.Long getTotalBasesForSample​(Sample sample)
                                       throws SequenceFileAnalysisException
        Given a sample gets the total number of bases in all sequence files in this sample.
        Parameters:
        sample - The sample to find the total number of bases.
        Returns:
        The total number of bases in all sequence files in this sample.
        Throws:
        SequenceFileAnalysisException - If there was an error getting FastQC analyses for a sequence file.
      • estimateCoverageForSample

        java.lang.Double estimateCoverageForSample​(Sample sample,
                                                   long referenceFileLength)
                                            throws SequenceFileAnalysisException
        Given the length of a reference file, estimate the total coverage for this sample.
        Parameters:
        sample - The sample to estimate coverage for.
        referenceFileLength - The length of the reference file in bases.
        Returns:
        The estimate coverage of all sequence data in this sample.
        Throws:
        SequenceFileAnalysisException - If there was an error getting FastQC analyses for a sequence file.
      • estimateCoverageForSample

        java.lang.Double estimateCoverageForSample​(Sample sample,
                                                   ReferenceFile referenceFile)
                                            throws SequenceFileAnalysisException
        Given a ReferenceFile, estimate the total coverage for this sample.
        Parameters:
        sample - The sample to estimate coverage for.
        referenceFile - The ReferenceFile to estimate coverage for.
        Returns:
        The estimate coverage of all sequence data in this sample.
        Throws:
        SequenceFileAnalysisException - If there was an error getting FastQC analyses for a sequence file.
      • getFilteredSamplesForProjects

        org.springframework.data.domain.Page<ProjectSampleJoin> getFilteredSamplesForProjects​(java.util.List<Project> projects,
                                                                                              java.util.List<java.lang.String> sampleNames,
                                                                                              java.lang.String sampleName,
                                                                                              java.lang.String searchTerm,
                                                                                              java.lang.String organism,
                                                                                              java.util.Date minDate,
                                                                                              java.util.Date maxDate,
                                                                                              int currentPage,
                                                                                              int pageSize,
                                                                                              org.springframework.data.domain.Sort sort)
        Get a Page of ProjectSampleJoin for samples from 1 or more projects based on filtering criteria.
        Parameters:
        projects - List of Project the Samples must be found within.
        sampleNames - List of String of Sample names to search
        sampleName - String exact name of a specific Sample
        searchTerm - String search term to search for.
        organism - String organism ter to search for.
        minDate - Date minimum date the sample was modified.
        maxDate - Date maximum date the sample was modified.
        currentPage - Integer the current page the table is on.
        pageSize - Integer the number of ProjectSampleJoin in the Page.
        sort - Sort chained sort definitions to sort page by.
        Returns:
        a Page of ProjectSampleJoin that are filtered and sorted.
      • searchSamplesForUser

        org.springframework.data.domain.Page<ProjectSampleJoin> searchSamplesForUser​(java.lang.String query,
                                                                                     java.lang.Integer page,
                                                                                     java.lang.Integer count,
                                                                                     org.springframework.data.domain.Sort sort)
        Search all Samples in projects the current logged in user has access to
        Parameters:
        query - the query string to search
        page - which page to return
        count - the number of entities to return
        sort - how to sort the result
        Returns:
        a page of ProjectSampleJoin
      • searchAllSamples

        org.springframework.data.domain.Page<ProjectSampleJoin> searchAllSamples​(java.lang.String query,
                                                                                 java.lang.Integer page,
                                                                                 java.lang.Integer count,
                                                                                 org.springframework.data.domain.Sort sort)
        Search all Samples in the database on the given query
        Parameters:
        query - the query string to search
        page - which page to return
        count - the number of entities to return
        sort - how to sort the result
        Returns:
        a page of ProjectSampleJoin
      • getSamplesCreated

        java.lang.Long getSamplesCreated​(java.util.Date createdDate)
        Get count of samples created in the time period
        Parameters:
        createdDate - the minimum date for samples created
        Returns:
        An Long count of samples created
      • getSamplesCreatedGrouped

        java.util.List<GenericStatModel> getSamplesCreatedGrouped​(java.util.Date createdDate,
                                                                  StatisticTimePeriod statisticTimePeriod)
        Get list of GenericStatModel of samples created in the past n time period grouped by the format provided.
        Parameters:
        createdDate - the minimum date for samples created
        statisticTimePeriod - the enum containing format for which to group the results by
        Returns:
        An GenericStatModel list
      • getCoverageForSamplesInProject

        java.util.Map<java.lang.Long,​java.lang.Long> getCoverageForSamplesInProject​(Project project,
                                                                                          java.util.List<java.lang.Long> sampleIds)
        Get Coverage for samples within a project.
        Parameters:
        project - the Project to use to calculate the coverage
        sampleIds - the Sample ids to get coverage for
        Returns:
        a map of sample id to coverage value