Package com.actelion.research.chem.io
Class DWARFileCreator
- java.lang.Object
-
- com.actelion.research.chem.io.DWARFileCreator
-
public class DWARFileCreator extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description DWARFileCreator(java.io.BufferedWriter writer)
Use a DWARFileCreator for writing native DataWarrior files without a CompoundTableModel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
add2DCoordinatesColumn(int structureColumn)
Creates a new column to hold encoded 2-dimensional atom coordinates for the structures stored in the associated structure column.int
add3DCoordinatesColumn(java.lang.String name, int structureColumn)
Creates a new column to hold encoded 3-dimensional atom coordinates for the structures stored in the associated structure column.int
addAlphanumericalColumn(java.lang.String name)
Creates a new standard column to hold any alphanumerical content.void
addColumnProperty(int column, java.lang.String key, java.lang.String value)
This method may be used to define column properties, e.g.int
addDescriptorColumn(java.lang.String descriptorShortName, java.lang.String descriptorVersion, int structureColumn)
Creates a new column to hold a chemical descriptor for the structures stored in the associated structure column.int
addStructureColumn(java.lang.String name, java.lang.String idColumnName)
This adds a column to host canonical structure representations (idcodes).void
setRowCoordinates(java.lang.String coordinates, int column)
Puts the given encoded atom coordinates into the given column.void
setRowStructure(StereoMolecule mol, int idcodeColumn, int coordsColumn)
Calculates the canonical structure representation as idcode from mol and puts it into the given idcodeColumn.void
setRowStructure(java.lang.String idcode, int column)
Puts the given idcode into the given column.void
setRowValue(java.lang.String value, int column)
Puts the given value into the given column.void
writeCurrentRow()
Call this once per row after setting individual cell content with the respective setRowXXXX() methods.void
writeEnd()
void
writeHeader(int rowCount)
Call this after defining columns and specifying column properties
-
-
-
Constructor Detail
-
DWARFileCreator
public DWARFileCreator(java.io.BufferedWriter writer)
Use a DWARFileCreator for writing native DataWarrior files without a CompoundTableModel. (if you have a populated CompoundTableModel, use the CompoundTableSaver instead). To use the DWARFileCreator you need to follow these steps:
- instantiate a new DWARFileCreator for every file
- define individual columns with addStructureColumn(), addDescriptorColumn(), and addAlphanumericalColumn()
- add custom column properties, if you need to with addColumnProperty() - call writeHeader() once to create the file and write file & table headers
- for every row call setRowStructure() and setRowValue() for cell values and then writeCurrentRow() - call writeEnd() to close the file
-
-
Method Detail
-
addStructureColumn
public int addStructureColumn(java.lang.String name, java.lang.String idColumnName)
This adds a column to host canonical structure representations (idcodes). This call allocates the column and defines proper column properties. If you want DataWarrior to show structure in this column with the original atom coordinates, you need to also add a column for the encoded atom coordinates. Otherwise DataWarrior would generate 2D-coordinates for the structures atoms on the fly.- Parameters:
name
-idColumnName
- null or column title of other column that hold a compound identifier- Returns:
- new structure column index
-
add2DCoordinatesColumn
public int add2DCoordinatesColumn(int structureColumn)
Creates a new column to hold encoded 2-dimensional atom coordinates for the structures stored in the associated structure column. A structure column may not have more than one associated 2-dimensional atom coordinate column. This call allocates the column and defines proper column properties.- Parameters:
structureColumn
-- Returns:
- new coordinate column index
-
add3DCoordinatesColumn
public int add3DCoordinatesColumn(java.lang.String name, int structureColumn)
Creates a new column to hold encoded 3-dimensional atom coordinates for the structures stored in the associated structure column. A structure column may have multiple associated 3-dimensional atom coordinate columns. This call allocates the column and defines proper column properties.- Parameters:
name
- 3D-coordinate column names are used to distinguish multiple 3D-coordinate setsstructureColumn
-- Returns:
- new coordinate column index
-
addDescriptorColumn
public int addDescriptorColumn(java.lang.String descriptorShortName, java.lang.String descriptorVersion, int structureColumn)
Creates a new column to hold a chemical descriptor for the structures stored in the associated structure column. A structure column may have multiple associated descriptor columns, provided that these have distinct types. This call allocates the column and defines proper column properties.- Parameters:
descriptorShortName
- name used to identify the descriptor type, e.g. 'FragFp'structureColumn
-- Returns:
- new descriptor column index
-
addAlphanumericalColumn
public int addAlphanumericalColumn(java.lang.String name)
Creates a new standard column to hold any alphanumerical content.- Parameters:
name
-- Returns:
-
addColumnProperty
public void addColumnProperty(int column, java.lang.String key, java.lang.String value)
This method may be used to define column properties, e.g. to associate the column with an URL for identifier lookups, to define a data range, or other special DataWarrior related features.- Parameters:
column
-key
-value
-
-
writeHeader
public void writeHeader(int rowCount) throws java.io.IOException
Call this after defining columns and specifying column properties- Parameters:
rowCount
- -1 if row count is not known- Throws:
java.io.IOException
-
setRowStructure
public void setRowStructure(StereoMolecule mol, int idcodeColumn, int coordsColumn)
Calculates the canonical structure representation as idcode from mol and puts it into the given idcodeColumn. If coordinateColumn != -1 then it also extracts the structures atom coordinates and puts them into the given coordinateColumn. It is assumed that the atom coordinates dimensionality (2D vs. 3D) matches that what was used to define the column.- Parameters:
mol
-idcodeColumn
-coordsColumn
-
-
setRowStructure
public void setRowStructure(java.lang.String idcode, int column)
Puts the given idcode into the given column. If you have defined a column for atom coordinates, you should also call setRowCoordinates() to store the corresponding coodinate encoding.- Parameters:
idcode
-column
-
-
setRowCoordinates
public void setRowCoordinates(java.lang.String coordinates, int column)
Puts the given encoded atom coordinates into the given column. It is assumed that the atom coordinates dimensionality (2D vs. 3D) matches that what was used to define the column.- Parameters:
coordinates
-column
-
-
setRowValue
public void setRowValue(java.lang.String value, int column)
Puts the given value into the given column.- Parameters:
value
-column
-
-
writeCurrentRow
public void writeCurrentRow() throws java.io.IOException
Call this once per row after setting individual cell content with the respective setRowXXXX() methods.- Throws:
java.io.IOException
-
writeEnd
public void writeEnd() throws java.io.IOException
- Throws:
java.io.IOException
-
-