Class TemplateHandler

java.lang.Object
org.openscience.cdk.layout.TemplateHandler

public final class TemplateHandler extends Object
Helper class for Structure Diagram Generation. Handles templates. This is our layout solution for ring systems which are notoriously difficult to layout, like cubane, adamantane, porphyrin, etc.
Author:
steinbeck
Source code:
main
Belongs to CDK module:
sdg
Keywords:
layout, 2D-coordinates, structure diagram generation
Created on:
2003-09-04
Requires:
java1.4+
  • Constructor Details

    • TemplateHandler

      public TemplateHandler(IChemObjectBuilder builder)
      Creates a new TemplateHandler with default templates loaded.
    • TemplateHandler

      public TemplateHandler()
      Creates a new TemplateHandler without any default templates.
  • Method Details

    • loadTemplates

      public void loadTemplates(IChemObjectBuilder builder)
      Loads all existing templates into memory. To add templates to be used in SDG, place a drawing with the new template in org/openscience/cdk/layout/templates and add the template filename to org/openscience/cdk/layout/templates/template.list
    • addMolecule

      public void addMolecule(IAtomContainer molecule)
      Adds a Molecule to the list of templates use by this TemplateHandler.
      Parameters:
      molecule - The molecule to be added to the TemplateHandler
    • removeMolecule

      public IAtomContainer removeMolecule(IAtomContainer molecule) throws CDKException
      Throws:
      CDKException
    • mapTemplateExact

      public boolean mapTemplateExact(IAtomContainer molecule) throws CDKException
      Checks if one of the loaded templates is isomorph to the given Molecule. If so, it assigns the coordinates from the template to the respective atoms in the Molecule, and marks the atoms as ISPLACED.
      Parameters:
      molecule - The molecule to be check for potential templates
      Returns:
      True if there was a possible mapping
      Throws:
      CDKException
    • mapTemplates

      public boolean mapTemplates(IAtomContainer molecule) throws CDKException
      Checks if one of the loaded templates is a substructure in the given Molecule. If so, it assigns the coordinates from the template to the respective atoms in the Molecule, and marks the atoms as ISPLACED.
      Parameters:
      molecule - The molecule to be check for potential templates
      Returns:
      True if there was a possible mapping
      Throws:
      CDKException
    • getTemplateCount

      public int getTemplateCount()
      Gets the templateCount attribute of the TemplateHandler object
      Returns:
      The templateCount value
    • getTemplateAt

      public IAtomContainer getTemplateAt(int position)
      Gets the templateAt attribute of the TemplateHandler object
      Parameters:
      position - Description of the Parameter
      Returns:
      The templateAt value
    • getMappedSubstructures

      public IAtomContainerSet getMappedSubstructures(IAtomContainer molecule) throws CDKException
      Checks if one of the loaded templates is a substructure in the given Molecule and returns all matched substructures in a IAtomContainerSet. This method does not assign any coordinates.
      Parameters:
      molecule - The molecule to be check for potential templates
      Returns:
      an IAtomContainerSet of all matched substructures of the molecule
      Throws:
      CDKException - if an error occurs
    • createSingleton

      public static TemplateHandler createSingleton(IAtomContainer template)
      Singleton template instance, mainly useful for aligning molecules. If the template does not have coordinates an error is thrown. For safety we clone the molecule.
      Parameters:
      template - the molecule
      Returns:
      new template handler
    • createFromSubstructure

      public static TemplateHandler createFromSubstructure(Pattern ptrn, Iterable<IAtomContainer> mols)
      Create a template from a substructure pattern. Using this template handler in the diagram generator then allows us to align to common reference.
      Parameters:
      ptrn - the structure pattern to match
      mols - list of molecules
      Returns:
      new template handler
    • createFromSubstructure

      public static TemplateHandler createFromSubstructure(Pattern ptrn, IAtomContainer mol)
      Create a template from a substructure pattern. Using this template handler in the diagram generator then allows us to align to common reference.
      Parameters:
      ptrn - the structure pattern to match
      mol - molecule
      Returns:
      new template handler