org.openscience.cdk.geometry
Class GeometryTools

java.lang.Object
  extended by org.openscience.cdk.geometry.GeometryTools

public class GeometryTools
extends Object

A set of static utility classes for geometric calculations and operations. This class is extensively used, for example, by JChemPaint to edit molecule. All methods in this class change the coordinates of the atoms. Use GeometryTools if you use an external set of coordinates (e. g. renderingCoordinates from RendererModel)

Author:
seb, Stefan Kuhn, Egon Willighagen, Ludovic Petain, Christian Hoppe, Niels Out
Belongs to CDK module:
standard
Source code:
HEAD

Constructor Summary
GeometryTools()
           
 
Method Summary
static javax.vecmath.Vector2d calculatePerpendicularUnitVector(javax.vecmath.Point2d point1, javax.vecmath.Point2d point2)
          Determines the normalized vector orthogonal on the vector p1->p2.
static void center(IAtomContainer atomCon, Dimension areaDim)
          Centers the molecule in the given area See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
static double[] distanceCalculator(double[] coords, double dist)
           
static int[] distanceCalculator(int[] coords, double dist)
          Gets the coordinates of two points (that represent a bond) and calculates for each the coordinates of two new points that have the given distance vertical to the bond.
static List<IAtom> findClosestInSpace(IAtomContainer container, IAtom startAtom, int max)
          Returns the atoms which are closes to an atom in an AtomContainer by distance in 3d.
static javax.vecmath.Point2d get2DCenter(IAtomContainer container)
          Returns the geometric center of all the atoms in the atomContainer.
static javax.vecmath.Point2d get2DCenter(IRingSet ringSet)
          Returns the geometric center of all the rings in this ringset.
static javax.vecmath.Point2d get2DCenter(Iterable<IAtom> atoms)
          Calculates the center of the given atoms and returns it as a Point2d See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
static javax.vecmath.Point2d get2DCenter(Iterator<IAtom> atoms)
          Calculates the center of the given atoms and returns it as a Point2d See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
static javax.vecmath.Point2d get2DCentreOfMass(IAtomContainer ac)
          Calculates the center of mass for the Atoms in the AtomContainer for the 2D coordinates.
static Dimension get2DDimension(IAtomContainer atomCon)
          Returns the java.awt.Dimension of a molecule See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
static javax.vecmath.Point3d get3DCenter(IAtomContainer ac)
          Returns the geometric center of all the atoms in this atomContainer.
static javax.vecmath.Point3d get3DCentreOfMass(IAtomContainer ac)
          Calculates the center of mass for the Atoms in the AtomContainer for the 2D coordinates.
static double getAllAtomRMSD(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, Map<Integer,Integer> mappedAtoms, boolean Coords3d)
          Return the RMSD between the 2 aligned molecules.
static double getAngle(double xDiff, double yDiff)
          Gets the angle attribute of the GeometryTools class
static double getAngleRMSD(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, Map<Integer,Integer> mappedAtoms)
          Return the variation of each angle value between the 2 aligned molecules.
static int getBestAlignmentForLabel(IAtomContainer container, IAtom atom)
          Determines the best alignment for the label of an atom in 2D space.
static int getBestAlignmentForLabelXY(IAtomContainer container, IAtom atom)
          Determines the best alignment for the label of an atom in 2D space.
static int[] getBondCoordinates(IBond bond)
          Writes the coordinates of the atoms participating the given bond into an array.
static double getBondLengthAverage(IAtomContainer container)
          An average of all 2D bond length values is produced.
static double getBondLengthAverage(IReaction reaction)
           
static double getBondLengthAverage3D(IAtomContainer container)
          An average of all 3D bond length values is produced, using point3ds in atoms.
static double getBondLengthRMSD(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, Map<Integer,Integer> mappedAtoms, boolean Coords3d)
          Return the RMSD of bonds length between the 2 aligned molecules.
static IAtom getClosestAtom(double xPosition, double yPosition, IAtomContainer atomCon)
          Returns the atom of the given molecule that is closest to the given coordinates.
static IAtom getClosestAtom(double xPosition, double yPosition, IAtomContainer atomCon, IAtom toignore)
          Returns the atom of the given molecule that is closest to the given coordinates and is not the atom.
static IAtom getClosestAtom(IAtomContainer atomCon, IAtom atom)
          Returns the atom of the given molecule that is closest to the given atom (excluding itself).
static IAtom getClosestAtom(int xPosition, int yPosition, IAtomContainer atomCon)
          Returns the atom of the given molecule that is closest to the given coordinates.
static IBond getClosestBond(double xPosition, double yPosition, IAtomContainer atomCon)
          Returns the bond of the given molecule that is closest to the given coordinates.
static IBond getClosestBond(int xPosition, int yPosition, IAtomContainer atomCon)
          Returns the bond of the given molecule that is closest to the given coordinates.
static double getHeavyAtomRMSD(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, Map<Integer,Integer> mappedAtoms, boolean hetAtomOnly, boolean Coords3d)
          Return the RMSD of the heavy atoms between the 2 aligned molecules.
static double getLength2D(IBond bond)
          Returns the geometric length of this bond in 2D space.
static double[] getMinMax(IAtomContainer container)
          Returns the minimum and maximum X and Y coordinates of the atoms in the AtomContainer.
static double getNormalizationFactor(IAtomContainer container)
          Calculates the normalization factor in order to get an average bond length of 1.5.
static Rectangle2D getRectangle2D(IAtomContainer container)
          Returns the 2D rectangle spanning the space occupied by the atom container.
static double getScaleFactor(IAtomContainer container, double bondLength)
          Determines the scale factor for displaying a structure loaded from disk in a frame.
static boolean has2DCoordinates(IAtom atom)
          Determines if this Atom contains 2D coordinates.
static boolean has2DCoordinates(IAtomContainer container)
          Determines if this AtomContainer contains 2D coordinates.
static boolean has2DCoordinates(IBond bond)
          Determines if this Bond contains 2D coordinates.
static int has2DCoordinatesNew(IAtomContainer container)
          Determines if this AtomContainer contains 2D coordinates for some or all molecules.
static boolean has3DCoordinates(IAtomContainer container)
          Determines if this model contains 3D coordinates
static boolean has3DCoordinates(IChemModel chemModel)
          Determines if this model contains 3D coordinates for all atoms.
static Map<Integer,Integer> mapAtomsOfAlignedStructures(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, double searchRadius, Map<Integer,Integer> mappedAtoms)
          Returns a Map with the AtomNumbers, the first number corresponds to the first (or the largest AtomContainer) atomcontainer.
static void normalize(javax.vecmath.Point3d point)
          Normalizes a point.
static void rotate(IAtomContainer atomCon, javax.vecmath.Point2d center, double angle)
          Rotates a molecule around a given center by a given angle
static void rotate(IAtom atom, javax.vecmath.Point3d p1, javax.vecmath.Point3d p2, double angle)
          Rotates a 3D point about a specified line segment by a specified angle.
static void scaleMolecule(IAtomContainer atomCon, Dimension areaDim, double fillFactor)
          Scales a molecule such that it fills a given percentage of a given dimension See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
static void scaleMolecule(IAtomContainer atomCon, double scaleFactor)
          Multiplies all the coordinates of the atoms of the given molecule with the scalefactor.
static Rectangle2D shiftContainer(IAtomContainer container, Rectangle2D bounds, Rectangle2D last, double gap)
          Shift the container horizontally to the right to make its bounds not overlap with the other bounds.
static Rectangle2D shiftReactionVertical(IReaction reaction, Rectangle2D bounds, Rectangle2D last, double gap)
          Shift the containers in a reaction vertically upwards to not overlap with the reference Rectangle2D.
static void sortBy2DDistance(IAtom[] atoms, javax.vecmath.Point2d point)
          Sorts a Vector of atoms such that the 2D distances of the atom locations from a given point are smallest for the first atoms in the vector See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
static void translate2D(IAtomContainer atomCon, double transX, double transY)
          Translates the given molecule by the given Vector.
static void translate2D(IAtomContainer atomCon, javax.vecmath.Vector2d vector)
          Translates a molecule from the origin to a new point denoted by a vector.
static void translate2DCenterTo(IAtomContainer container, javax.vecmath.Point2d p)
          Translates the geometric 2DCenter of the given AtomContainer container to the specified Point2d p.
static void translate2DCentreOfMassTo(IAtomContainer atomCon, javax.vecmath.Point2d p)
          Translates a molecule from the origin to a new point denoted by a vector.
static void translateAllPositive(IAtomContainer atomCon)
          Adds an automatically calculated offset to the coordinates of all atoms such that all coordinates are positive and the smallest x or y coordinate is exactly zero.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeometryTools

public GeometryTools()
Method Detail

translateAllPositive

public static void translateAllPositive(IAtomContainer atomCon)
Adds an automatically calculated offset to the coordinates of all atoms such that all coordinates are positive and the smallest x or y coordinate is exactly zero. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
atomCon - AtomContainer for which all the atoms are translated to positive coordinates

translate2D

public static void translate2D(IAtomContainer atomCon,
                               double transX,
                               double transY)
Translates the given molecule by the given Vector. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
atomCon - The molecule to be translated
transX - translation in x direction
transY - translation in y direction

scaleMolecule

public static void scaleMolecule(IAtomContainer atomCon,
                                 Dimension areaDim,
                                 double fillFactor)
Scales a molecule such that it fills a given percentage of a given dimension See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
atomCon - The molecule to be scaled
areaDim - The dimension to be filled
fillFactor - The percentage of the dimension to be filled

scaleMolecule

public static void scaleMolecule(IAtomContainer atomCon,
                                 double scaleFactor)
Multiplies all the coordinates of the atoms of the given molecule with the scalefactor. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
atomCon - The molecule to be scaled
scaleFactor - Description of the Parameter

center

public static void center(IAtomContainer atomCon,
                          Dimension areaDim)
Centers the molecule in the given area See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
atomCon - molecule to be centered
areaDim - dimension in which the molecule is to be centered

translate2D

public static void translate2D(IAtomContainer atomCon,
                               javax.vecmath.Vector2d vector)
Translates a molecule from the origin to a new point denoted by a vector. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
atomCon - molecule to be translated
vector - dimension that represents the translation vector

rotate

public static void rotate(IAtomContainer atomCon,
                          javax.vecmath.Point2d center,
                          double angle)
Rotates a molecule around a given center by a given angle

Parameters:
atomCon - The molecule to be rotated
center - A point giving the rotation center
angle - The angle by which to rotate the molecule, in radians

rotate

public static void rotate(IAtom atom,
                          javax.vecmath.Point3d p1,
                          javax.vecmath.Point3d p2,
                          double angle)
Rotates a 3D point about a specified line segment by a specified angle. The code is based on code available here. Positive angles are anticlockwise looking down the axis towards the origin. Assume right hand coordinate system.

Parameters:
atom - The atom to rotate
p1 - The first point of the line segment
p2 - The second point of the line segment
angle - The angle to rotate by (in degrees)

normalize

public static void normalize(javax.vecmath.Point3d point)
Normalizes a point.

Parameters:
point - The point to normalize

get2DDimension

public static Dimension get2DDimension(IAtomContainer atomCon)
Returns the java.awt.Dimension of a molecule See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
atomCon - of which the dimension should be returned
Returns:
The java.awt.Dimension of this molecule

getRectangle2D

public static Rectangle2D getRectangle2D(IAtomContainer container)
Returns the 2D rectangle spanning the space occupied by the atom container.

Parameters:
container - IAtomContainer to calculate the rectangle for
Returns:
a Rectangle2D describing the space occupied

getMinMax

public static double[] getMinMax(IAtomContainer container)
Returns the minimum and maximum X and Y coordinates of the atoms in the AtomContainer. The output is returned as:
   minmax[0] = minX;
   minmax[1] = minY;
   minmax[2] = maxX;
   minmax[3] = maxY;
 
See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
container - Description of the Parameter
Returns:
An four int array as defined above.

translate2DCentreOfMassTo

public static void translate2DCentreOfMassTo(IAtomContainer atomCon,
                                             javax.vecmath.Point2d p)
Translates a molecule from the origin to a new point denoted by a vector. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
atomCon - molecule to be translated
p - Description of the Parameter

get2DCenter

public static javax.vecmath.Point2d get2DCenter(Iterable<IAtom> atoms)
Calculates the center of the given atoms and returns it as a Point2d See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
atoms - The vector of the given atoms
Returns:
The center of the given atoms as Point2d

get2DCenter

public static javax.vecmath.Point2d get2DCenter(Iterator<IAtom> atoms)
Calculates the center of the given atoms and returns it as a Point2d See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
atoms - The Iterator of the given atoms
Returns:
The center of the given atoms as Point2d

get2DCenter

public static javax.vecmath.Point2d get2DCenter(IRingSet ringSet)
Returns the geometric center of all the rings in this ringset. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
ringSet - Description of the Parameter
Returns:
the geometric center of the rings in this ringset

get2DCentreOfMass

public static javax.vecmath.Point2d get2DCentreOfMass(IAtomContainer ac)
Calculates the center of mass for the Atoms in the AtomContainer for the 2D coordinates. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
ac - AtomContainer for which the center of mass is calculated
Returns:
Null, if any of the atomcontainer IAtom's masses are null
Keywords:
center of mass

get2DCenter

public static javax.vecmath.Point2d get2DCenter(IAtomContainer container)
Returns the geometric center of all the atoms in the atomContainer. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
container - Description of the Parameter
Returns:
the geometric center of the atoms in this atomContainer

translate2DCenterTo

public static void translate2DCenterTo(IAtomContainer container,
                                       javax.vecmath.Point2d p)
Translates the geometric 2DCenter of the given AtomContainer container to the specified Point2d p.

Parameters:
container - AtomContainer which should be translated.
p - New Location of the geometric 2D Center.
See Also:
get2DCenter(java.lang.Iterable), translate2DCentreOfMassTo(org.openscience.cdk.interfaces.IAtomContainer, javax.vecmath.Point2d)

get3DCentreOfMass

public static javax.vecmath.Point3d get3DCentreOfMass(IAtomContainer ac)
Calculates the center of mass for the Atoms in the AtomContainer for the 2D coordinates. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
ac - AtomContainer for which the center of mass is calculated
Returns:
Description of the Return Value
Keywords:
center of mass
Dictionary pointer(s):
calculate3DCenterOfMass in the Blue Obelisk Chemoinformatics Dictionary [blue-obelisk:calculate3DCenterOfMass]

get3DCenter

public static javax.vecmath.Point3d get3DCenter(IAtomContainer ac)
Returns the geometric center of all the atoms in this atomContainer. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
ac - Description of the Parameter
Returns:
the geometric center of the atoms in this atomContainer

getAngle

public static double getAngle(double xDiff,
                              double yDiff)
Gets the angle attribute of the GeometryTools class

Parameters:
xDiff - Description of the Parameter
yDiff - Description of the Parameter
Returns:
The angle value

distanceCalculator

public static int[] distanceCalculator(int[] coords,
                                       double dist)
Gets the coordinates of two points (that represent a bond) and calculates for each the coordinates of two new points that have the given distance vertical to the bond.

Parameters:
coords - The coordinates of the two given points of the bond like this [point1x, point1y, point2x, point2y]
dist - The vertical distance between the given points and those to be calculated
Returns:
The coordinates of the calculated four points

distanceCalculator

public static double[] distanceCalculator(double[] coords,
                                          double dist)

getBondCoordinates

public static int[] getBondCoordinates(IBond bond)
Writes the coordinates of the atoms participating the given bond into an array. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
bond - The given bond
Returns:
The array with the coordinates

getClosestAtom

public static IAtom getClosestAtom(int xPosition,
                                   int yPosition,
                                   IAtomContainer atomCon)
Returns the atom of the given molecule that is closest to the given coordinates. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
xPosition - The x coordinate
yPosition - The y coordinate
atomCon - The molecule that is searched for the closest atom
Returns:
The atom that is closest to the given coordinates

getClosestAtom

public static IAtom getClosestAtom(IAtomContainer atomCon,
                                   IAtom atom)
Returns the atom of the given molecule that is closest to the given atom (excluding itself).

Parameters:
atomCon - The molecule that is searched for the closest atom
atom - The atom to search around
Returns:
The atom that is closest to the given coordinates

getClosestAtom

public static IAtom getClosestAtom(double xPosition,
                                   double yPosition,
                                   IAtomContainer atomCon,
                                   IAtom toignore)
Returns the atom of the given molecule that is closest to the given coordinates and is not the atom. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
xPosition - The x coordinate
yPosition - The y coordinate
atomCon - The molecule that is searched for the closest atom
toignore - This molecule will not be returned.
Returns:
The atom that is closest to the given coordinates

getClosestAtom

public static IAtom getClosestAtom(double xPosition,
                                   double yPosition,
                                   IAtomContainer atomCon)
Returns the atom of the given molecule that is closest to the given coordinates. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
xPosition - The x coordinate
yPosition - The y coordinate
atomCon - The molecule that is searched for the closest atom
Returns:
The atom that is closest to the given coordinates

getClosestBond

public static IBond getClosestBond(int xPosition,
                                   int yPosition,
                                   IAtomContainer atomCon)
Returns the bond of the given molecule that is closest to the given coordinates. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
xPosition - The x coordinate
yPosition - The y coordinate
atomCon - The molecule that is searched for the closest bond
Returns:
The bond that is closest to the given coordinates

getClosestBond

public static IBond getClosestBond(double xPosition,
                                   double yPosition,
                                   IAtomContainer atomCon)
Returns the bond of the given molecule that is closest to the given coordinates. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
xPosition - The x coordinate
yPosition - The y coordinate
atomCon - The molecule that is searched for the closest bond
Returns:
The bond that is closest to the given coordinates

sortBy2DDistance

public static void sortBy2DDistance(IAtom[] atoms,
                                    javax.vecmath.Point2d point)
Sorts a Vector of atoms such that the 2D distances of the atom locations from a given point are smallest for the first atoms in the vector See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
point - The point from which the distances to the atoms are measured
atoms - The atoms for which the distances to point are measured

getScaleFactor

public static double getScaleFactor(IAtomContainer container,
                                    double bondLength)
Determines the scale factor for displaying a structure loaded from disk in a frame. An average of all bond length values is produced and a scale factor is determined which would scale the given molecule such that its See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
container - The AtomContainer for which the ScaleFactor is to be calculated
bondLength - The target bond length
Returns:
The ScaleFactor with which the AtomContainer must be scaled to have the target bond length

getBondLengthAverage

public static double getBondLengthAverage(IAtomContainer container)
An average of all 2D bond length values is produced. Bonds which have Atom's with no coordinates are disregarded. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
container - The AtomContainer for which the average bond length is to be calculated
Returns:
the average bond length

getLength2D

public static double getLength2D(IBond bond)
Returns the geometric length of this bond in 2D space. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
bond - Description of the Parameter
Returns:
The geometric length of this bond

has2DCoordinates

public static boolean has2DCoordinates(IAtomContainer container)
Determines if this AtomContainer contains 2D coordinates. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
container - Description of the Parameter
Returns:
boolean indication that 2D coordinates are available

has2DCoordinatesNew

public static int has2DCoordinatesNew(IAtomContainer container)
Determines if this AtomContainer contains 2D coordinates for some or all molecules. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
container - the molecule to be considered
Returns:
0 no 2d, 1=some, 2= for each atom

has2DCoordinates

public static boolean has2DCoordinates(IAtom atom)
Determines if this Atom contains 2D coordinates. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
atom - Description of the Parameter
Returns:
boolean indication that 2D coordinates are available

has2DCoordinates

public static boolean has2DCoordinates(IBond bond)
Determines if this Bond contains 2D coordinates. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
bond - Description of the Parameter
Returns:
boolean indication that 2D coordinates are available

has3DCoordinates

public static boolean has3DCoordinates(IAtomContainer container)
Determines if this model contains 3D coordinates

Parameters:
container - the molecule to consider
Returns:
boolean indication that 3D coordinates are available

calculatePerpendicularUnitVector

public static javax.vecmath.Vector2d calculatePerpendicularUnitVector(javax.vecmath.Point2d point1,
                                                                      javax.vecmath.Point2d point2)
Determines the normalized vector orthogonal on the vector p1->p2.

Parameters:
point1 - Description of the Parameter
point2 - Description of the Parameter
Returns:
Description of the Return Value

getNormalizationFactor

public static double getNormalizationFactor(IAtomContainer container)
Calculates the normalization factor in order to get an average bond length of 1.5. It takes only into account Bond's with two atoms. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
container - Description of the Parameter
Returns:
The normalizationFactor value

getBestAlignmentForLabel

public static int getBestAlignmentForLabel(IAtomContainer container,
                                           IAtom atom)
Determines the best alignment for the label of an atom in 2D space. It returns 1 if left aligned, and -1 if right aligned. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
container - Description of the Parameter
atom - Description of the Parameter
Returns:
The bestAlignmentForLabel value

getBestAlignmentForLabelXY

public static int getBestAlignmentForLabelXY(IAtomContainer container,
                                             IAtom atom)
Determines the best alignment for the label of an atom in 2D space. It returns 1 if right (=default) aligned, and -1 if left aligned. returns 2 if top aligned, and -2 if H is aligned below the atom See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets

Parameters:
container - Description of the Parameter
atom - Description of the Parameter
Returns:
The bestAlignmentForLabel value

findClosestInSpace

public static List<IAtom> findClosestInSpace(IAtomContainer container,
                                             IAtom startAtom,
                                             int max)
                                      throws CDKException
Returns the atoms which are closes to an atom in an AtomContainer by distance in 3d.

Parameters:
container - The AtomContainer to examine
startAtom - the atom to start from
max - the number of neighbours to return
Returns:
the average bond length
Throws:
CDKException - Description of the Exception

mapAtomsOfAlignedStructures

public static Map<Integer,Integer> mapAtomsOfAlignedStructures(IAtomContainer firstAtomContainer,
                                                               IAtomContainer secondAtomContainer,
                                                               double searchRadius,
                                                               Map<Integer,Integer> mappedAtoms)
                                                        throws CDKException
Returns a Map with the AtomNumbers, the first number corresponds to the first (or the largest AtomContainer) atomcontainer. It is recommend to sort the atomContainer due to their number of atoms before calling this function. The molecules needs to be aligned before! (coordinates are needed)

Parameters:
firstAtomContainer - the (largest) first aligned AtomContainer which is the reference
secondAtomContainer - the second aligned AtomContainer
searchRadius - the radius of space search from each atom
Returns:
a Map of the mapped atoms
Throws:
CDKException - Description of the Exception

getBondLengthRMSD

public static double getBondLengthRMSD(IAtomContainer firstAtomContainer,
                                       IAtomContainer secondAtomContainer,
                                       Map<Integer,Integer> mappedAtoms,
                                       boolean Coords3d)
Return the RMSD of bonds length between the 2 aligned molecules.

Parameters:
firstAtomContainer - the (largest) first aligned AtomContainer which is the reference
secondAtomContainer - the second aligned AtomContainer
mappedAtoms - Map: a Map of the mapped atoms
Coords3d - boolean: true if moecules has 3D coords, false if molecules has 2D coords
Returns:
double: all the RMSD of bonds length

getAngleRMSD

public static double getAngleRMSD(IAtomContainer firstAtomContainer,
                                  IAtomContainer secondAtomContainer,
                                  Map<Integer,Integer> mappedAtoms)
Return the variation of each angle value between the 2 aligned molecules.

Parameters:
firstAtomContainer - the (largest) first aligned AtomContainer which is the reference
secondAtomContainer - the second aligned AtomContainer
mappedAtoms - Map: a Map of the mapped atoms
Returns:
double: the value of the RMSD

getAllAtomRMSD

public static double getAllAtomRMSD(IAtomContainer firstAtomContainer,
                                    IAtomContainer secondAtomContainer,
                                    Map<Integer,Integer> mappedAtoms,
                                    boolean Coords3d)
                             throws CDKException
Return the RMSD between the 2 aligned molecules.

Parameters:
firstAtomContainer - the (largest) first aligned AtomContainer which is the reference
secondAtomContainer - the second aligned AtomContainer
mappedAtoms - Map: a Map of the mapped atoms
Coords3d - boolean: true if molecules has 3D coords, false if molecules has 2D coords
Returns:
double: the value of the RMSD
Throws:
CDKException - if there is an error in getting mapped atoms

getHeavyAtomRMSD

public static double getHeavyAtomRMSD(IAtomContainer firstAtomContainer,
                                      IAtomContainer secondAtomContainer,
                                      Map<Integer,Integer> mappedAtoms,
                                      boolean hetAtomOnly,
                                      boolean Coords3d)
Return the RMSD of the heavy atoms between the 2 aligned molecules.

Parameters:
firstAtomContainer - the (largest) first aligned AtomContainer which is the reference
secondAtomContainer - the second aligned AtomContainer
mappedAtoms - Map: a Map of the mapped atoms
hetAtomOnly - boolean: true if only hetero atoms should be considered
Coords3d - boolean: true if molecules has 3D coords, false if molecules has 2D coords
Returns:
double: the value of the RMSD

getBondLengthAverage3D

public static double getBondLengthAverage3D(IAtomContainer container)
An average of all 3D bond length values is produced, using point3ds in atoms. Atom's with no coordinates are disregarded.

Parameters:
container - The AtomContainer for which the average bond length is to be calculated
Returns:
the average bond length

shiftContainer

public static Rectangle2D shiftContainer(IAtomContainer container,
                                         Rectangle2D bounds,
                                         Rectangle2D last,
                                         double gap)
Shift the container horizontally to the right to make its bounds not overlap with the other bounds.

Parameters:
container - the IAtomContainer to shift to the right
bounds - the Rectangle2D of the IAtomContainer to shift
last - the bounds that is used as reference
gap - the gap between the two Rectangle2Ds
Returns:
the Rectangle2D of the IAtomContainer after the shift

getBondLengthAverage

public static double getBondLengthAverage(IReaction reaction)

has3DCoordinates

public static boolean has3DCoordinates(IChemModel chemModel)
Determines if this model contains 3D coordinates for all atoms.

Parameters:
chemModel - the ChemModel to consider
Returns:
Boolean indication that 3D coordinates are available for all atoms.

shiftReactionVertical

public static Rectangle2D shiftReactionVertical(IReaction reaction,
                                                Rectangle2D bounds,
                                                Rectangle2D last,
                                                double gap)
Shift the containers in a reaction vertically upwards to not overlap with the reference Rectangle2D. The shift is such that the given gap is realized, but only if the reactions are actually overlapping.

Parameters:
reaction - the reaction to shift
bounds - the bounds of the reaction to shift
last - the bounds of the last reaction
Returns:
the Rectangle2D of the shifted reaction