Class AtomPlacer
java.lang.Object
org.openscience.cdk.layout.AtomPlacer
Methods for generating coordinates for atoms in various situations. They can
be used for Automated Structure Diagram Generation or in the interactive
buildup of molecules by the user.
- Author:
- steinbeck
- Created on:
- 2003-08-29
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for the AtomPlacer objectAtomPlacer(IAtomContainer molecule) Constructor for the AtomPlacer providing a molecule -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanTrue is all the atoms in the given AtomContainer have been placedstatic voidbreadthFirstSearch(IAtomContainer ac, List<IAtom> sphere, IAtomContainer[] pathes) Performs a breadthFirstSearch in an AtomContainer starting with a particular sphere, which usually consists of one start atom, and searches for the longest aliphatic chain which is yet unplaced.voiddistributePartners(IAtom atom, IAtomContainer placedNeighbours, javax.vecmath.Point2d sharedAtomsCenter, IAtomContainer unplacedNeighbours, double bondLength) Distribute the bonded atoms (neighbours) of an atom such that they fill the remaining space around an atom in a geometrically nice way.static IAtomContainergetInitialLongestChain(IAtomContainer molecule) Search an aliphatic molecule for the longest chain.static IAtomContainergetLongestUnplacedChain(IAtomContainer molecule, IAtom startAtom) Search a molecule for the longest unplaced, aliphatic chain in it.Return the molecule the AtomPlacer currently works withjavax.vecmath.Vector2dgetNextBondVector(IAtom atom, IAtom previousAtom, javax.vecmath.Point2d distanceMeasure, boolean trans) Returns the next bond vector needed for drawing an extended linear chain of atoms.static IAtomContainerGet all the placed atoms in an AtomContainerstatic StringlistNumbers(IAtomContainer mol, List<IAtom> ac) Returns a string with the numbers of all atoms in a Vector relative to a given molecule.static StringlistNumbers(IAtomContainer mol, IAtomContainer ac) Returns a string with the numbers of all atoms in an AtomContainer relative to a given molecule.Returns a string with the numbers of all placed atoms in an AtomContainerstatic voidMarks all the atoms in the given AtomContainer as not placedstatic voidMarks all the atoms in the given AtomContainer as placedvoidpartitionPartners(IAtom atom, IAtomContainer unplacedPartners, IAtomContainer placedPartners) Partition the bonding partners of a given atom into placed (coordinates assinged) and not placed.booleanbooleanConvenience method to place a single atom.voidplaceLinearChain(IAtomContainer atomContainer, javax.vecmath.Vector2d initialBondVector, double bondLength) Places the atoms in a linear chain.voidpopulatePolygonCorners(List<IAtom> atoms, javax.vecmath.Point2d center, double thetaBeg, double thetaStep, double radius) Populates the corners of a polygon with atoms.voidsetMolecule(IAtomContainer molecule) Sets the molecule the AtomPlacer currently works withstatic booleanshouldBeLinear(IAtom atom, IAtomContainer molecule) Deprecated.
-
Field Details
-
debug
public static final boolean debug- See Also:
-
PRIORITY
- See Also:
-
MACROCYCLE_ATOM_HINT
- See Also:
-
-
Constructor Details
-
AtomPlacer
public AtomPlacer()Constructor for the AtomPlacer object -
AtomPlacer
Constructor for the AtomPlacer providing a molecule- Parameters:
molecule- the molecule being laid-out
-
-
Method Details
-
getMolecule
Return the molecule the AtomPlacer currently works with- Returns:
- the molecule the AtomPlacer currently works with
-
setMolecule
Sets the molecule the AtomPlacer currently works with- Parameters:
molecule- the molecule the AtomPlacer currently works with
-
distributePartners
public void distributePartners(IAtom atom, IAtomContainer placedNeighbours, javax.vecmath.Point2d sharedAtomsCenter, IAtomContainer unplacedNeighbours, double bondLength) Distribute the bonded atoms (neighbours) of an atom such that they fill the remaining space around an atom in a geometrically nice way. IMPORTANT: This method is not supposed to handle the case of one or no place neighbor. In the case of one placed neigbor, the chain placement methods should be used.- Parameters:
atom- The atom whose partners are to be placedplacedNeighbours- The atoms which are already placedsharedAtomsCenter- The 2D centre of the placed AtomsunplacedNeighbours- The partners to be placedbondLength- The standared bond length for the newly placed Atoms
-
placeLinearChain
public void placeLinearChain(IAtomContainer atomContainer, javax.vecmath.Vector2d initialBondVector, double bondLength) Places the atoms in a linear chain.Expects the first atom to be placed and places the next atom according to initialBondVector. The rest of the chain is placed such that it is as linear as possible (in the overall result, the angles in the chain are set to 120 Deg.)
- Parameters:
atomContainer- The IAtomContainer containing the chain atom to be placedinitialBondVector- The Vector indicating the direction of the first bondbondLength- The factor used to scale the initialBondVector
-
place
Convenience method to place a single atom. This function will first find a placed neighbour (for this function - one with coordinates defined,IChemObject.PLACEDdoes not need to be set) and then place this new atoms considering the neighbour's neighbours. Essentially this utility is useful for sprouting a new atom to an already placed structure.- Parameters:
atom- the atom to placebondLength- the default bond length if no bonds in the container- Returns:
- the atom was placed or not
-
place
-
getNextBondVector
public javax.vecmath.Vector2d getNextBondVector(IAtom atom, IAtom previousAtom, javax.vecmath.Point2d distanceMeasure, boolean trans) Returns the next bond vector needed for drawing an extended linear chain of atoms. It assumes an angle of 120 deg for a nice chain layout and calculates the two possible placments for the next atom. It returns the vector pointing farmost away from a given start atom.- Parameters:
atom- An atom for which the vector to the next atom to draw is calculatedpreviousAtom- The preceding atom for angle calculationdistanceMeasure- A point from which the next atom is to be farmost awaytrans- if true E (trans) configurations are built, false makes Z (cis) configurations- Returns:
- A vector pointing to the location of the next atom to draw
-
populatePolygonCorners
public void populatePolygonCorners(List<IAtom> atoms, javax.vecmath.Point2d center, double thetaBeg, double thetaStep, double radius) Populates the corners of a polygon with atoms. Used to place atoms in a geometrically regular way around a ring center or another atom. If this is used to place the bonding partner of an atom (and not to draw a ring) we want to place the atoms such that those with highest "weight" are placed furthermost away from the rest of the molecules. The "weight" mentioned here is calculated by a modified morgan number algorithm.- Parameters:
atoms- All the atoms to drawcenter- The center of a ring, or an atom for which the partners are to be placedthetaBeg- A start angle (in radians), giving the angle of the most clockwise atom which has already been placedthetaStep- An angle (in radians) to be added for each atom from atomsToDrawradius- The radius of the polygon to be populated: bond length or ring radius
-
partitionPartners
public void partitionPartners(IAtom atom, IAtomContainer unplacedPartners, IAtomContainer placedPartners) Partition the bonding partners of a given atom into placed (coordinates assinged) and not placed.- Parameters:
atom- The atom whose bonding partners are to be partitionedunplacedPartners- A vector for the unplaced bonding partners to go inplacedPartners- A vector for the placed bonding partners to go in
-
getInitialLongestChain
Search an aliphatic molecule for the longest chain. This is the method to be used if there are no rings in the molecule and you want to layout the longest chain in the molecule as a starting point of the structure diagram generation.- Parameters:
molecule- The molecule to be search for the longest unplaced chain- Returns:
- An AtomContainer holding the longest chain.
- Throws:
NoSuchAtomException- Description of the ExceptionCDKException
-
getLongestUnplacedChain
public static IAtomContainer getLongestUnplacedChain(IAtomContainer molecule, IAtom startAtom) throws CDKException Search a molecule for the longest unplaced, aliphatic chain in it. If an aliphatic chain encounters an unplaced ring atom, the ring atom is also appended to allow for it to be laid out. This gives us a vector for attaching the unplaced ring later.- Parameters:
molecule- The molecule to be search for the longest unplaced chainstartAtom- A start atom from which the chain search starts- Returns:
- An AtomContainer holding the longest unplaced chain.
- Throws:
CDKException- Description of the Exception
-
breadthFirstSearch
public static void breadthFirstSearch(IAtomContainer ac, List<IAtom> sphere, IAtomContainer[] pathes) throws CDKException Performs a breadthFirstSearch in an AtomContainer starting with a particular sphere, which usually consists of one start atom, and searches for the longest aliphatic chain which is yet unplaced. If the search encounters an unplaced ring atom, it is also appended to the chain so that this last bond of the chain can also be laid out. This gives us the orientation for the attachment of the ring system.- Parameters:
ac- The AtomContainer to be searchedsphere- A sphere of atoms to start the search withpathes- A vector of N pathes (N = no of heavy atoms).- Throws:
CDKException- Description of the Exception
-
listPlaced
Returns a string with the numbers of all placed atoms in an AtomContainer- Parameters:
ac- The AtomContainer for which the placed atoms are to be listed- Returns:
- A string with the numbers of all placed atoms in an AtomContainer
-
listNumbers
Returns a string with the numbers of all atoms in an AtomContainer relative to a given molecule. I.e. the number the is listesd is the position of each atom in the molecule.- Parameters:
mol- Description of the Parameterac- The AtomContainer for which the placed atoms are to be listed- Returns:
- A string with the numbers of all placed atoms in an AtomContainer
- Throws:
CDKException- Description of the Exception
-
listNumbers
Returns a string with the numbers of all atoms in a Vector relative to a given molecule. I.e. the number the is listesd is the position of each atom in the molecule.- Parameters:
mol- Description of the Parameterac- The Vector for which the placed atoms are to be listed- Returns:
- A string with the numbers of all placed atoms in an AtomContainer
-
allPlaced
True is all the atoms in the given AtomContainer have been placed- Parameters:
ac- The AtomContainer to be searched- Returns:
- True is all the atoms in the given AtomContainer have been placed
-
markNotPlaced
Marks all the atoms in the given AtomContainer as not placed- Parameters:
ac- The AtomContainer whose atoms are to be marked
-
markPlaced
Marks all the atoms in the given AtomContainer as placed- Parameters:
ac- The AtomContainer whose atoms are to be marked
-
getPlacedAtoms
Get all the placed atoms in an AtomContainer- Parameters:
ac- The AtomContainer to be searched for placed atoms- Returns:
- An AtomContainer containing all the placed atoms
-
shouldBeLinear
Deprecated.
-