Class AbstractBioAssaySetExporter
- Direct Known Subclasses:
BaseFileExporter
,BfsExporter
The exporter has been designed to export three types of information associated with a bioassay set.
- Spot data: intensity values, extra values, raw data values
- Reporter data: reporter annotations, position extra values
- Bioassay data: annotations
Subclass implementors can override doExport()
if they wish. A better option is to override the other methods
that are called from this method in this order:
beginExport()
: One time onlyexportGlobalHeader()
: One time only. If false is returned, the export skips to the last stepexportSectionHeader()
: One or more timesexportSectionData()
: One or more timesexportSectionFooter()
: One or more times. If true is returned, the steps 3-5 are repeated.endExport(RuntimeException)
: Always called last. If the parameter is not null an error has occurred
- Version:
- 2.12
- Author:
- Nicklas
- Last modified
- $Date: 2017-06-07 13:28:31 +0200 (on, 07 jun 2017) $
-
Field Summary
Modifier and TypeFieldDescriptionprivate List<AssayField>
private boolean
private DbControl
private ProgressReporter
private List<DynamicField>
private SnapshotManager
private BioAssaySet
private List<DynamicField>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addAssayField
(AssayField field) Add information about an assay field that should be exported.protected void
Adds all experimental factors from the experiment that the source bioassay set belongs to as assay fields.protected void
addReporterField
(DynamicField field) Add information about a reporter field that should be exported.protected void
addSpotField
(DynamicField field) Add information about a spot field that should be exported.protected void
Make preparations for the export.protected int
Loads and caches reporter data in an internal structure for quick access.protected void
copyReporterFields
(int key, Object[] data, int startIndex) Copy cached reporter data into a data array.void
doExport()
Run the export.protected void
End the export and clean up/close all aquired resources.protected void
Export global footer or other data that only appears once in the end of the exported file.protected boolean
Export global headers or other data that only appear once in the beginning of the exported file.protected void
Export section data.protected boolean
End the section by exporting a footer.protected void
Start a new section in the export by exporting section headers.protected List<AssayField>
Get the list of registered assay fields, in the order they were registered.protected int
getAssayIndex
(short column) Get the cached index value for an assay when you know the assay's column number.protected boolean
Get a list with all bioassays in the source bioassay set.Get the current DbControl.Get the progress reporterprotected List<DynamicField>
Get the list of registered reporter fields, in the order they were registered.protected DynamicPositionQuery
Get a configured query for position data that returns all fields that has been registered withaddReporterField(DynamicField)
.Get the current snapshot manager.Get the source bioassay set.protected List<DynamicField>
Get the list of registered spot fields, in the order they were registered.protected DynamicSpotQuery
getSpotQuery
(boolean bioAssayRestriction) Get a configured query for spot data that returns all fields that has been registered withaddSpotField(DynamicField)
.protected void
prepareAssayIndexMap
(List<BioAssay> assays, int firstIndex, int columnsPerAssay) Prepare a cache that maps the bioassay column (BioAssay.getDataCubeColumnNo()
) value to an index in the 'data' array this is generated.protected void
setAverageOnReporter
(boolean averageOnReporter) Specify if the exported data should be averaged on reporter or not.void
Set's the DbControl that should be used to get data from the database.protected void
setProgress
(int percent, String message) Update the progress of the export.void
setProgressReporter
(ProgressReporter progress) Set the progress reporter that is used to report progress.void
setSnapshotManager
(SnapshotManager snapshotManager) Set's the snapshot manager that should be used to load annotation values.void
setSource
(BioAssaySet source) Set the bioassay set that is used as a source for the spot data.protected void
validate()
Validate that all required options has been set and that other options have sensible values.
-
Field Details
-
source
-
dc
-
snapshotManager
-
progress
-
assayFields
-
reporterFields
-
spotFields
-
averageOnReporter
private boolean averageOnReporter -
bioAssays
-
reporterCache
-
assayIndexMap
-
-
Constructor Details
-
AbstractBioAssaySetExporter
protected AbstractBioAssaySetExporter()
-
-
Method Details
-
setDbControl
Set's the DbControl that should be used to get data from the database. -
getDbControl
Get the current DbControl. -
setSnapshotManager
Set's the snapshot manager that should be used to load annotation values. If no snapshot manager is provided an internal, temporary one is used.- Since:
- 2.14
-
getSnapshotManager
Get the current snapshot manager.- Since:
- 2.14
-
setProgressReporter
Set the progress reporter that is used to report progress. Subclasses can callsetProgress(int, String)
to update the current status. -
getProgressReporter
Get the progress reporter -
setSource
Set the bioassay set that is used as a source for the spot data. -
getSource
Get the source bioassay set. -
addSpotField
Add information about a spot field that should be exported.- Parameters:
field
- The spot field (null is ignored)
-
getSpotFields
Get the list of registered spot fields, in the order they were registered. -
addReporterField
Add information about a reporter field that should be exported.- Parameters:
field
- The reporter field (null is ignored)
-
getReporterFields
Get the list of registered reporter fields, in the order they were registered. -
addAssayField
Add information about an assay field that should be exported.- Parameters:
field
- The assay field (null is ignored)
-
getAssayFields
Get the list of registered assay fields, in the order they were registered. -
setAverageOnReporter
protected void setAverageOnReporter(boolean averageOnReporter) Specify if the exported data should be averaged on reporter or not. -
getAverageOnReporter
protected boolean getAverageOnReporter() -
doExport
public void doExport()Run the export. -
validate
protected void validate()Validate that all required options has been set and that other options have sensible values. Subclasses that override this method should call super.validate(). The default implementation will at least validate that a DbControl and a source bioassay set has been set.- Since:
- 2.15
-
beginExport
protected void beginExport()Make preparations for the export. Subclasses that need to initialise things should override this method. This is the first method that is called fromdoExport()
and is only called once. The default implementation does nothing. -
exportGlobalHeader
protected boolean exportGlobalHeader()Export global headers or other data that only appear once in the beginning of the exported file. This method is called afterbeginExport()
and is only called once. The return value can be used to indicate if the export should continue with sections or with global footers. The default implementation does nothing and returns TRUE.- Returns:
- TRUE to continue with a section
exportSectionHeader()
, FALSE to continue with global footersexportGlobalFooter()
-
exportSectionHeader
protected void exportSectionHeader()Start a new section in the export by exporting section headers. This method is called afterexportGlobalHeader()
and may be called multiple times as determined by the return value ofexportSectionFooter()
. The default implementation does nothing. -
exportSectionData
protected void exportSectionData()Export section data. This method is called afterexportSectionHeader()
and may be called multiple times as determined by the return value ofexportSectionFooter()
. The default implementation does nothing. -
endExport
End the export and clean up/close all aquired resources. This method is always called last. In the case of an error the exception parameter has a non-null value. The default implementation clears up values that has been cached so it is recommended that subclasses always call this method as part of their own cleanup. If the subclass implementation wants to throw a different exception it is recommended that the given exception is chained to allow developers to debug problems. -
getBioAssays
Get a list with all bioassays in the source bioassay set. The list is sorted by assay name and id. The list is cached internally and if this method is called several times, the same list is returned. -
addExperimentalFactorsAsAssayFields
protected void addExperimentalFactorsAsAssayFields()Adds all experimental factors from the experiment that the source bioassay set belongs to as assay fields. The experimental factors are ordered by name. -
getSpotQuery
Get a configured query for spot data that returns all fields that has been registered withaddSpotField(DynamicField)
. The fields are selected in the order they were registered. This method also adds the position and column of the spot as the last two fields. Note! If thesetAverageOnReporter(boolean)
option has been enabled there is no unique position so the query returns the reporter id instead of the position in this case.- Parameters:
bioAssayRestriction
- If TRUE a restriction is added to the query to make it return data for a single bioassay only. Usequery.setParameter("bioAssayColumn", (int)bioAssay.getDataCubeColumnNo(), Type.INT)
to set the value for the restriction- Returns:
- A prepared query
-
getReporterQuery
Get a configured query for position data that returns all fields that has been registered withaddReporterField(DynamicField)
. The fields are selected in the order they were registered. This method also adds the position of the spot as the last field.Note 1! If the
setAverageOnReporter(boolean)
option has been enabled there is no unique position so the query returns the reporter id instead of the position in this case.Note 2! If the
setAverageOnReporter(boolean)
option has been enabled the query may return the same reporter information multiple times.Note 3! A subclass may override this method, but it should at least still select the same number of fields as is expected from the default implementation.
- Returns:
- A prepared query
-
cacheReporterData
protected int cacheReporterData()Loads and caches reporter data in an internal structure for quick access. This method will execute the query returned bygetReporterQuery()
and read all data into a memory structure. The data is indexed by position number or by reporter id (if average on reporters is enabled). -
prepareAssayIndexMap
Prepare a cache that maps the bioassay column (BioAssay.getDataCubeColumnNo()
) value to an index in the 'data' array this is generated. The map is generated as follows:- first assay -> firstIndex
- second assay -> firstIndex + columnsPerAssay
- third assay -> firtsIndex + 2 * columnsPerAssay
- ... and so on
Use
getAssayIndex(short)
to get the indexed values.- Parameters:
assays
- The assays that should be mappedfirstIndex
- The index of the first assaycolumnsPerAssay
- Number of columns for each assay
-
getAssayIndex
protected int getAssayIndex(short column) Get the cached index value for an assay when you know the assay's column number.- Parameters:
column
- The column number (BioAssay.getDataCubeColumnNo()
)- Returns:
- The index of the first position in the 'data' array that data for the assay should be written to.
- See Also:
-
copyReporterFields
Copy cached reporter data into a data array.- Parameters:
key
- The cache key (=position or reporter id)data
- The data array to copy tostartIndex
- The start index in the data array for the first reporter field
-
setProgress
Update the progress of the export.- See Also:
-