Package org.openscience.cdk.tools
Class HOSECodeGenerator
java.lang.Object
org.openscience.cdk.tools.HOSECodeGenerator
- All Implemented Interfaces:
Serializable
Generates HOSE codes [Bremser, W.. Analytica Chimica Acta. 1978. 103].
IMPORTANT: Your molecule must contain implicit or explicit hydrogens
for this method to work properly.
- Author:
- steinbeck
- See Also:
- Source code:
- main
- Belongs to CDK module:
- standard
- Keywords:
- HOSE code, spherical atom search
- Created on:
- 2002-05-10
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IAtomContainer
The molecular structure on which we workprotected String[]
The bond symbols used for bond orders "single", "double", "triple" and "aromatic"protected String
protected StringBuffer
The HOSECode string that we assemblestatic final int
Ignored parent ordering be considered when sorting spheres (legacy mode) for compatibility with existing ML/AI models.protected int
Counter for the sphere in which we currently work.protected List<org.openscience.cdk.tools.HOSECodeGenerator.TreeNode>
Container for the nodes in a sphere.protected List<org.openscience.cdk.tools.HOSECodeGenerator.TreeNode>[]
Here we store the spheres that we assemble, in order to parse them into a code later. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for the HOSECodeGenerator.HOSECodeGenerator
(int flags) Constructor for the HOSECodeGenerator. -
Method Summary
Modifier and TypeMethodDescriptiongetHOSECode
(IAtomContainer ac, IAtom root, int noOfSpheres) getHOSECode
(IAtomContainer ac, IAtom root, int noOfSpheres, boolean ringsize) getNodesInSphere
(int sphereNumber) getSpheres
(IAtomContainer ac, IAtom root, int noOfSpheres, boolean ringsize) This method is intended to be used to get the atoms around an atom in spheres.makeBremserCompliant
(String code)
-
Field Details
-
sphereNodes
Container for the nodes in a sphere. -
sphere
protected int sphereCounter for the sphere in which we currently work. -
spheres
Here we store the spheres that we assemble, in order to parse them into a code later. -
HOSECode
The HOSECode string that we assemble -
atomContainer
The molecular structure on which we work -
bondSymbols
The bond symbols used for bond orders "single", "double", "triple" and "aromatic" -
centerCode
-
LEGACY_MODE
public static final int LEGACY_MODEIgnored parent ordering be considered when sorting spheres (legacy mode) for compatibility with existing ML/AI models.- See Also:
-
-
Constructor Details
-
HOSECodeGenerator
public HOSECodeGenerator(int flags) Constructor for the HOSECodeGenerator.Important!
A critical bug was discovered in the implementation (see PR 828) which gave the wrong nesting in "some" cases. Fixing this behaviour invalidates any ML/AI models trained on the incorrect values. If you have a model built with the old algorithm that can not be retrained setlegacyMode=true
.- Parameters:
flags
- (default: false)- See Also:
-
HOSECodeGenerator
public HOSECodeGenerator()Constructor for the HOSECodeGenerator.Important!
A critical bug was discovered in the implementation (see PR 828) which gave the wrong nesting in "some" cases. Fixing this behaviour invalidates any ML/AI models trained on the incorrect values. If you have a model built with the old algorithm that can not be retrained set .- See Also:
-
-
Method Details
-
getSpheres
public List<IAtom>[] getSpheres(IAtomContainer ac, IAtom root, int noOfSpheres, boolean ringsize) throws CDKException This method is intended to be used to get the atoms around an atom in spheres. It is not used in this class, but is provided for other classes to use. It also creates the HOSE code in HOSECode as a side-effect.- Parameters:
ac
- TheIAtomContainer
with the molecular skeleton in which the root atom resides.root
- The root atom for which to produce the spheres.noOfSpheres
- The number of spheres to look at.ringsize
- Shall the center code have the ring size in it? Only use if you want to have the hose code later, else say false.- Returns:
- An array of
List
. The list at i-1 contains the atoms at sphere i as TreeNodes. - Throws:
CDKException
-
getHOSECode
Produces a HOSE code for Atomroot
in theIAtomContainer
ac
. The HOSE code is produced for the number of spheres given bynoOfSpheres
. IMPORTANT: if you want aromaticity to be included in the code, you need to run the IAtomContainerac
to theCDKHueckelAromaticityDetector
prior to usinggetHOSECode()
. This method only gives proper results if the molecule is fully saturated (if not, the order of the HOSE code might depend on atoms in higher spheres). This method is known to fail for protons sometimes. IMPORTANT: Your molecule must contain implicit or explicit hydrogens for this method to work properly.- Parameters:
ac
- TheIAtomContainer
with the molecular skeleton in which the root atom residesroot
- The root atom for which to produce the HOSE codenoOfSpheres
- The number of spheres to look at- Returns:
- The HOSECode value
- Throws:
CDKException
- Thrown if something is wrong
-
getHOSECode
public String getHOSECode(IAtomContainer ac, IAtom root, int noOfSpheres, boolean ringsize) throws CDKException Produces a HOSE code for Atomroot
in theIAtomContainer
ac
. The HOSE code is produced for the number of spheres given bynoOfSpheres
. IMPORTANT: if you want aromaticity to be included in the code, you need to run the IAtomContainerac
to theCDKHueckelAromaticityDetector
prior to usinggetHOSECode()
. This method only gives proper results if the molecule is fully saturated (if not, the order of the HOSE code might depend on atoms in higher spheres). This method is known to fail for protons sometimes. IMPORTANT: Your molecule must contain implicit or explicit hydrogens for this method to work properly.- Parameters:
ac
- The IAtomContainer with the molecular skeleton in which the root atom residesroot
- The root atom for which to produce the HOSE codenoOfSpheres
- The number of spheres to look atringsize
- The size of the ring(s) it is in is included in center atom code- Returns:
- The HOSECode value
- Throws:
CDKException
- Thrown if something is wrong
-
makeBremserCompliant
-
getNodesInSphere
-