Class AtomTypeFactory

java.lang.Object
org.openscience.cdk.config.AtomTypeFactory

public class AtomTypeFactory extends Object
General class for defining AtomTypes. This class itself does not define the items types; for this classes implementing the AtomTypeConfiguration interface are used.

To see which AtomTypeConfigurator's CDK provides, one should check the AtomTypeConfigurator API.

The AtomTypeFactory is a singleton class, which means that there exists only one instance of the class. Well, almost. For each atom type table, there is one AtomTypeFactory instance. An instance of this class is obtained with:

  AtomTypeFactory factory = AtomTypeFactory.getInstance(someChemObjectBuilder);
  
For each atom type list a separate AtomTypeFactory is instantiated.

To get all the atom types of an element from a specific list, this code can be used:

  AtomTypeFactory factory = AtomTypeFactory.getInstance(
    "org/openscience/cdk/config/data/jmol_atomtypes.txt",
      someChemObjectBuilder
  );
  AtomType[] types = factory.getAtomTypes("C");
  
Author:
steinbeck
See Also:
Source code:
main
Belongs to CDK module:
core
Keywords:
atom, type
Created on:
2001-08-29
  • Field Details

    • ATOMTYPE_ID_STRUCTGEN

      public static final String ATOMTYPE_ID_STRUCTGEN
      Used as an ID to describe the atom type.
      See Also:
    • ATOMTYPE_ID_MODELING

      public static final String ATOMTYPE_ID_MODELING
      Used as an ID to describe the atom type.
      See Also:
    • ATOMTYPE_ID_JMOL

      public static final String ATOMTYPE_ID_JMOL
      Used as an ID to describe the atom type.
      See Also:
  • Method Details

    • getInstance

      public static AtomTypeFactory getInstance(InputStream ins, String format, IChemObjectBuilder builder)
      Method to create a default AtomTypeFactory, using the given InputStream. An AtomType of this kind is not cached.
      Parameters:
      ins - InputStream containing the data
      format - String representing the possible formats ('xml' and 'txt')
      builder - IChemObjectBuilder used to make IChemObject instances
      Returns:
      The AtomTypeFactory for the given data file
      See Also:
    • getInstance

      public static AtomTypeFactory getInstance(IChemObjectBuilder builder)
      Method to create a default AtomTypeFactory, using the structgen atom type list.
      Parameters:
      builder - IChemObjectBuilder used to make IChemObject instances
      Returns:
      The AtomTypeFactory for the given data file
      See Also:
    • getInstance

      public static AtomTypeFactory getInstance(String configFile, IChemObjectBuilder builder)
      Method to create a specialized AtomTypeFactory. Available lists in CDK are:
      • org/openscience/cdk/config/data/jmol_atomtypes.txt
      • org/openscience/cdk/config/data/mol2_atomtypes.xml
      • org/openscience/cdk/config/data/structgen_atomtypes.xml
      • org/openscience/cdk/config/data/mm2_atomtypes.xml
      • org/openscience/cdk/config/data/mmff94_atomtypes.xml
      • org/openscience/cdk/dict/data/cdk-atom-types.owl
      • org/openscience/cdk/dict/data/sybyl-atom-types.owl
      Parameters:
      configFile - String the name of the data file
      builder - INewChemObjectBuilder used to make IChemObject instances
      Returns:
      The AtomTypeFactory for the given data file
    • getSize

      public int getSize()
      Returns the number of atom types in this list.
      Returns:
      The number of atom types
    • getAtomType

      public IAtomType getAtomType(String identifier) throws NoSuchAtomTypeException
      Get an AtomType with the given ID.
      Parameters:
      identifier - an ID for a particular atom type (like C$)
      Returns:
      The AtomType for this id
      Throws:
      NoSuchAtomTypeException - Thrown if the atom type does not exist.
    • getAtomTypes

      public IAtomType[] getAtomTypes(String symbol)
      Get an array of all atomTypes known to the AtomTypeFactory for the given element symbol and atomtype class.
      Parameters:
      symbol - An element symbol to search for
      Returns:
      An array of atomtypes that matches the given element symbol and atomtype class
    • getAllAtomTypes

      public IAtomType[] getAllAtomTypes()
      Gets the allAtomTypes attribute of the AtomTypeFactory object.
      Returns:
      The allAtomTypes value
    • configure

      public IAtom configure(IAtom atom) throws CDKException
      Configures an atom. Finds the correct element type by looking at the Atom's atom type name, and if that fails, picks the first atom type matching the Atom's element symbol..
      Parameters:
      atom - The atom to be configured
      Returns:
      The configured atom
      Throws:
      CDKException - when it could not recognize and configure the IAtom