Package ubic.gemma.core.analysis.service
Class ExpressionDataFileServiceImpl
- java.lang.Object
-
- ubic.gemma.core.analysis.service.AbstractFileService<ExpressionExperiment>
-
- ubic.gemma.core.analysis.service.ExpressionDataFileServiceImpl
-
- All Implemented Interfaces:
ExpressionDataFileService,FileService<ExpressionExperiment>,JsonFileService<ExpressionExperiment>,TsvFileService<ExpressionExperiment>
@Component @ParametersAreNonnullByDefault public class ExpressionDataFileServiceImpl extends AbstractFileService<ExpressionExperiment> implements ExpressionDataFileService
Supports the creation and location of 'flat file' versions of data in the system, for download by users. Files are cached on the filesystem and reused if possible, rather than recreating them every time.- Author:
- paul
-
-
Field Summary
-
Fields inherited from interface ubic.gemma.core.analysis.service.ExpressionDataFileService
DISCLAIMER
-
-
Constructor Summary
Constructors Constructor Description ExpressionDataFileServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidanalysisResultSetsToString(Collection<ExpressionAnalysisResultSet> results, Map<Long,String[]> geneAnnotations, StringBuilder buf)List<DifferentialExpressionAnalysisResult>analysisResultSetToString(ExpressionAnalysisResultSet ears, Map<Long,String[]> geneAnnotations, StringBuilder buf, Map<Long,StringBuilder> probe2String, List<DifferentialExpressionAnalysisResult> sortedFirstColumnOfResults)voiddeleteAllFiles(ExpressionExperiment ee)Delete any existing coexpression, data, or differential expression data files.voiddeleteDiffExArchiveFile(DifferentialExpressionAnalysis analysis)FilegetDiffExpressionAnalysisArchiveFile(Long analysisId, boolean forceCreate)Locate or create the differential expression data file(s) for a given experiment.FilegetMetadataFile(ExpressionExperiment ee, ExpressionExperimentMetaFileType type)Locate a metadata file.voidwriteDiffExArchiveFile(BioAssaySet experimentAnalyzed, DifferentialExpressionAnalysis analysis, DifferentialExpressionAnalysisConfig config)Writes to the configured gemma.appdata.home The file created is a zip archive containing at least two files.Optional<File>writeOrLocateCoexpressionDataFile(ExpressionExperiment ee, boolean forceWrite)Write or located the coexpression data file for a given experimentFilewriteOrLocateDesignFile(ExpressionExperiment ee, boolean forceWrite)Locate or create an experimental design file for a given experiment.Collection<File>writeOrLocateDiffExpressionDataFiles(ExpressionExperiment ee, boolean forceWrite)Locate or create the differential expression data file(s) for a given experiment.Optional<File>writeOrLocateJSONProcessedExpressionDataFile(ExpressionExperiment ee, boolean forceWrite, boolean filtered)FilewriteOrLocateJSONRawExpressionDataFile(ExpressionExperiment ee, QuantitationType type, boolean forceWrite)Optional<File>writeOrLocateProcessedDataFile(ExpressionExperiment ee, boolean forceWrite, boolean filtered)Locate or create a data file containing the 'preferred and masked' expression data matrix, with filtering for low expression applied (currently supports default settings only).FilewriteOrLocateRawExpressionDataFile(ExpressionExperiment ee, QuantitationType type, boolean forceWrite)Locate or create a new data file for the given quantitation type.voidwriteProcessedExpressionData(ExpressionExperiment ee, Writer writer)Write processed expression data to a given writer for a given quantitation type.Optional<File>writeProcessedExpressionDataFile(ExpressionExperiment ee, boolean filtered, String fileName, boolean compress)Create a data file containing the 'preferred and masked' expression data matrix, with filtering for low expression applied (currently supports default settings only).voidwriteRawExpressionData(ExpressionExperiment ee, QuantitationType qt, Writer writer)Write raw expression data to a given writer for a given quantitation type.voidwriteTsv(ExpressionExperiment entity, Writer writer)Write the given entity to tabular format.-
Methods inherited from class ubic.gemma.core.analysis.service.AbstractFileService
escapeTsv, format, getSubDelimiter, getTsvFormatBuilder, write, write, writeJson
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ubic.gemma.core.analysis.service.FileService
write, write
-
-
-
-
Method Detail
-
analysisResultSetsToString
public void analysisResultSetsToString(Collection<ExpressionAnalysisResultSet> results, Map<Long,String[]> geneAnnotations, StringBuilder buf)
- Specified by:
analysisResultSetsToStringin interfaceExpressionDataFileService
-
analysisResultSetToString
public List<DifferentialExpressionAnalysisResult> analysisResultSetToString(ExpressionAnalysisResultSet ears, Map<Long,String[]> geneAnnotations, StringBuilder buf, Map<Long,StringBuilder> probe2String, @Nullable List<DifferentialExpressionAnalysisResult> sortedFirstColumnOfResults)
- Specified by:
analysisResultSetToStringin interfaceExpressionDataFileService
-
deleteAllFiles
public void deleteAllFiles(ExpressionExperiment ee)
Description copied from interface:ExpressionDataFileServiceDelete any existing coexpression, data, or differential expression data files.- Specified by:
deleteAllFilesin interfaceExpressionDataFileService- Parameters:
ee- the experiment
-
deleteDiffExArchiveFile
public void deleteDiffExArchiveFile(DifferentialExpressionAnalysis analysis)
- Specified by:
deleteDiffExArchiveFilein interfaceExpressionDataFileService
-
getDiffExpressionAnalysisArchiveFile
public File getDiffExpressionAnalysisArchiveFile(Long analysisId, boolean forceCreate)
Description copied from interface:ExpressionDataFileServiceLocate or create the differential expression data file(s) for a given experiment. We generate an archive that contains following files: - differential expression analysis file (q-values per factor) - file for each result set with contrasts info (such as fold change for each factor value)- Specified by:
getDiffExpressionAnalysisArchiveFilein interfaceExpressionDataFileService- Parameters:
analysisId- analysis IDforceCreate- whether to force creation- Returns:
- file
-
getMetadataFile
public File getMetadataFile(ExpressionExperiment ee, ExpressionExperimentMetaFileType type)
Description copied from interface:ExpressionDataFileServiceLocate a metadata file.- Specified by:
getMetadataFilein interfaceExpressionDataFileService
-
writeProcessedExpressionDataFile
public Optional<File> writeProcessedExpressionDataFile(ExpressionExperiment ee, boolean filtered, String fileName, boolean compress) throws IOException, FilteringException
Description copied from interface:ExpressionDataFileServiceCreate a data file containing the 'preferred and masked' expression data matrix, with filtering for low expression applied (currently supports default settings only).- Specified by:
writeProcessedExpressionDataFilein interfaceExpressionDataFileService- Parameters:
ee- the experimentfiltered- fitlered?fileName- file namecompress- compress?- Returns:
- file, or empty if the experiment has no processed expression data
- Throws:
IOException- when there are IO problemsFilteringException
-
writeDiffExArchiveFile
public void writeDiffExArchiveFile(BioAssaySet experimentAnalyzed, DifferentialExpressionAnalysis analysis, @Nullable DifferentialExpressionAnalysisConfig config) throws IOException
Description copied from interface:ExpressionDataFileServiceWrites to the configured gemma.appdata.home The file created is a zip archive containing at least two files. The first is the summary model fit statistics, ANOVA-style. The others are the contrast details for each factor. They should be R-friendly (e.g., readable withread.delim("analysis.results.txt", header=T, comment.char="#", row.names=1)- Specified by:
writeDiffExArchiveFilein interfaceExpressionDataFileService- Parameters:
experimentAnalyzed- the experimentanalysis- analysisconfig- config- Throws:
IOException- when there was a problem during write
-
writeRawExpressionData
@Transactional(readOnly=true) public void writeRawExpressionData(ExpressionExperiment ee, QuantitationType qt, Writer writer) throws IOException
Description copied from interface:ExpressionDataFileServiceWrite raw expression data to a given writer for a given quantitation type.Note: For compression, wrap a
GZIPOutputStreamwith aOutputStreamWriter. To write to a string, consider usingStringWriter.- Specified by:
writeRawExpressionDatain interfaceExpressionDataFileService- Parameters:
ee- the expression experimentqt- a quantitation type to usewriter- the destination for the raw expression data- Throws:
IOException- if operations with the writer fails
-
writeProcessedExpressionData
@Transactional(readOnly=true) public void writeProcessedExpressionData(ExpressionExperiment ee, Writer writer) throws IOException
Description copied from interface:ExpressionDataFileServiceWrite processed expression data to a given writer for a given quantitation type.Note: For compression, wrap a
GZIPOutputStreamwith aOutputStreamWriter. To write to a string, consider usingStringWriter.- Specified by:
writeProcessedExpressionDatain interfaceExpressionDataFileService- Parameters:
ee- the expression experimentwriter- the destination for the raw expression data- Throws:
IOException- if operations with the writer fails
-
writeOrLocateCoexpressionDataFile
public Optional<File> writeOrLocateCoexpressionDataFile(ExpressionExperiment ee, boolean forceWrite)
Description copied from interface:ExpressionDataFileServiceWrite or located the coexpression data file for a given experiment- Specified by:
writeOrLocateCoexpressionDataFilein interfaceExpressionDataFileService- Parameters:
ee- the experimentforceWrite- whether to force write- Returns:
- file
-
writeOrLocateProcessedDataFile
public Optional<File> writeOrLocateProcessedDataFile(ExpressionExperiment ee, boolean forceWrite, boolean filtered) throws FilteringException
Description copied from interface:ExpressionDataFileServiceLocate or create a data file containing the 'preferred and masked' expression data matrix, with filtering for low expression applied (currently supports default settings only). It will be gzip-compressed. The file will be regenerated even if one already exists if the forceWrite parameter is true, or if there was a recent change (more recent than the last modified date of the existing file) to any of the experiments platforms.- Specified by:
writeOrLocateProcessedDataFilein interfaceExpressionDataFileService- Parameters:
ee- the experimentforceWrite- force re-write even if file already exists and is up to date.filtered- filtered- Returns:
- file, or empty if the experiment has no processed vectors
- Throws:
FilteringException
-
writeOrLocateRawExpressionDataFile
public File writeOrLocateRawExpressionDataFile(ExpressionExperiment ee, QuantitationType type, boolean forceWrite)
Description copied from interface:ExpressionDataFileServiceLocate or create a new data file for the given quantitation type. The output will include gene information if it can be located from its own file.- Specified by:
writeOrLocateRawExpressionDataFilein interfaceExpressionDataFileServicetype- the quantitation typeforceWrite- To not return the existing file, but create it anew.- Returns:
- file
-
writeOrLocateDesignFile
public File writeOrLocateDesignFile(ExpressionExperiment ee, boolean forceWrite)
Description copied from interface:ExpressionDataFileServiceLocate or create an experimental design file for a given experiment. The file will be regenerated even if one already exists if the forceWrite parameter is true, or if there was a recent change (more recent than the last modified date of the existing file) to any of the experiments platforms.- Specified by:
writeOrLocateDesignFilein interfaceExpressionDataFileService- Parameters:
ee- the experimentforceWrite- force re-write even if file already exists and is up to date- Returns:
- file
-
writeOrLocateDiffExpressionDataFiles
public Collection<File> writeOrLocateDiffExpressionDataFiles(ExpressionExperiment ee, boolean forceWrite)
Description copied from interface:ExpressionDataFileServiceLocate or create the differential expression data file(s) for a given experiment.- Specified by:
writeOrLocateDiffExpressionDataFilesin interfaceExpressionDataFileService- Parameters:
ee- the experimentforceWrite- whether to force write- Returns:
- collection of files, one per analysis.
-
writeOrLocateJSONProcessedExpressionDataFile
public Optional<File> writeOrLocateJSONProcessedExpressionDataFile(ExpressionExperiment ee, boolean forceWrite, boolean filtered) throws FilteringException
- Specified by:
writeOrLocateJSONProcessedExpressionDataFilein interfaceExpressionDataFileService- Throws:
FilteringException- See Also:
ExpressionDataFileService.writeOrLocateProcessedDataFile(ExpressionExperiment, boolean, boolean)
-
writeOrLocateJSONRawExpressionDataFile
public File writeOrLocateJSONRawExpressionDataFile(ExpressionExperiment ee, QuantitationType type, boolean forceWrite)
-
writeTsv
@Transactional(readOnly=true) public void writeTsv(ExpressionExperiment entity, Writer writer) throws IOException
Description copied from interface:TsvFileServiceWrite the given entity to tabular format.- Specified by:
writeTsvin interfaceTsvFileService<ExpressionExperiment>- Throws:
IOException
-
-