Class MDTableHandler


  • @PublicAPI
    public class MDTableHandler
    extends Object
    Class for handling Molecular Descriptor tables.
    Since:
    JChem 2.0
    • Constructor Detail

      • MDTableHandler

        public MDTableHandler​(ConnectionHandler conh,
                              String strucTableName)
                       throws SQLException
        Creates a new instance of MDTableHandler
        Parameters:
        conh - ConnectionHanlder opened to the database
        strucTableName - the name of the structure table, the Molecular Descriptors were created using these structures
        Throws:
        SQLException - if an sql error encountered
      • MDTableHandler

        public MDTableHandler​(ConnectionHandler conh,
                              String tableName,
                              boolean indexTable)
                       throws SQLException
        Internally used. Creates a new instance of MDTableHandler
        Parameters:
        conh - ConnectionHanlder opened to the database
        tableName - the name of the structure table
        indexTable - strucTableName is an index table
        Throws:
        SQLException - if an sql error encountered
    • Method Detail

      • getMDTableName

        public static String getMDTableName​(String strucTableName,
                                            String descriptorName)
        Generates table name for storing Molecular Descriptors
        Parameters:
        strucTableName - the name of the structure table
        descriptorName - the name of the descriptor
        Returns:
        the MD table name generated according to conventions
      • createMDTable

        public void createMDTable​(String descriptorName,
                                  String descType,
                                  String descSettings,
                                  String descComment)
                           throws SQLException
        Creates a Molecular Descriptor Table. Creates table named "<strucTableName>_MD_<descriptorName>", and stores creation parameters in the property table
        Parameters:
        descriptorName - the name of the Molecular Descriptor
        descType - the type of the descriptor as a fully qualified class name
        descSettings - the descriptor settings to be used for descriptor generation
        descComment - a comment text for the descriptor table
        Throws:
        SQLException - if an sql error encountered
      • createMDTable

        public void createMDTable​(String descriptorName,
                                  String descType,
                                  String descSettings,
                                  String descComment,
                                  boolean updateOnInsert)
                           throws SQLException
        Creates a Molecular Descriptor Table. Creates table named "<strucTableName>_MD_<descriptorName>", and stores creation parameters in the property table
        Parameters:
        descriptorName - the name of the Molecular Descriptor
        descType - the type of the descriptor as a fully qualified class name
        descSettings - the descriptor settings to be used for descriptor generation
        descComment - a comment text for the descriptor table
        updateOnInsert - if set to true, the descriptors will be automatically added for inserted structures. The default setting is false.
        Throws:
        SQLException - if an sql error encountered
      • deleteMDTable

        public void deleteMDTable​(String descriptorName)
                           throws SQLException
        Deletes a Molecular Descriptor Table. Deletes table named "<strucTableName>_MD_<descriptorName>". Also removes entry from the property table
        Parameters:
        descriptorName - the name of the Molecular Descriptor
        Throws:
        SQLException - if an sql error encountered
      • isMDTableValid

        public boolean isMDTableValid​(String descriptorName)
                               throws SQLException
        Tests, if a given MD table is valid or not.
        Only tests, whether the maximum value of cd_id is bigger in the structure table than in the MD table (invalid) , or equal (valid)
        Parameters:
        descriptorName - the name of the Molecular Descriptor
        Returns:
        true if every row has a pair in the two tables
        false if the structure table contains rows not listed in the MD table (import occurred after generation, regeneration is necessary)
        Throws:
        SQLException - in case of database error, or if there are rows in the MD table that are not represented in the structure table (this shouldn't occur)
      • isMDTableValidByAllIDs

        public boolean isMDTableValidByAllIDs​(String descriptorName)
                                       throws SQLException
        Tests, whether a given MD table is valid.
        Checks if every row in structure table has a pair in the MD table. (this may take some time)
        Parameters:
        descriptorName - the name of the Molecular Descriptor
        Returns:
        true if every row has a pair in the two tables
        false if the structure table contains rows not listed in the MD table (import occurred after generation, regeneration is necessary)
        Throws:
        SQLException - in case of database error, or if there are rows in the MD table that are not represented in the structure table (this shouldn't occur)
      • incRegenerateDescriptorTable

        public void incRegenerateDescriptorTable​(String descriptorName)
                                          throws SQLException
        Calculates missing lines in MD table
        Parameters:
        descriptorName - the name of the Molecular Descriptor
        Throws:
        SQLException - if an sql error encountered
      • getMolecularDescriptors

        public String[] getMolecularDescriptors()
                                         throws SQLException
        Retrieves the names of MolecularDescriptors assigned to the structure table and stored in the JChem database.
        Returns:
        the descriptor names
        Throws:
        SQLException - if an sql error encountered
      • getMDConfigs

        public String[] getMDConfigs​(String descriptorName)
                              throws SQLException
        Retrieves the names of stored configurations associated with a certain Molecular Descriptor
        Parameters:
        descriptorName - the name of the molecular descriptor
        Returns:
        the names of the configurations
        Throws:
        SQLException - if an sql error encountered
      • getMDConfig

        public String getMDConfig​(String mdName,
                                  String configName)
                           throws SQLException
        Retrieves the value of the specified MolecularDescriptor configuration
        Parameters:
        mdName - symbolic (user defined) name of the molecular descriptor
        configName - the name of the configuration
        Returns:
        the retrieved configuration string
        Throws:
        SQLException - if an sql error encountered
      • setMDConfig

        public void setMDConfig​(String mdName,
                                String configName,
                                String config)
                         throws SQLException
        Sets the value of the specified MolecularDescriptor configuration
        Parameters:
        mdName - symbolic (user defined) name of the molecular descriptor
        configName - the name of the configuration
        config - the configuration string
        Throws:
        SQLException - if an sql error encountered
      • deleteMDConfig

        public void deleteMDConfig​(String mdName,
                                   String configName)
                            throws SQLException
        Deletes the specified MolecularDescriptor setting
        Parameters:
        mdName - symbolic (user defined) name of the molecular descriptor
        configName - the name of the configuration
        Throws:
        SQLException - if an sql error encountered
      • getMDSettings

        public String getMDSettings​(String mdName)
                             throws SQLException
        Gets the value of the Settings property of the MolecularDescriptor specified by its name from the property table of the JChem database.
        Parameters:
        mdName - name of the MolecularDescriptor
        Returns:
        the value of the Settings property
        Throws:
        SQLException - if an sql error encountered
      • getMDType

        public String getMDType​(String mdName)
                         throws SQLException
        Gets the Type property of the MolecularDescriptor specified by its name.
        Parameters:
        mdName - name of the MolecularDescriptor
        Returns:
        type of the MolecularDescriptor
        Throws:
        SQLException - if an sql error encountered
      • getMDComment

        public String getMDComment​(String mdName)
                            throws SQLException
        Gets the value of the Comment property of the MolecularDescriptor specified by its name from the property table of the JChem database.
        Parameters:
        mdName - name of the MolecularDescriptor
        Returns:
        optional comment given by the user when the descriptor was created and stored
        Throws:
        SQLException - if an sql error encountered
      • getMDUpdateOnInsert

        public boolean getMDUpdateOnInsert​(String mdName)
                                    throws SQLException
        Gets the value of the UpdateOnInsert property of the MolecularDescriptor specified by its name from the property table of the JChem database.
        Parameters:
        mdName - name of the MolecularDescriptor
        Returns:
        true if the descriptor should be updated on insert.
        Throws:
        SQLException - if an sql error encountered
      • createMDSet

        public MDSet createMDSet​(String[] mdNames)
                          throws SQLException
        Creates an MDSet based on settings stored in the database
        Parameters:
        mdNames - the names of the Molecular Descriptors
        Returns:
        the generated MDSet, contains descriptors initialized with their stored settings
        Throws:
        SQLException - if an sql error encountered
      • createMD

        public MolecularDescriptor createMD​(String mdName)
                                     throws SQLException
        Creates an MolecularDescriptor based on settings stored in the database
        Parameters:
        mdName - the name of the Molecular Descriptor
        Returns:
        the generated descriptor, initialized with its stored settings
        Throws:
        SQLException - if an sql error encountered
      • getMDTables

        public String[] getMDTables()
                             throws SQLException
        Retrieves the names of Molecular Descriptor tables assigned to the structure table and stored in the JChem database.
        Returns:
        the names of the descriptor tables
        Throws:
        SQLException - if an sql error encountered