Package org.openscience.cdk.silent
Class Atom
- java.lang.Object
-
- org.openscience.cdk.silent.ChemObject
-
- org.openscience.cdk.silent.Element
-
- org.openscience.cdk.silent.Isotope
-
- org.openscience.cdk.silent.AtomType
-
- org.openscience.cdk.silent.Atom
-
- All Implemented Interfaces:
Serializable
,Cloneable
,IAtom
,IAtomType
,ICDKObject
,IChemObject
,IElement
,IIsotope
- Direct Known Subclasses:
PDBAtom
,PseudoAtom
public class Atom extends AtomType implements IAtom, Serializable, Cloneable
Represents the idea of an chemical atom.An Atom class is instantiated with at least the atom symbol:
Atom a = new Atom("C");
Once instantiated all field not filled by passing parameters to the constructor are null. Atoms can be configured by using the IsotopeFactory.configure() method:
IsotopeFactory if = IsotopeFactory.getInstance(a.getNewBuilder()); if.configure(a);
More examples about using this class can be found in the Junit test for this class.
- Author:
- steinbeck
- See Also:
XMLIsotopeFactory.getInstance(org.openscience.cdk.interfaces.IChemObjectBuilder)
, Serialized Form- Source code:
- main
- Belongs to CDK module:
- silent
- Keywords:
- atom
- Created on:
- 2000-10-02
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.openscience.cdk.interfaces.IAtomType
IAtomType.Hybridization
-
-
Field Summary
Fields Modifier and Type Field Description protected Double
charge
The partial charge of the atom.protected javax.vecmath.Point3d
fractionalPoint3d
A 3 point specifying the location of this atom in a crystal unit cell.protected Integer
hydrogenCount
The number of implicitly bound hydrogen atoms for this atom.protected javax.vecmath.Point2d
point2d
A 2D point specifying the location of this atom in a 2D coordinate space.protected javax.vecmath.Point3d
point3d
A 3 point specifying the location of this atom in a 3D coordinate space.protected Integer
stereoParity
A stereo parity descriptor for the stereochemistry of this atom.-
Fields inherited from class org.openscience.cdk.silent.AtomType
electronValency, formalCharge, formalNeighbourCount, hybridization
-
Fields inherited from class org.openscience.cdk.silent.Isotope
exactMass, naturalAbundance
-
Fields inherited from class org.openscience.cdk.silent.Element
atomicNumber
-
Fields inherited from interface org.openscience.cdk.interfaces.IChemObject
ALIPHATIC, AROMATIC, CONJUGATED, HYDROGEN_BOND_ACCEPTOR, HYDROGEN_BOND_DONOR, IN_RING, MAPPED, NOT_IN_RING, PLACED, REACTIVE_CENTER, SINGLE_OR_DOUBLE, TYPEABLE, VISITED
-
Fields inherited from interface org.openscience.cdk.interfaces.IElement
Ac, Ag, Al, Am, Ar, As, At, Au, B, Ba, Be, Bh, Bi, Bk, Br, C, Ca, Cd, Ce, Cf, Cl, Cm, Cn, Co, Cr, Cs, Cu, Db, Ds, Dy, Er, Es, Eu, F, Fe, Fl, Fm, Fr, Ga, Gd, Ge, H, He, Hf, Hg, Ho, Hs, I, In, Ir, K, Kr, La, Li, Lr, Lu, Lv, Mc, Md, Mg, Mn, Mo, Mt, N, Na, Nb, Nd, Ne, Nh, Ni, No, Np, O, Og, Os, P, Pa, Pb, Pd, Pm, Po, Pr, Pt, Pu, Ra, Rb, Re, Rf, Rg, Rh, Rn, Ru, S, Sb, Sc, Se, Sg, Si, Sm, Sn, Sr, Ta, Tb, Tc, Te, Th, Ti, Tl, Tm, Ts, U, V, W, Wildcard, Xe, Y, Yb, Zn, Zr
-
-
Constructor Summary
Constructors Constructor Description Atom()
Constructs an completely unset Atom.Atom(int elem)
Create a new atom with of the specified element.Atom(int elem, int hcnt)
Create a new atom with of the specified element and hydrogen count.Atom(int elem, int hcnt, int fchg)
Create a new atom with of the specified element, hydrogen count, and formal charge.Atom(String symbol)
Constructs an Atom from a string containing an element symbol and optionally the atomic mass, hydrogen count, and formal charge.Atom(String elementSymbol, javax.vecmath.Point2d point2d)
Constructs an Atom from an Element and a Point2d.Atom(String elementSymbol, javax.vecmath.Point3d point3d)
Constructs an Atom from an Element and a Point3d.Atom(IAtom org)
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.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Iterable<IBond>
bonds()
Returns the bonds connected to this atom.IAtom
clone()
Clones this atom object and its content.boolean
compare(Object object)
Compares a atom with this atom.boolean
equals(Object obj)
IBond
getBond(IAtom atom)
Returns the bond connecting 'this' atom to the provided atom.int
getBondCount()
Get the number of explicit bonds connected to this atom.Double
getCharge()
Returns the partial charge of this atom.IAtomContainer
getContainer()
Access theIAtomContainer
of which this atom is a member of.javax.vecmath.Point3d
getFractionalPoint3d()
Returns a point specifying the location of this atom in a Crystal unit cell.Integer
getImplicitHydrogenCount()
Returns the hydrogen count of this atom.int
getIndex()
Acces the index of an atom in the context of anIAtomContainer
.int
getMapIdx()
Access the map index for this atom.javax.vecmath.Point2d
getPoint2d()
Returns a point specifying the location of this atom in a 2D space.javax.vecmath.Point3d
getPoint3d()
Returns a point specifying the location of this atom in a 3D space.Integer
getStereoParity()
Returns the stereo parity of this atom.int
hashCode()
void
setCharge(Double charge)
Sets the partial charge of this atom.void
setFractionalPoint3d(javax.vecmath.Point3d point3d)
Sets a point specifying the location of this atom in a Crystal unit cell.void
setImplicitHydrogenCount(Integer hydrogenCount)
Sets the number of implicit hydrogen count of this atom.void
setMapIdx(int mapidx)
Set the map index for this atom.void
setPoint2d(javax.vecmath.Point2d point2d)
Sets a point specifying the location of this atom in a 2D space.void
setPoint3d(javax.vecmath.Point3d point3d)
Sets a point specifying the location of this atom in 3D space.void
setStereoParity(Integer stereoParity)
Sets the stereo parity for this atom.String
toString()
Returns a one line string representation of this Atom.-
Methods inherited from class org.openscience.cdk.silent.AtomType
getAtomTypeName, getBondOrderSum, getCovalentRadius, getFormalCharge, getFormalNeighbourCount, getHybridization, getMaxBondOrder, getValency, setAtomTypeName, setBondOrderSum, setCovalentRadius, setFormalCharge, setFormalNeighbourCount, setHybridization, setMaxBondOrder, setValency
-
Methods inherited from class org.openscience.cdk.silent.Isotope
getExactMass, getMassNumber, getNaturalAbundance, setExactMass, setMassNumber, setNaturalAbundance
-
Methods inherited from class org.openscience.cdk.silent.Element
getAtomicNumber, getSymbol, setAtomicNumber, setSymbol
-
Methods inherited from class org.openscience.cdk.silent.ChemObject
addListener, addProperties, clear, flags, getBuilder, getFlag, getFlags, getFlagValue, getID, getListenerCount, getNotification, getProperties, getProperty, getProperty, is, notifyChanged, notifyChanged, removeListener, removeProperty, set, setFlag, setFlags, setID, setNotification, setProperties, setProperty, shallowCopy
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.openscience.cdk.interfaces.IAtom
getTotalHydrogenCount, isAromatic, isInRing, neighbors, setIsAromatic, setIsInRing
-
Methods inherited from interface org.openscience.cdk.interfaces.IAtomType
getAtomTypeName, getBondOrderSum, getCovalentRadius, getFormalCharge, getFormalNeighbourCount, getHybridization, getMaxBondOrder, getValency, setAtomTypeName, setBondOrderSum, setCovalentRadius, setFormalCharge, setFormalNeighbourCount, setHybridization, setMaxBondOrder, setValency
-
Methods inherited from interface org.openscience.cdk.interfaces.ICDKObject
getBuilder
-
Methods inherited from interface org.openscience.cdk.interfaces.IChemObject
addListener, addProperties, clear, flags, getFlag, getFlags, getFlagValue, getID, getListenerCount, getNotification, getProperties, getProperty, getProperty, is, notifyChanged, notifyChanged, removeListener, removeProperty, set, setFlag, setFlags, setID, setNotification, setProperties, setProperty
-
Methods inherited from interface org.openscience.cdk.interfaces.IElement
getAtomicNumber, getSymbol, setAtomicNumber, setSymbol
-
Methods inherited from interface org.openscience.cdk.interfaces.IIsotope
getExactMass, getMassNumber, getNaturalAbundance, setExactMass, setMassNumber, setNaturalAbundance
-
-
-
-
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 isCDKConstants.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 numberhcnt
- 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 numberhcnt
- hydrogen countfchg
- 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 atompoint3d
- 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 Elementpoint2d
- 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
-
Atom
public Atom(IAtom org)
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:
org
- IAtomType to copy information from
-
-
Method Detail
-
getContainer
public IAtomContainer getContainer()
Access theIAtomContainer
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 anIAtomContainer
, 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 interfaceIAtom
- 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 anIAtomContainer
. If the index is not known, < 0 is returned.
-
getBondCount
public int getBondCount()
Get the number of explicit bonds connected to this atom.- Specified by:
getBondCount
in interfaceIAtom
- Returns:
- the total bond count
-
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 ifIAtom.getIndex()
returns < 0 orIAtom.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()) { }
-
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.
-
setCharge
public void setCharge(Double charge)
Sets the partial charge of this atom.- Specified by:
setCharge
in interfaceIAtom
- 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 interfaceIAtom
- 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 interfaceIAtom
- Parameters:
hydrogenCount
- The number of hydrogen atoms bonded to this atom.- See Also:
getImplicitHydrogenCount()
-
getImplicitHydrogenCount
public Integer getImplicitHydrogenCount()
Returns the hydrogen count of this atom.- Specified by:
getImplicitHydrogenCount
in interfaceIAtom
- Returns:
- The hydrogen count of this atom.
- See Also:
setImplicitHydrogenCount(java.lang.Integer)
-
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 interfaceIAtom
- 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 interfaceIAtom
- 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 interfaceIAtom
- Parameters:
point3d
- A point in a 3d fractional unit cell space- See Also:
getFractionalPoint3d()
,Crystal
-
setStereoParity
public void setStereoParity(Integer stereoParity)
Sets the stereo parity for this atom.- Specified by:
setStereoParity
in interfaceIAtom
- Parameters:
stereoParity
- The stereo parity for this atom- See Also:
for predefined values.
,getStereoParity()
-
getPoint2d
public javax.vecmath.Point2d getPoint2d()
Returns a point specifying the location of this atom in a 2D space.- Specified by:
getPoint2d
in interfaceIAtom
- 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 interfaceIAtom
- Returns:
- A point in 3-dimensional space. Null if unset.
- See Also:
setPoint3d(javax.vecmath.Point3d)
-
getFractionalPoint3d
public javax.vecmath.Point3d getFractionalPoint3d()
Returns a point specifying the location of this atom in a Crystal unit cell.- Specified by:
getFractionalPoint3d
in interfaceIAtom
- Returns:
- A point in 3d fractional unit cell space. Null if unset.
- See Also:
setFractionalPoint3d(javax.vecmath.Point3d)
,for predefined values.
-
getStereoParity
public Integer getStereoParity()
Returns the stereo parity of this atom. It uses the predefined values found in CDKConstants.- Specified by:
getStereoParity
in interfaceIAtom
- Returns:
- The stereo parity for this atom
- See Also:
CDKConstants
,setStereoParity(java.lang.Integer)
-
compare
public boolean compare(Object object)
Compares a atom with this atom.
-
toString
public String toString()
Returns a one line string representation of this Atom. Methods is conform RFC #9.- Specified by:
toString
in interfaceIChemObject
- Overrides:
toString
in classAtomType
- Returns:
- The string representation of this Atom
-
getMapIdx
public int getMapIdx()
Description copied from interface:IAtom
Access the map index for this atom.
-
setMapIdx
public void setMapIdx(int mapidx)
Description copied from interface:IAtom
Set the map index for this atom.
-
clone
public IAtom clone() throws CloneNotSupportedException
Clones this atom object and its content.- Specified by:
clone
in interfaceIAtom
- Specified by:
clone
in interfaceIChemObject
- Overrides:
clone
in classAtomType
- Returns:
- The cloned object
- Throws:
CloneNotSupportedException
- if the IChemObject cannot be cloned
-
-