Class 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).
      java.util.Properties getColumnProperties​(java.lang.String columnTitle)
      This method, when called after calling setMasterCopy() or after completing defining columns, returns the column properties of the given column.
      java.lang.String[] getColumnTitles()
      This method, when called after calling setMasterCopy() or after completing defining columns, returns the list of defined column names in the correct order.
      void setMasterCopy​(DWARFileParser parser)
      If the file to be created shall resemble another DataWarrior file regarding file explanation, macro content, columns names, column properties, runtime properties (template), then one may define a master copy with this method that serves as a blue print.
      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
      void writeTemplate​(java.util.ArrayList<java.lang.String> properties)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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). You may provide a freshly instantiated DWARFileParser as master copy that will provide header, explanation text, macros, column properties, and runtime properties for the new file. To use the DWARFileCreator you need to follow these steps:
        - instantiate a new DWARFileCreator for a new output file
        - optionally call setMasterCopy()
        - 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()
        - if you didn't call setMasterCopy(), then optionally call writeTemplate() to add runtime properties
        - call writeEnd() to close the file
    • Method Detail

      • setMasterCopy

        public void setMasterCopy​(DWARFileParser parser)
        If the file to be created shall resemble another DataWarrior file regarding file explanation, macro content, columns names, column properties, runtime properties (template), then one may define a master copy with this method that serves as a blue print.
        Parameters:
        parser - DWARFileParser initialized with MODE_BUFFER_HEAD_AND_TAIL
      • 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 sets
        structureColumn -
        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 -
      • getColumnTitles

        public java.lang.String[] getColumnTitles()
        This method, when called after calling setMasterCopy() or after completing defining columns, returns the list of defined column names in the correct order. Especially, when using a master copy, this method informs about the expected columns and their order to be used for adding the data.
        Returns:
        manually defined column titles or from master copy, if used
      • getColumnProperties

        public java.util.Properties getColumnProperties​(java.lang.String columnTitle)
        This method, when called after calling setMasterCopy() or after completing defining columns, returns the column properties of the given column.
        Returns:
        manually defined column properties or from master copy, if used
      • 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
      • writeTemplate

        public void writeTemplate​(java.util.ArrayList<java.lang.String> properties)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • writeEnd

        public void writeEnd()
                      throws java.io.IOException
        Throws:
        java.io.IOException