|
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 net.sf.basedb.util.export.spotdata.BfsExporter
public abstract class BfsExporter
Base class for exporting spotdata to BFS format. This class will do most of the hard work. A subclass is required to:
createDataWriters()
).
arrangeData(int, short, Object[][], Object[])
).
Before the exporter can be used it must be configured. The most important options are:
AbstractBioAssaySetExporter.setDbControl(DbControl)
(required): Sets the DbControl that is used for database access.
AbstractBioAssaySetExporter.setSource(net.sf.basedb.core.BioAssaySet)
(required): Sets the bioassay set that data should
be exported from.
setMetadataWriter(MetadataWriter)
(required): Sets the writer stream were BFS metadata is
written.
setReporterAnnotationsWriter(AnnotationWriter)
and addReporterField(DynamicField)
(optional): Sets the writer stream were reporter annoatations are written and selects which
reporter annotations to export. If no writer is specified the reporter annotations file is not
created.
setAssayAnnotationsWriter(AnnotationWriter)
and addAssayField(AssayField)
(optional): Sets the writer stream were assay annotations is written and selects which
assay annotations to export. If no writer is specified the assay annotations file is not
created.
setDataWriterFactory(DataWriterFactory)
and addSpotField(DynamicField)
(optional): Sets the factory that should be used to create output files and selects which
spot data to export. The number of files and the data arrangement depends on the subtype.
setParameter(String, String...)
(optional): Additional parameters that are needed
by, for example, a plug-in that is about to process the exported data files.
Field Summary | |
---|---|
private AnnotationWriter |
assayWriter
|
private boolean |
autoCloseWriters
|
private ChainedProgressReporter |
chainedProgress
|
private DataWriterFactory |
dataWriterFactory
|
private List<DataWriter> |
dataWriters
|
private Set<Integer> |
exportedPositions
|
private List<MetadataModel.SectionEntry> |
extraFiles
|
private MetadataWriter |
metadataWriter
|
private Map<String,String[]> |
parameters
|
private AnnotationWriter |
reporterWriter
|
private long |
spotCount
|
Constructor Summary | |
---|---|
protected |
BfsExporter()
|
Method Summary | |
---|---|
void |
addAssayField(AssayField field)
Add information about an assay field that should be exported. |
void |
addAssayFields(Collection<? extends AssayField> fields)
Add multiple assay fields in one go. |
void |
addExtraFile(String key,
String filename)
Add information about an extra data file that is included as part of the BFS. |
void |
addReporterField(DynamicField field)
Add information about a reporter field that should be exported. |
void |
addReporterFields(Collection<? extends DynamicField> fields)
Add multiple reporter fields in one go. |
void |
addSpotField(DynamicField spotField)
Add information about a spot field that should be exported. |
void |
addSpotFields(Collection<? extends DynamicField> fields)
Add multiple spot fields in one go. |
protected abstract void |
arrangeData(int position,
short column,
Object[][] data,
Object[] spotData)
Arrange the data that was returned by the query into the data writers array. |
protected void |
beginExport()
Validates that all required properties has been set and initialises other things that are needed. |
protected DataWriter |
createDataWriter(Object owner,
String suggestedFilename)
Utility method for calling creating a data writer. |
protected abstract List<DataWriter> |
createDataWriters()
Create the exact number of data writers that is needed to export the desired data. |
protected void |
endExport(RuntimeException e)
Clean up. |
protected void |
exportAssayAnnotations()
Export the assay annotations. |
protected void |
exportGlobalFooter()
Exports reporter annotations. |
protected boolean |
exportGlobalHeader()
Export the metadata and assay annotations. |
protected void |
exportMetadata()
Export the metadata file which contains information about the other files (reporter annotations, assay annotations and spot data), plug-in parameters, etc. |
protected void |
exportReporterAnnotations(ProgressReporter progress,
long count)
Export the reporter annotations. |
protected void |
exportSectionData()
Export all spot data. |
protected long |
exportSpotData(ProgressReporter progress,
long count)
Export spot data. |
protected AnnotationWriter |
getAssayAnnotationsWriter()
Get the writer were assay annotations should be printed. |
List<AssayField> |
getAssayFields()
Get the list of registered assay fields, in the order they were registered. |
String |
getBFSSubtype()
Get the BFS subtype. |
protected DataWriterFactory |
getDataWriterFactory()
Get the factory that creates data writers. |
protected MetadataWriter |
getMetadataWriter()
Get the writer were metadata should be printed. |
String[] |
getParameter(String key)
Get the current value of a parameter. |
protected AnnotationWriter |
getReporterAnnotationsWriter()
Get the writer were reporter annotations should be printed. |
List<DynamicField> |
getReporterFields()
Get the list of registered reporter fields, in the order they were registered. |
List<DynamicField> |
getSpotFields()
Get the list of registered spot fields, in the order they were registered. |
void |
setAssayAnnotationsWriter(AnnotationWriter assayWriter)
Set the stream were assay annotations should be written. |
void |
setAutoCloseWriters(boolean autoClose)
If this option is set then all writers are automatically closed when all data has been writted to them. |
void |
setDataWriterFactory(DataWriterFactory<?> dataWriterFactory)
Set the data writer factory to use for generating spot data files. |
void |
setMetadataWriter(MetadataWriter metadataWriter)
Set the stream were the metadata should be written. |
void |
setParameter(String key,
String... values)
Add a parameter that is exported in the [parameters] section. |
void |
setReporterAnnotationsWriter(AnnotationWriter reporterWriter)
Set the stream were reporter annotations should be written. |
protected void |
validate()
Validate that all required options has been set and that other options have sensible values. |
Methods inherited from class net.sf.basedb.util.export.spotdata.AbstractBioAssaySetExporter |
---|
addExperimentalFactorsAsAssayFields, cacheReporterData, checkInterrupted, copyReporterFields, doExport, exportSectionFooter, exportSectionHeader, getAssayIndex, getAverageOnReporter, getBioAssays, getDbControl, getProgressReporter, getReporterQuery, getSnapshotManager, getSource, getSpotQuery, prepareAssayIndexMap, setAverageOnReporter, setDbControl, setProgress, setProgressReporter, setSnapshotManager, setSource |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private boolean autoCloseWriters
private DataWriterFactory dataWriterFactory
private Map<String,String[]> parameters
private MetadataWriter metadataWriter
private AnnotationWriter reporterWriter
private AnnotationWriter assayWriter
private List<DataWriter> dataWriters
private List<MetadataModel.SectionEntry> extraFiles
private ChainedProgressReporter chainedProgress
private long spotCount
private Set<Integer> exportedPositions
Constructor Detail |
---|
protected BfsExporter()
Method Detail |
---|
public void setAutoCloseWriters(boolean autoClose)
public void setMetadataWriter(MetadataWriter metadataWriter)
public void setReporterAnnotationsWriter(AnnotationWriter reporterWriter)
AnnotationWriter.getFilename()
since this is required in the metadata file.
Use addReporterField(DynamicField)
to register reporter
fields to export. The position number is always exported.
reporterWriter
- An annotation writer, or null if no reporter
annotation file should be createdpublic void setAssayAnnotationsWriter(AnnotationWriter assayWriter)
AnnotationWriter.getFilename()
since this is required in the metadata file.
Use addAssayField(AssayField)
to register fields to export.
The assay id is always exported.
assayWriter
- An annotation writer, or null if no assay
annotations file should be createdpublic void setDataWriterFactory(DataWriterFactory<?> dataWriterFactory)
dataWriterFactory
- A data writer factory, or null if no spot
data files should be createdpublic void setParameter(String key, String... values)
NOTE! Calling this method twice with the same key, overwrites the existing parameters, but doesn't change the order they are written to the file.
key
- The parameter key (if null this method call is ignored)values
- The parameter value (may be null)public String[] getParameter(String key)
key
- The parameter key
public void addReporterField(DynamicField field)
AbstractBioAssaySetExporter
addReporterField
in class AbstractBioAssaySetExporter
field
- The reporter field (null is ignored)public void addReporterFields(Collection<? extends DynamicField> fields)
fields
- A collection with the fields that should be addedpublic List<DynamicField> getReporterFields()
AbstractBioAssaySetExporter
getReporterFields
in class AbstractBioAssaySetExporter
public void addAssayField(AssayField field)
AbstractBioAssaySetExporter
addAssayField
in class AbstractBioAssaySetExporter
field
- The assay field (null is ignored)public void addAssayFields(Collection<? extends AssayField> fields)
fields
- A collection with the fields that should be addedpublic List<AssayField> getAssayFields()
AbstractBioAssaySetExporter
getAssayFields
in class AbstractBioAssaySetExporter
public void addSpotField(DynamicField spotField)
addSpotField
in class AbstractBioAssaySetExporter
spotField
- The spot field informationpublic void addSpotFields(Collection<? extends DynamicField> fields)
fields
- A collection with the fields that should be addedpublic List<DynamicField> getSpotFields()
AbstractBioAssaySetExporter
getSpotFields
in class AbstractBioAssaySetExporter
public void addExtraFile(String key, String filename)
File entries are written in the order they are registered by this method. Multiple entries with the same key are allowed (eg. the previous entry is not replaced).
key
- The key for the filefilename
- The name of the fileprotected void validate()
AbstractBioAssaySetExporter
validate
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 exportSectionData()
exportSectionData
in class AbstractBioAssaySetExporter
protected void exportGlobalFooter()
exportGlobalFooter
in class AbstractBioAssaySetExporter
protected void endExport(RuntimeException e)
endExport
in class AbstractBioAssaySetExporter
public String getBFSSubtype()
MetadataWriter.setSubtype(String)
.
protected MetadataWriter getMetadataWriter()
protected AnnotationWriter getReporterAnnotationsWriter()
protected AnnotationWriter getAssayAnnotationsWriter()
protected DataWriterFactory getDataWriterFactory()
protected void exportMetadata()
setParameter(String, String[])
and are written to
the [parameters] section. If no parameters has been registered this
section is skipped.
protected void exportReporterAnnotations(ProgressReporter progress, long count)
getReporterAnnotationsWriter()
returns null. The
position is used as the value for the id column. Other columns
are exported as given by getReporterFields()
.
If a progress reporter is given, progress is updated between 0 and 100%.
This method needs to be executed after exportSpotData(ProgressReporter, long)
since we need to know which positions that was exported.
progress
- An optional progress reportercount
- The total number of reporters, or 0 if not knownprotected void exportAssayAnnotations()
getAssayAnnotationsWriter()
returns null. The
assay ID is used as the value for the id column. Other columns
are exported as given by getAssayFields()
.
protected long exportSpotData(ProgressReporter progress, long count)
progress
- An optional progress reportercount
- The expected number of spots or 0 if not known
protected DataWriter createDataWriter(Object owner, String suggestedFilename) throws IOException
DataWriterFactory.createDataWriter(Object, String)
.
IOException
protected abstract List<DataWriter> createDataWriters() throws IOException
DataWriter.getFilename()
and the number of data columns
(DataWriter.getColumnCount()
) it is going to write.
This method must be implemented by a subclass and is called once from
the beginExport()
method unless no data writer factory has been
set up.
IOException
- If there is a problem with creating the writersprotected abstract void arrangeData(int position, short column, Object[][] data, Object[] spotData)
createDataWriters()
. The size of
the second index is determined by the number of columns for the
data writer (eg. DataWriter.getColumnCount()
.
This method must be implemented by a subclass which should copy data from the spotdata array into the data array. The data array is flushed to the data writers every time the position coordinate changes. Thus, this method can be called multiple times with different column (=assay) coordinates.
position
- The current position of the spot datacolumn
- The current column of the spot datadata
- The data array to copy the data tospotData
- The current row of spot data, in the same order
as getSpotFields()
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |