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 void
analysisResultSetsToString(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)
void
deleteAllFiles(ExpressionExperiment ee)
Delete any existing coexpression, data, or differential expression data files.void
deleteDiffExArchiveFile(DifferentialExpressionAnalysis analysis)
File
getDiffExpressionAnalysisArchiveFile(Long analysisId, boolean forceCreate)
Locate or create the differential expression data file(s) for a given experiment.File
getMetadataFile(ExpressionExperiment ee, ExpressionExperimentMetaFileType type)
Locate a metadata file.void
writeDiffExArchiveFile(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 experimentFile
writeOrLocateDesignFile(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)
File
writeOrLocateJSONRawExpressionDataFile(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).File
writeOrLocateRawExpressionDataFile(ExpressionExperiment ee, QuantitationType type, boolean forceWrite)
Locate or create a new data file for the given quantitation type.void
writeProcessedExpressionData(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).void
writeRawExpressionData(ExpressionExperiment ee, QuantitationType qt, Writer writer)
Write raw expression data to a given writer for a given quantitation type.void
writeTsv(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:
analysisResultSetsToString
in interfaceExpressionDataFileService
-
analysisResultSetToString
public List<DifferentialExpressionAnalysisResult> analysisResultSetToString(ExpressionAnalysisResultSet ears, Map<Long,String[]> geneAnnotations, StringBuilder buf, Map<Long,StringBuilder> probe2String, @Nullable List<DifferentialExpressionAnalysisResult> sortedFirstColumnOfResults)
- Specified by:
analysisResultSetToString
in interfaceExpressionDataFileService
-
deleteAllFiles
public void deleteAllFiles(ExpressionExperiment ee)
Description copied from interface:ExpressionDataFileService
Delete any existing coexpression, data, or differential expression data files.- Specified by:
deleteAllFiles
in interfaceExpressionDataFileService
- Parameters:
ee
- the experiment
-
deleteDiffExArchiveFile
public void deleteDiffExArchiveFile(DifferentialExpressionAnalysis analysis)
- Specified by:
deleteDiffExArchiveFile
in interfaceExpressionDataFileService
-
getDiffExpressionAnalysisArchiveFile
public File getDiffExpressionAnalysisArchiveFile(Long analysisId, boolean forceCreate)
Description copied from interface:ExpressionDataFileService
Locate 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:
getDiffExpressionAnalysisArchiveFile
in interfaceExpressionDataFileService
- Parameters:
analysisId
- analysis IDforceCreate
- whether to force creation- Returns:
- file
-
getMetadataFile
public File getMetadataFile(ExpressionExperiment ee, ExpressionExperimentMetaFileType type)
Description copied from interface:ExpressionDataFileService
Locate a metadata file.- Specified by:
getMetadataFile
in interfaceExpressionDataFileService
-
writeProcessedExpressionDataFile
public Optional<File> writeProcessedExpressionDataFile(ExpressionExperiment ee, boolean filtered, String fileName, boolean compress) throws IOException, FilteringException
Description copied from interface:ExpressionDataFileService
Create a data file containing the 'preferred and masked' expression data matrix, with filtering for low expression applied (currently supports default settings only).- Specified by:
writeProcessedExpressionDataFile
in 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:ExpressionDataFileService
Writes 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:
writeDiffExArchiveFile
in 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:ExpressionDataFileService
Write raw expression data to a given writer for a given quantitation type.Note: For compression, wrap a
GZIPOutputStream
with aOutputStreamWriter
. To write to a string, consider usingStringWriter
.- Specified by:
writeRawExpressionData
in 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:ExpressionDataFileService
Write processed expression data to a given writer for a given quantitation type.Note: For compression, wrap a
GZIPOutputStream
with aOutputStreamWriter
. To write to a string, consider usingStringWriter
.- Specified by:
writeProcessedExpressionData
in 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:ExpressionDataFileService
Write or located the coexpression data file for a given experiment- Specified by:
writeOrLocateCoexpressionDataFile
in 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:ExpressionDataFileService
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). 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:
writeOrLocateProcessedDataFile
in 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:ExpressionDataFileService
Locate 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:
writeOrLocateRawExpressionDataFile
in interfaceExpressionDataFileService
type
- 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:ExpressionDataFileService
Locate 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:
writeOrLocateDesignFile
in 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:ExpressionDataFileService
Locate or create the differential expression data file(s) for a given experiment.- Specified by:
writeOrLocateDiffExpressionDataFiles
in 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:
writeOrLocateJSONProcessedExpressionDataFile
in 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:TsvFileService
Write the given entity to tabular format.- Specified by:
writeTsv
in interfaceTsvFileService<ExpressionExperiment>
- Throws:
IOException
-
-