Interface SampleService
-
- All Superinterfaces:
CRUDService<java.lang.Long,Sample>
- All Known Implementing Classes:
SampleServiceImpl
public interface SampleService extends CRUDService<java.lang.Long,Sample>
A service class for working with samples.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.Double
estimateCoverageForSample(Sample sample, long referenceFileLength)
Given the length of a reference file, estimate the total coverage for this sample.java.lang.Double
estimateCoverageForSample(Sample sample, ReferenceFile referenceFile)
Given aReferenceFile
, estimate the total coverage for this sample.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.org.springframework.data.domain.Page<ProjectSampleJoin>
getFilteredProjectSamples(java.util.List<Project> projects, ProjectSampleJoinSpecification filterSpec, int currentPage, int pageSize, org.springframework.data.domain.Sort sort)
Get aPage
ofProjectSampleJoin
for samples from 1 or more projects based on filtering criteria.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 aPage
ofProjectSampleJoin
for samples from 1 or more projects based on filtering criteria.java.util.List<java.lang.Long>
getLockedSamplesInProject(Project project)
Get a list ofSample
ids that are locked in this project.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.java.util.Set<MetadataEntry>
getMetadataForSample(Sample sample)
Get theMetadataEntry
set associated with the givenSample
java.lang.Long
getNumberOfSamplesForProject(Project project)
java.util.List<QCEntry>
getQCEntriesForSample(Sample sample)
java.util.Map<java.lang.Long,java.util.List<QCEntry>>
getQCEntriesForSamples(java.util.List<Sample> samples)
Sample
getSampleBySampleName(Project project, java.lang.String sampleName)
Get theSample
with the given sample nameProjectSampleJoin
getSampleForProject(Project project, java.lang.Long identifier)
SampleSequencingObjectJoin
getSampleForSequencingObject(SequencingObject seqObject)
Find aSample
assocaited with aSequencingObject
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 theSample
identifiers with the given list of sample names from a list of projects.java.util.List<java.lang.String>
getSampleOrganismsForProject(Project project)
java.lang.Long
getSamplesCreated(java.util.Date createdDate)
Get count of samples created in the time periodjava.util.List<GenericStatModel>
getSamplesCreatedGrouped(java.util.Date createdDate, StatisticTimePeriod statisticTimePeriod)
Get list ofGenericStatModel
of samples created in the past n time period grouped by the format provided.java.util.Collection<Sample>
getSamplesForAnalysisSubmission(AnalysisSubmission submission)
Get a list of allSample
s associated with a givenAnalysisSubmission
java.util.List<Join<Project,Sample>>
getSamplesForProject(Project project)
Get the list ofSample
that belongs to a specific project.java.util.List<Sample>
getSamplesForProjectShallow(Project project)
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)
java.util.List<Sample>
getSamplesInProject(Project project, java.util.List<java.lang.Long> sampleIds)
java.lang.Long
getTotalBasesForSample(Sample sample)
Given a sample gets the total number of bases in all sequence files in this sample.Sample
mergeSampleMetadata(Sample sample, java.util.Set<MetadataEntry> metadataToAdd)
Merge the given set ofMetadataEntry
into the givenSample
.Sample
mergeSamples(Project p, Sample mergeInto, java.util.Collection<Sample> toMerge)
Merge multiple samples into one.void
removeSequencingObjectFromSample(Sample sample, SequencingObject object)
Remove aSequencingObject
from a givenSample
.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 allSample
s in the database on the given queryorg.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 allSample
s in projects the current logged in user has access toSample
updateSampleMetadata(Sample sample, java.util.Set<MetadataEntry> metadataToSet)
Set the given set ofMetadataEntry
on the givenSample
and save it to the database-
Methods inherited from interface ca.corefacility.bioinformatics.irida.service.CRUDService
count, create, delete, exists, findAll, findRevisions, findRevisions, list, list, list, read, readMultiple, search, search, update, updateFields, updateMultiple
-
-
-
-
Method Detail
-
getSampleForProject
ProjectSampleJoin getSampleForProject(Project project, java.lang.Long identifier) throws EntityNotFoundException
Get a specific instance of aSample
that belongs to aProject
. If theSample
is not associated to theProject
(i.e., no relationship is shared between theSample
andProject
, then anEntityNotFoundException
will be thrown.- Parameters:
project
- theProject
to get theSample
for.identifier
- the identifier of theSample
- Returns:
- the
ProjectSampleJoin
describing the relationship between projet and sample - Throws:
EntityNotFoundException
- if no relationship exists betweenSample
andProject
.
-
updateSampleMetadata
Sample updateSampleMetadata(Sample sample, java.util.Set<MetadataEntry> metadataToSet)
Set the given set ofMetadataEntry
on the givenSample
and save it to the database
-
mergeSampleMetadata
Sample mergeSampleMetadata(Sample sample, java.util.Set<MetadataEntry> metadataToAdd)
Merge the given set ofMetadataEntry
into the givenSample
. This will replace existing metadata that matches and add the new data to the sample.- Parameters:
sample
- the sample to updatemetadataToAdd
- the metadata to add- Returns:
- the updated Sample
-
getMetadataForSample
java.util.Set<MetadataEntry> getMetadataForSample(Sample sample)
Get theMetadataEntry
set associated with the givenSample
- Parameters:
sample
- theSample
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 ofSample
ids that are locked in this project. This method exists as a faster way of determining ownership than getting the fullProjectSampleJoin
- Parameters:
project
- theProject
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 ofSample
ID with a Set of theMetadataEntry
s
-
getSampleForSequencingObject
SampleSequencingObjectJoin getSampleForSequencingObject(SequencingObject seqObject)
Find aSample
assocaited with aSequencingObject
- Parameters:
seqObject
- theSequencingObject
to get theSample
for- Returns:
- the
SampleSequencingObjectJoin
describing the relationship
-
getSamplesForProject
java.util.List<Join<Project,Sample>> getSamplesForProject(Project project)
Get the list ofSample
that belongs to a specific project.
-
getSamplesInProject
java.util.List<Sample> getSamplesInProject(Project project, java.util.List<java.lang.Long> sampleIds)
-
getSampleOrganismsForProject
java.util.List<java.lang.String> getSampleOrganismsForProject(Project project)
- Parameters:
project
- theProject
to get sample organisms for- Returns:
- a list of sample organisms
-
getNumberOfSamplesForProject
java.lang.Long getNumberOfSamplesForProject(Project 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)
-
getSampleBySampleName
Sample getSampleBySampleName(Project project, java.lang.String sampleName)
Get theSample
with the given sample name
-
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 theSample
identifiers with the given list of sample names from a list of projects.
-
removeSequencingObjectFromSample
void removeSequencingObjectFromSample(Sample sample, SequencingObject object)
Remove aSequencingObject
from a givenSample
. This will delete theSampleSequencingObjectJoin
object- Parameters:
sample
-Sample
to remove sequences fromobject
-SequencingObject
to remove
-
mergeSamples
Sample mergeSamples(Project p, Sample mergeInto, java.util.Collection<Sample> toMerge)
Merge multiple samples into one. Merging samples copies theSequenceFile
references from the set of samples into one sample. The collection of samples intoMerge
are marked as deleted. All samples must be associated with the specified project. The relationship between each sample intoMerge
and the project p will be deleted.
-
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 aReferenceFile
, estimate the total coverage for this sample.- Parameters:
sample
- The sample to estimate coverage for.referenceFile
- TheReferenceFile
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.
-
getFilteredProjectSamples
org.springframework.data.domain.Page<ProjectSampleJoin> getFilteredProjectSamples(java.util.List<Project> projects, ProjectSampleJoinSpecification filterSpec, int currentPage, int pageSize, org.springframework.data.domain.Sort sort)
Get aPage
ofProjectSampleJoin
for samples from 1 or more projects based on filtering criteria.- Parameters:
projects
-List
ofProject
theSample
s must be found within.filterSpec
-ProjectSampleJoinSpecification
currentPage
-Integer
the current page the table is on.pageSize
-Integer
the number ofProjectSampleJoin
in thePage
.sort
-Sort
chained sort definitions to sort page by.- Returns:
- a
Page
ofProjectSampleJoin
that are filtered and sorted.
-
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 aPage
ofProjectSampleJoin
for samples from 1 or more projects based on filtering criteria.- Parameters:
projects
-List
ofProject
theSample
s must be found within.sampleNames
-List
ofString
of Sample names to searchsampleName
-String
exact name of a specificSample
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 ofProjectSampleJoin
in thePage
.sort
-Sort
chained sort definitions to sort page by.- Returns:
- a
Page
ofProjectSampleJoin
that are filtered and sorted.
-
getSamplesForAnalysisSubmission
java.util.Collection<Sample> getSamplesForAnalysisSubmission(AnalysisSubmission submission)
Get a list of allSample
s associated with a givenAnalysisSubmission
- Parameters:
submission
- theAnalysisSubmission
- Returns:
- a Collection of
Sample
-
getQCEntriesForSamples
java.util.Map<java.lang.Long,java.util.List<QCEntry>> getQCEntriesForSamples(java.util.List<Sample> samples)
-
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 allSample
s in projects the current logged in user has access to- Parameters:
query
- the query string to searchpage
- which page to returncount
- the number of entities to returnsort
- 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 allSample
s in the database on the given query- Parameters:
query
- the query string to searchpage
- which page to returncount
- the number of entities to returnsort
- 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 ofGenericStatModel
of samples created in the past n time period grouped by the format provided.- Parameters:
createdDate
- the minimum date for samples createdstatisticTimePeriod
- 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.
-
-