Class Atom

    • Field Detail

      • point2d

        protected javax.vecmath.Point2d point2d
        A 2D point specifying the location of this atom in a 2D coordinate space.
      • point3d

        protected javax.vecmath.Point3d point3d
        A 3 point specifying the location of this atom in a 3D coordinate space.
      • fractionalPoint3d

        protected javax.vecmath.Point3d fractionalPoint3d
        A 3 point specifying the location of this atom in a crystal unit cell.
      • hydrogenCount

        protected Integer hydrogenCount
        The number of implicitly bound hydrogen atoms for this atom.
      • stereoParity

        protected Integer stereoParity
        A stereo parity descriptor for the stereochemistry of this atom.
      • charge

        protected Double charge
        The partial charge of the atom. The default value is CDKConstants.UNSET and serves to provide a check whether the charge has been set or not
    • Constructor Detail

      • Atom

        public Atom()
        Constructs an completely unset Atom.
      • Atom

        public Atom​(int elem)
        Create a new atom with of the specified element.
        Parameters:
        elem - atomic number
      • Atom

        public Atom​(int elem,
                    int hcnt)
        Create a new atom with of the specified element and hydrogen count.
        Parameters:
        elem - atomic number
        hcnt - hydrogen count
      • Atom

        public Atom​(int elem,
                    int hcnt,
                    int fchg)
        Create a new atom with of the specified element, hydrogen count, and formal charge.
        Parameters:
        elem - atomic number
        hcnt - hydrogen count
        fchg - formal charge
      • Atom

        public Atom​(String symbol)
        Constructs an Atom from a string containing an element symbol and optionally the atomic mass, hydrogen count, and formal charge. The symbol grammar allows easy construction from common symbols, for example:
             new Atom("NH+");   // nitrogen cation with one hydrogen
             new Atom("OH");    // hydroxy
             new Atom("O-");    // oxygen anion
             new Atom("13CH3"); // methyl isotope 13
         
             atom := {mass}? {symbol} {hcnt}? {fchg}?
             mass := \d+
             hcnt := 'H' \d+
             fchg := '+' \d+? | '-' \d+?
         
        Parameters:
        symbol - string with the element symbol
      • Atom

        public Atom​(String elementSymbol,
                    javax.vecmath.Point3d point3d)
        Constructs an Atom from an Element and a Point3d.
        Parameters:
        elementSymbol - The symbol of the atom
        point3d - The 3D coordinates of the atom
      • Atom

        public Atom​(String elementSymbol,
                    javax.vecmath.Point2d point2d)
        Constructs an Atom from an Element and a Point2d.
        Parameters:
        elementSymbol - The Element
        point2d - The Point
      • Atom

        public Atom​(IElement element)
        Constructs an isotope by copying the symbol, atomic number, flags, identifier, exact mass, natural abundance, mass number, maximum bond order, bond order sum, van der Waals and covalent radii, formal charge, hybridization, electron valency, formal neighbour count and atom type name from the given IAtomType. It does not copy the listeners and properties. If the element is an instance of IAtom, then the 2D, 3D and fractional coordinates, partial atomic charge, hydrogen count and stereo parity are copied too.
        Parameters:
        element - IAtomType to copy information from
    • Method Detail

      • getContainer

        public IAtomContainer getContainer()
        Access the IAtomContainer of which this atom is a member of. Because atoms can be in multiple molecules this method will only work if the atom has been accessed in the context of an IAtomContainer, for example:
        
         IAtomContainer mol  = new AtomContainer();
         IAtom          atom = new Atom(6);
        
         atom.getContainer(); // null
         mol.add(atom);
         atom.getContainer(); // still null
         mol.getAtom(0).getContainer(); // not-null, returns 'mol'
         
        Specified by:
        getContainer in interface IAtom
        Returns:
        the atom container or null if not accessed in the context of a container
      • getIndex

        public int getIndex()
        Acces the index of an atom in the context of an IAtomContainer. If the index is not known, < 0 is returned.
        Specified by:
        getIndex in interface IAtom
        Returns:
        atom index or < 0 if the index is not known
      • bonds

        public Iterable<IBond> bonds()
        Returns the bonds connected to this atom. If the bonds are not known an exception is thrown. This method will only throw an exception if IAtom.getIndex() returns < 0 or IAtom.getContainer() returns null.
        
        
         IAtom atom = ...;
        
         if (atom.getIndex() >= 0) {
           for (IBond bond : atom.bonds()) {
        
           }
         }
        
         if (atom.getContainer() != null) {
           for (IBond bond : atom.bonds()) {
        
           }
         }
        
         IAtomContainer mol = ...;
         // guaranteed not throw an exception
         for (IBond bond : mol.getAtom(i).bonds()) {
        
         }
         
        Specified by:
        bonds in interface IAtom
        Returns:
        iterable of bonds
      • getBondCount

        public int getBondCount()
        Get the number of explicit bonds connected to this atom.
        Specified by:
        getBondCount in interface IAtom
        Returns:
        the total bond count
      • getBond

        public IBond getBond​(IAtom atom)
        Returns the bond connecting 'this' atom to the provided atom. If the atoms are not bonded, null is returned.
        Specified by:
        getBond in interface IAtom
        Parameters:
        atom - the other atom
        Returns:
        the bond connecting the atoms
      • setCharge

        public void setCharge​(Double charge)
        Sets the partial charge of this atom.
        Specified by:
        setCharge in interface IAtom
        Parameters:
        charge - The partial charge
        See Also:
        getCharge()
      • getCharge

        public Double getCharge()
        Returns the partial charge of this atom. If the charge has not been set the return value is Double.NaN
        Specified by:
        getCharge in interface IAtom
        Returns:
        the charge of this atom
        See Also:
        setCharge(java.lang.Double)
      • setImplicitHydrogenCount

        public void setImplicitHydrogenCount​(Integer hydrogenCount)
        Sets the number of implicit hydrogen count of this atom.
        Specified by:
        setImplicitHydrogenCount in interface IAtom
        Parameters:
        hydrogenCount - The number of hydrogen atoms bonded to this atom.
        See Also:
        getImplicitHydrogenCount()
      • setPoint2d

        public void setPoint2d​(javax.vecmath.Point2d point2d)
        Sets a point specifying the location of this atom in a 2D space.
        Specified by:
        setPoint2d in interface IAtom
        Parameters:
        point2d - A point in a 2D plane
        See Also:
        getPoint2d()
      • setPoint3d

        public void setPoint3d​(javax.vecmath.Point3d point3d)
        Sets a point specifying the location of this atom in 3D space.
        Specified by:
        setPoint3d in interface IAtom
        Parameters:
        point3d - A point in a 3-dimensional space
        See Also:
        getPoint3d()
      • setFractionalPoint3d

        public void setFractionalPoint3d​(javax.vecmath.Point3d point3d)
        Sets a point specifying the location of this atom in a Crystal unit cell.
        Specified by:
        setFractionalPoint3d in interface IAtom
        Parameters:
        point3d - A point in a 3d fractional unit cell space
        See Also:
        getFractionalPoint3d(), Crystal
      • getPoint2d

        public javax.vecmath.Point2d getPoint2d()
        Returns a point specifying the location of this atom in a 2D space.
        Specified by:
        getPoint2d in interface IAtom
        Returns:
        A point in a 2D plane. Null if unset.
        See Also:
        setPoint2d(javax.vecmath.Point2d)
      • getPoint3d

        public javax.vecmath.Point3d getPoint3d()
        Returns a point specifying the location of this atom in a 3D space.
        Specified by:
        getPoint3d in interface IAtom
        Returns:
        A point in 3-dimensional space. Null if unset.
        See Also:
        setPoint3d(javax.vecmath.Point3d)
      • compare

        public boolean compare​(Object object)
        Compares a atom with this atom.
        Overrides:
        compare in class AtomType
        Parameters:
        object - of type Atom
        Returns:
        true, if the atoms are equal
      • isAromatic

        public boolean isAromatic()
        Access whether this atom has been marked as aromatic. The default value is false and you must explicitly perceive aromaticity with one of the available models.
        Specified by:
        isAromatic in interface IAtom
        Returns:
        aromatic status
        See Also:
        IChemObject.getFlag(int), Aromaticity
      • isInRing

        public boolean isInRing()
        Access whether this atom has been flagged as in a ring. The default value is false and you must explicitly find rings first.
        Specified by:
        isInRing in interface IAtom
        Returns:
        ring status
        See Also:
        IChemObject.getFlag(int), RingSearch
      • getMapIdx

        public int getMapIdx()
        Description copied from interface: IAtom
        Access the map index for this atom.
        Specified by:
        getMapIdx in interface IAtom
        Returns:
        the map index (0 if not set)
      • setMapIdx

        public void setMapIdx​(int mapidx)
        Description copied from interface: IAtom
        Set the map index for this atom.
        Specified by:
        setMapIdx in interface IAtom
        Parameters:
        mapidx - the new map index
      • toString

        public String toString()
        Returns a one line string representation of this Atom. Methods is conform RFC #9.
        Specified by:
        toString in interface IChemObject
        Overrides:
        toString in class AtomType
        Returns:
        The string representation of this Atom
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object