|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.util.export.spotdata.AbstractBioAssaySetExporter
public abstract class AbstractBioAssaySetExporter
An abstract superclass for all exporters that exports spot data from a bioassay set. The purpose of this class is to collect some minimal configurations options (such as the source bioassay set and a DbControl) and to outline a generic export procedure. This class also has a lot of support functionality for subclass that wants to specify exactly which information that should be exported (spot data, reporter annotations, assay annotations, etc.), query generation, progress reporting, thread interruption controls, etc.
The exporter has been designed to export three types of information associated with a bioassay set.
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 only
exportGlobalHeader()
: One time only. If false is
returned, the export skips to the last step
exportSectionHeader()
: One or more times
exportSectionData()
: One or more times
exportSectionFooter()
: 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
Field Summary | |
---|---|
private List<AssayField> |
assayFields
|
private Map<Short,Integer> |
assayIndexMap
|
private boolean |
averageOnReporter
|
private List<BioAssay> |
bioAssays
|
private DbControl |
dc
|
private ProgressReporter |
progress
|
private Map<Integer,Object[]> |
reporterCache
|
private List<DynamicField> |
reporterFields
|
private SnapshotManager |
snapshotManager
|
private BioAssaySet |
source
|
private List<DynamicField> |
spotFields
|
Constructor Summary | |
---|---|
protected |
AbstractBioAssaySetExporter()
|
Method Summary | |
---|---|
protected void |
addAssayField(AssayField field)
Add information about an assay field that should be exported. |
protected void |
addExperimentalFactorsAsAssayFields()
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 |
beginExport()
Make preparations for the export. |
protected int |
cacheReporterData()
Loads and caches reporter data in an internal structure for quick access. |
protected void |
checkInterrupted()
Deprecated. In 2.16, use ThreadSignalHandler.checkInterrupted() instead |
protected void |
copyReporterFields(int key,
Object[] data,
int startIndex)
Copy cached reporter data into a data array. |
void |
doExport()
Run the export. |
protected void |
endExport(RuntimeException e)
End the export and clean up/close all aquired resources. |
protected void |
exportGlobalFooter()
Export global footer or other data that only appears once in the end of the exported file. |
protected boolean |
exportGlobalHeader()
Export global headers or other data that only appear once in the beginning of the exported file. |
protected void |
exportSectionData()
Export section data. |
protected boolean |
exportSectionFooter()
End the section by exporting a footer. |
protected void |
exportSectionHeader()
Start a new section in the export by exporting section headers. |
protected List<AssayField> |
getAssayFields()
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 |
getAverageOnReporter()
|
protected List<BioAssay> |
getBioAssays()
Get a list with all bioassays in the source bioassay set. |
DbControl |
getDbControl()
Get the current DbControl. |
ProgressReporter |
getProgressReporter()
Get the progress reporter |
protected List<DynamicField> |
getReporterFields()
Get the list of registered reporter fields, in the order they were registered. |
protected DynamicPositionQuery |
getReporterQuery()
Get a configured query for position data that returns all fields that has been registered with addReporterField(DynamicField) . |
SnapshotManager |
getSnapshotManager()
Get the current snapshot manager. |
BioAssaySet |
getSource()
Get the source bioassay set. |
protected List<DynamicField> |
getSpotFields()
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 with addSpotField(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 |
setDbControl(DbControl dc)
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private BioAssaySet source
private DbControl dc
private SnapshotManager snapshotManager
private ProgressReporter progress
private List<AssayField> assayFields
private List<DynamicField> reporterFields
private List<DynamicField> spotFields
private boolean averageOnReporter
private List<BioAssay> bioAssays
private Map<Integer,Object[]> reporterCache
private Map<Short,Integer> assayIndexMap
Constructor Detail |
---|
protected AbstractBioAssaySetExporter()
Method Detail |
---|
public void setDbControl(DbControl dc)
public DbControl getDbControl()
public void setSnapshotManager(SnapshotManager snapshotManager)
public SnapshotManager getSnapshotManager()
public void setProgressReporter(ProgressReporter progress)
setProgress(int, String)
to update the current status.
public ProgressReporter getProgressReporter()
public void setSource(BioAssaySet source)
public BioAssaySet getSource()
protected void addSpotField(DynamicField field)
field
- The spot field (null is ignored)protected List<DynamicField> getSpotFields()
protected void addReporterField(DynamicField field)
field
- The reporter field (null is ignored)protected List<DynamicField> getReporterFields()
protected void addAssayField(AssayField field)
field
- The assay field (null is ignored)protected List<AssayField> getAssayFields()
protected void setAverageOnReporter(boolean averageOnReporter)
protected boolean getAverageOnReporter()
public void doExport()
protected void validate()
protected void beginExport()
doExport()
and is only called once. The
default implementation does nothing.
protected boolean exportGlobalHeader()
beginExport()
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.
exportSectionHeader()
,
FALSE to continue with global footers exportGlobalFooter()
protected void exportSectionHeader()
exportGlobalHeader()
and may
be called multiple times as determined by the return value of
exportSectionFooter()
. The default implementation does
nothing.
protected void exportSectionData()
exportSectionHeader()
and may be called multiple times as determined by the return value of
exportSectionFooter()
. The default implementation does
nothing.
protected boolean exportSectionFooter()
exportSectionData()
. The return value is used to determine if the export
should be repeated with a new section or if it should move on to global footers.
The default implementation returns false.
exportSectionHeader()
,
FALSE to continue with global footers exportGlobalFooter()
protected void exportGlobalFooter()
exportGlobalHeader()
or exportSectionFooter()
. The default implementation does nothing.
protected void endExport(RuntimeException e)
protected List<BioAssay> getBioAssays()
protected void addExperimentalFactorsAsAssayFields()
protected DynamicSpotQuery getSpotQuery(boolean bioAssayRestriction)
addSpotField(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 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.
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 restriction
protected DynamicPositionQuery getReporterQuery()
addReporterField(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.
protected int cacheReporterData()
getReporterQuery()
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).
protected void prepareAssayIndexMap(List<BioAssay> assays, int firstIndex, int columnsPerAssay)
BioAssay.getDataCubeColumnNo()
)
value to an index in the 'data' array this is generated. The map is generated as
follows:
Use getAssayIndex(short)
to get the indexed values.
assays
- The assays that should be mappedfirstIndex
- The index of the first assaycolumnsPerAssay
- Number of columns for each assayprotected int getAssayIndex(short column)
column
- The column number (BioAssay.getDataCubeColumnNo()
)
prepareAssayIndexMap(List, int, int)
protected void copyReporterFields(int key, Object[] data, int startIndex)
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@Deprecated protected void checkInterrupted()
ThreadSignalHandler.checkInterrupted()
instead
SignalException
if it has.
protected void setProgress(int percent, String message)
ProgressReporter
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |