public abstract class BaseFileExporter extends AbstractBioAssaySetExporter
Modifier and Type | Field and Description |
---|---|
private boolean |
autoCloseWriters |
private BaseFileWriter |
out |
private java.util.Map<java.lang.String,java.lang.String> |
parameters |
Modifier | Constructor and Description |
---|---|
protected |
BaseFileExporter() |
Modifier and Type | Method and Description |
---|---|
void |
addAssayField(AssayField field)
Adds an assay field to the exported file.
|
void |
addAssayFields(java.util.Collection<? extends AssayField> fields)
Add multiple assay fields in one go.
|
void |
addReporterField(DynamicField field)
Add information about a reporter field that should be exported.
|
void |
addReporterFields(java.util.Collection<? extends DynamicField> fields)
Add multiple reporter fields in one go.
|
void |
addSpotField(DynamicField field)
Add information about a spot field that should be exported.
|
void |
addSpotFields(java.util.Collection<? extends DynamicField> fields)
Add multiple spot fields in one go.
|
protected void |
beginExport()
Prepare the export by adding all experimental
factors as assay fields if no fields have been specified.
|
protected void |
endExport(java.lang.RuntimeException e)
End the export and clean up/close all aquired resources.
|
protected void |
exportAssaysSectionData()
Export data for the 'assays' section that contains information
about the bioassays in the source bioassay set.
|
protected void |
exportAssaysSectionHeaders()
Exports headers for the 'assays' section which contains metadata
information about the assays in the bioassay set.
|
protected boolean |
exportGlobalHeader()
Export 'settings' and 'assays' sections.
|
protected int |
exportSettingsSection()
Export the settings section which contains all parameter values
registered with
setParameter(String, String) . |
protected void |
exportSpotSectionData(java.util.List<BioAssay> assays,
DynamicSpotQuery spotQuery,
ProgressReporter progress,
long count)
Export the spot data of a 'spot' section.
|
protected void |
exportSpotSectionHeaders(java.util.List<BioAssay> assays,
long spotCount)
Start a new 'spot' section and export the standard headers:
'channels, 'assays', 'columns', 'assayFields' and 'count'.
|
java.util.List<AssayField> |
getAssayFields()
Get the list of registered assay fields, in the order they were
registered.
|
boolean |
getAverageOnReporter() |
protected BaseFileWriter |
getBaseFileWriter()
Get the writer that writes the data to the file.
|
protected DynamicSpotQuery |
getCountQuery(boolean bioAssayRestriction)
Get a configured query that counts the number of data lines that is about to
be written in a data section.
|
java.lang.String |
getParameter(java.lang.String key)
Get the current value of a 'settings' parameter.
|
java.util.List<DynamicField> |
getReporterFields()
Get the list of registered reporter fields, in the order they were
registered.
|
java.util.List<DynamicField> |
getSpotFields()
Get the list of registered spot fields, in the order they were
registered.
|
void |
setAutoCloseWriters(boolean autoClose)
If this option is set then all writers are automatically closed
when all data has been writted to them.
|
void |
setAverageOnReporter(boolean averageOnReporter)
Specify if the exported data should be averaged on reporter
or not.
|
void |
setParameter(java.lang.String key,
java.lang.String value)
Add a parameter that is exported in the 'settings' section, which
is the first section in the BASEfile.
|
void |
setWriter(BaseFileWriter out)
Set the stream were the exported data should be written.
|
addExperimentalFactorsAsAssayFields, cacheReporterData, copyReporterFields, doExport, exportGlobalFooter, exportSectionData, exportSectionFooter, exportSectionHeader, getAssayIndex, getBioAssays, getDbControl, getProgressReporter, getReporterQuery, getSnapshotManager, getSource, getSpotQuery, prepareAssayIndexMap, setDbControl, setProgress, setProgressReporter, setSnapshotManager, setSource, validate
private java.util.Map<java.lang.String,java.lang.String> parameters
private BaseFileWriter out
private boolean autoCloseWriters
public void setWriter(BaseFileWriter out)
public void setAutoCloseWriters(boolean autoClose)
public void setParameter(java.lang.String key, java.lang.String value)
key
- The parameter key (if null this method call is ignored)value
- The parameter value (may be null)public java.lang.String getParameter(java.lang.String key)
key
- The parameter keypublic void addSpotField(DynamicField field)
AbstractBioAssaySetExporter
addSpotField
in class AbstractBioAssaySetExporter
field
- The spot field (null is ignored)public void addSpotFields(java.util.Collection<? extends DynamicField> fields)
fields
- A collection with the fields that should be addedpublic java.util.List<DynamicField> getSpotFields()
AbstractBioAssaySetExporter
getSpotFields
in class AbstractBioAssaySetExporter
public void addReporterField(DynamicField field)
AbstractBioAssaySetExporter
addReporterField
in class AbstractBioAssaySetExporter
field
- The reporter field (null is ignored)public void addReporterFields(java.util.Collection<? extends DynamicField> fields)
fields
- A collection with the fields that should be addedpublic java.util.List<DynamicField> getReporterFields()
AbstractBioAssaySetExporter
getReporterFields
in class AbstractBioAssaySetExporter
public void addAssayField(AssayField field)
addAssayField
in class AbstractBioAssaySetExporter
field
- The assay field (null is ignored)public void addAssayFields(java.util.Collection<? extends AssayField> fields)
fields
- A collection with the fields that should be addedpublic java.util.List<AssayField> getAssayFields()
AbstractBioAssaySetExporter
getAssayFields
in class AbstractBioAssaySetExporter
public void setAverageOnReporter(boolean averageOnReporter)
AbstractBioAssaySetExporter
setAverageOnReporter
in class AbstractBioAssaySetExporter
public boolean getAverageOnReporter()
getAverageOnReporter
in class AbstractBioAssaySetExporter
protected void beginExport()
beginExport
in class AbstractBioAssaySetExporter
protected boolean exportGlobalHeader()
exportGlobalHeader
in class AbstractBioAssaySetExporter
AbstractBioAssaySetExporter.exportSectionHeader()
,
FALSE to continue with global footers AbstractBioAssaySetExporter.exportGlobalFooter()
protected void endExport(java.lang.RuntimeException e)
AbstractBioAssaySetExporter
endExport
in class AbstractBioAssaySetExporter
protected BaseFileWriter getBaseFileWriter()
protected int exportSettingsSection()
setParameter(String, String)
. If a parameter
with key=section exists the value of that parameter is used as the
name of this section, otherwise 'settings' is used as name.
If the 'section' parameter exists, it must be the first
parameter. It is not allowed in other places and will generate an
exception.
This method leaves the BASEfile writer in the header part in case the caller wants to add more headers.
If no parameters has been registered this section is skipped.
protected void exportAssaysSectionHeaders()
protected void exportAssaysSectionData()
protected void exportSpotSectionHeaders(java.util.List<BioAssay> assays, long spotCount)
assays
- The bioassays that this section contains data forspotCount
- The number of data lines that is going to be
written in the data partprotected void exportSpotSectionData(java.util.List<BioAssay> assays, DynamicSpotQuery spotQuery, ProgressReporter progress, long count)
AbstractBioAssaySetExporter.cacheReporterData()
and is copied to the output by
AbstractBioAssaySetExporter.copyReporterFields(int, Object[], int)
.
A new data row is generated each time the position number changes. If each row should contain data from more than one assay an index map must be given. The index map should map the bioassay column to the ordinal number of the assay in the list of assays.
assays
- A list of with the bioassays that the current spot
data section contains data forspotQuery
- The query used to retreive the dataprogress
- An optional progress reporter, if given progress
is reported from 0 to 100%count
- The total number of spots must be given for the progress
reporting to workprotected DynamicSpotQuery getCountQuery(boolean bioAssayRestriction)
bioAssayRestriction
- If TRUE a restriction is added to the
query to make it return data for a single bioassay only.
Use query.setParameter("bioAssayColumn", (int)bioAssay.getDataCubeColumnNo(), Type.INT)
to set the value for the restrictionAbstractSqlQuery.count(DbControl)
to
get the count