Class AtomPlacer


  • public class AtomPlacer
    extends Object
    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
    Source code:
    main
    Belongs to CDK module:
    sdg
    Created on:
    2003-08-29
    • Constructor Detail

      • AtomPlacer

        public AtomPlacer()
        Constructor for the AtomPlacer object
    • Method Detail

      • getMolecule

        public IAtomContainer getMolecule()
        Return the molecule the AtomPlacer currently works with
        Returns:
        the molecule the AtomPlacer currently works with
      • setMolecule

        public void setMolecule​(IAtomContainer molecule)
        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 placed
        placedNeighbours - The atoms which are already placed
        unplacedNeighbours - The partners to be placed
        bondLength - The standared bond length for the newly placed Atoms
        sharedAtomsCenter - The 2D centre of the 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 placed
        initialBondVector - The Vector indicating the direction of the first bond
        bondLength - The factor used to scale the initialBondVector
      • 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 calculated
        previousAtom - The preceding atom for angle calculation
        distanceMeasure - A point from which the next atom is to be farmost away
        trans - 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 draw
        thetaBeg - A start angle (in radians), giving the angle of the most clockwise atom which has already been placed
        thetaStep - An angle (in radians) to be added for each atom from atomsToDraw
        center - The center of a ring, or an atom for which the partners are to be placed
        radius - 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 partitioned
        unplacedPartners - A vector for the unplaced bonding partners to go in
        placedPartners - A vector for the placed bonding partners to go in
      • getInitialLongestChain

        public static IAtomContainer getInitialLongestChain​(IAtomContainer molecule)
                                                     throws CDKException
        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 Exception
        CDKException
      • 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 chain
        startAtom - 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 searched
        sphere - A sphere of atoms to start the search with
        pathes - A vector of N pathes (N = no of heavy atoms).
        Throws:
        CDKException - Description of the Exception
      • listPlaced

        public String listPlaced​(IAtomContainer ac)
        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

        public static String listNumbers​(IAtomContainer mol,
                                         IAtomContainer ac)
                                  throws CDKException
        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:
        ac - The AtomContainer for which the placed atoms are to be listed
        mol - Description of the Parameter
        Returns:
        A string with the numbers of all placed atoms in an AtomContainer
        Throws:
        CDKException - Description of the Exception
      • listNumbers

        public static String listNumbers​(IAtomContainer mol,
                                         List<IAtom> ac)
        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:
        ac - The Vector for which the placed atoms are to be listed
        mol - Description of the Parameter
        Returns:
        A string with the numbers of all placed atoms in an AtomContainer
      • allPlaced

        public static boolean allPlaced​(IAtomContainer ac)
        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

        public static void markNotPlaced​(IAtomContainer ac)
        Marks all the atoms in the given AtomContainer as not placed
        Parameters:
        ac - The AtomContainer whose atoms are to be marked
      • markPlaced

        public static void markPlaced​(IAtomContainer ac)
        Marks all the atoms in the given AtomContainer as placed
        Parameters:
        ac - The AtomContainer whose atoms are to be marked
      • getPlacedAtoms

        public static IAtomContainer getPlacedAtoms​(IAtomContainer ac)
        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