Class UISampleService
- java.lang.Object
-
- ca.corefacility.bioinformatics.irida.ria.web.services.UISampleService
-
@Component public class UISampleService extends java.lang.Object
UI Service for samples
-
-
Constructor Summary
Constructors Constructor Description UISampleService(SampleService sampleService, ProjectService projectService, UpdateSamplePermission updateSamplePermission, SequencingObjectService sequencingObjectService, GenomeAssemblyService genomeAssemblyService, org.springframework.context.MessageSource messageSource, UICartService cartService, MetadataTemplateService metadataTemplateService, MetadataEntryRepository metadataEntryRepository, MetadataRestrictionRepository metadataRestrictionRepository)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AddSampleMetadataResponse
addSampleMetadata(java.lang.Long sampleId, AddSampleMetadataRequest addSampleMetadataRequest, java.util.Locale locale)
Add metadata for the samplejava.util.List<SampleSequencingObjectFileModel>
concatenateSequenceFiles(java.lang.Long sampleId, java.util.Set<java.lang.Long> objectIds, java.lang.String filename, boolean removeOriginals)
Concatenate a collection ofSequencingObject
sjava.lang.String
deleteGenomeAssemblyFromSample(java.lang.Long sampleId, java.lang.Long genomeAssemblyId, java.util.Locale locale)
Remove a genome assembly linked to aSample
java.lang.String
deleteSequencingObjectFromSample(java.lang.Long sampleId, java.lang.Long sequencingObjectId, java.util.Locale locale)
Remove a sequencing object linked to aSample
void
downloadAssembly(java.lang.Long sampleId, java.lang.Long genomeAssemblyId, javax.servlet.http.HttpServletResponse response)
Download a GenomeAssembly fileorg.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 samplesvoid
downloadSamplesSpreadsheet(java.lang.Long projectId, java.lang.String type, ProjectSamplesTableRequest request, javax.servlet.http.HttpServletResponse response, java.util.Locale locale)
Download the currently filtered project samples table as either an xlsx or csv file.void
enhanceQcEntries(SequencingObject obj, Project project)
java.util.List<SequencingObject>
getFast5FilesForExportSample(Sample sample)
Get a list of fast5 sequence files for a samplejava.util.List<SampleSequencingObjectFileModel>
getFast5FilesForSample(Sample sample, Project project, java.util.List<java.lang.Long> sequencingObjectIds)
Get a list of fast5 sequence files for a sampleSampleFilesResponse
getFilesForSamples(java.util.List<java.lang.Long> sampleIds, java.lang.Long projectId)
Get details about the files belonging to a list of samplesjava.util.List<GenomeAssembly>
getGenomeAssembliesForExportSample(Sample sample)
Get any genome assemblies that are available for a samplejava.util.List<SampleGenomeAssemblyFileModel>
getGenomeAssembliesForSample(Sample sample)
Get any genome assemblies that are available for a samplejava.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.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)java.util.List<SequencingObject>
getPairedSequenceFilesForExportSample(Sample sample, Project project)
Get a list of paired end sequence files for a samplejava.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 sampleSampleDetails
getSampleDetails(java.lang.Long id, java.lang.Long projectId)
Get full details for aSample
SampleExportFiles
getSampleExportFiles(java.lang.Long sampleId, java.lang.Long projectId)
SampleFiles
getSampleFiles(java.lang.Long sampleId, java.lang.Long projectId)
Get the sequence files associated with a sampleSampleMetadata
getSampleMetadata(java.lang.Long id, java.lang.Long projectId)
Get all the metadata for aSample
java.util.List<SequencingObject>
getSingleEndSequenceFilesForExportSample(Sample sample, Project project)
Get a list of single end sequence files for a samplejava.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 sampleSampleFiles
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 idsjava.lang.String
mergeSamples(java.lang.Long projectId, MergeRequest request, java.util.Locale locale)
Merge 1 or more samples into another samplejava.lang.String
removeSampleMetadata(java.lang.Long projectId, java.lang.Long metadataFieldId, java.lang.Long metadataEntryId, java.util.Locale locale)
Remove metadata from the samplejava.lang.String
removeSamplesFromProject(java.lang.Long projectId, java.util.List<java.lang.Long> sampleIds)
Remove 1 or more samples from a project.void
shareSamplesWithProject(ShareSamplesRequest request, java.util.Locale locale)
java.lang.String
updateDefaultGenomeAssemblyForSample(java.lang.Long sampleId, java.lang.Long genomeAssemblyId, java.util.Locale locale)
Update the default genome assembly for the samplejava.lang.String
updateDefaultSequencingObjectForSample(java.lang.Long sampleId, java.lang.Long sequencingObjectId, java.util.Locale locale)
Update the default sequencing object for the samplejava.lang.String
updateSampleDetails(java.lang.Long id, UpdateSampleAttributeRequest request, java.util.Locale locale)
Update a field within the sample details.java.lang.String
updateSampleMetadata(java.lang.Long sampleId, UpdateSampleMetadataRequest updateSampleMetadataRequest, java.util.Locale locale)
Update metadata for the samplejava.util.List<SampleGenomeAssemblyFileModel>
uploadAssemblies(java.lang.Long sampleId, org.springframework.web.multipart.MultipartHttpServletRequest request)
UploadGenomeAssembly
's to a samplejava.util.List<SampleSequencingObjectFileModel>
uploadFast5Files(java.lang.Long sampleId, org.springframework.web.multipart.MultipartHttpServletRequest request)
UploadFast5Object
's to a samplejava.util.List<SampleSequencingObjectFileModel>
uploadSequenceFiles(java.lang.Long sampleId, org.springframework.web.multipart.MultipartHttpServletRequest request)
UploadSequenceFile
's to a sample
-
-
-
Constructor Detail
-
UISampleService
@Autowired public UISampleService(SampleService sampleService, ProjectService projectService, UpdateSamplePermission updateSamplePermission, SequencingObjectService sequencingObjectService, GenomeAssemblyService genomeAssemblyService, org.springframework.context.MessageSource messageSource, UICartService cartService, MetadataTemplateService metadataTemplateService, MetadataEntryRepository metadataEntryRepository, MetadataRestrictionRepository metadataRestrictionRepository)
-
-
Method Detail
-
getSampleDetails
public SampleDetails getSampleDetails(java.lang.Long id, java.lang.Long projectId)
Get full details for aSample
- Parameters:
id
- Identifier for aSample
projectId
- Idenfitifer for aProject
- Returns:
SampleDetails
-
getSampleMetadata
public SampleMetadata getSampleMetadata(java.lang.Long id, java.lang.Long projectId)
Get all the metadata for aSample
- Parameters:
id
- Identifier for aSample
projectId
- Identifier for aProject
- 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 samplerequest
-UpdateSampleAttributeRequest
details about which field to updatelocale
-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 identifiersequencingObjectId
- The sequencing object identifierlocale
-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 identifiergenomeAssemblyId
- The genome assembly identifierlocale
-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 sampleaddSampleMetadataRequest
- DTO containing sample metadata to add paramslocale
-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 idmetadataFieldId
- The metadata field idmetadataEntryId
- The metadata entry idlocale
-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 identifierupdateSampleMetadataRequest
- DTO containing sample metadata update paramslocale
-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 sampleprojectId
- 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 samplesequencingObjectIds
- Identifiers for updated sequencing objects to getprojectId
- 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 aSample
- Parameters:
sampleId
- Identifier for a samplesequencingObjectId
- Identifier for the sequencingObjectlocale
-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 aSample
- Parameters:
sampleId
- Identifier for a samplegenomeAssemblyId
- Identifier for the GenomeAssemblylocale
-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 samplegenomeAssemblyId
- Identifier for the genome assemblyresponse
-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 forprojectId
- - 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
-
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
-
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
-
getGenomeAssembliesForSample
public java.util.List<SampleGenomeAssemblyFileModel> getGenomeAssembliesForSample(Sample sample)
Get any genome assemblies that are available for a sample- Parameters:
sample
- theSample
to get the assemblies for- Returns:
- a list of genome assembly files
-
enhanceQcEntries
public void enhanceQcEntries(SequencingObject obj, Project project)
Adds theProject
to anyQCEntry
within aSequencingObject
. If theQCEntry
reports asQCEntry.QCEntryStatus.UNAVAILABLE
after being enhanced it is removed from the list- Parameters:
obj
- theSequencingObject
to enhanceproject
- theProject
to add
-
shareSamplesWithProject
public void shareSamplesWithProject(ShareSamplesRequest request, java.util.Locale locale) throws UIShareSamplesException
- Parameters:
request
- Request containing the details of the movelocale
- current usersLocale
- Throws:
UIShareSamplesException
- if project or samples cannot be found
-
uploadSequenceFiles
public java.util.List<SampleSequencingObjectFileModel> uploadSequenceFiles(java.lang.Long sampleId, org.springframework.web.multipart.MultipartHttpServletRequest request) throws java.io.IOException
UploadSequenceFile
's to a sample- Parameters:
sampleId
- TheSample
id to upload torequest
- The current request which containsMultipartFile
- 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
UploadFast5Object
's to a sample- Parameters:
sampleId
- the ID of the sample to upload torequest
- The current request which containsMultipartFile
- 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 usersLocale
- 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 projectrequest
- details about the samples to mergelocale
- 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
UploadGenomeAssembly
's to a sample- Parameters:
sampleId
- the ID of the sample to upload torequest
- The current request which containsMultipartFile
- Returns:
- list
SampleGenomeAssemblyFileModel
containing the newly created genome assemblies - Throws:
java.io.IOException
- Exception thrown if there is an error handling the file.
-
concatenateSequenceFiles
public java.util.List<SampleSequencingObjectFileModel> concatenateSequenceFiles(java.lang.Long sampleId, java.util.Set<java.lang.Long> objectIds, java.lang.String filename, boolean removeOriginals) throws ConcatenateException
Concatenate a collection ofSequencingObject
s- Parameters:
sampleId
- the id of theSample
to concatenate inobjectIds
- theSequencingObject
idsfilename
- base of the new filename to createremoveOriginals
- boolean whether to remove the original files- Returns:
- The concatenated sequencing object in a
SampleSequencingObjectFileModel
- Throws:
ConcatenateException
- if there was an error concatenating the files
-
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 projectsampleIds
- 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 projectsampleIds
- List of identifiers for samplesresponse
-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 projecttype
- The type of file to generate (either excel or csv)request
- The project samples table requestresponse
- The responselocale
- 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
-
getSingleEndSequenceFilesForExportSample
public java.util.List<SequencingObject> getSingleEndSequenceFilesForExportSample(Sample sample, Project project)
Get a list of single end sequence files for a sample
-
getFast5FilesForExportSample
public java.util.List<SequencingObject> getFast5FilesForExportSample(Sample sample)
Get a list of fast5 sequence files for a sample- Parameters:
sample
- theSample
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
- theSample
to get the assemblies for- Returns:
- a list of genome assembly files
-
-