public class AtomContainer extends ChemObject implements IAtomContainer, IChemObjectListener, Serializable, Cloneable
Looping over all Bonds in the AtomContainer is typically done like:
Iterator iter = atomContainer.bonds();
while (iter.hasNext()) {
IBond aBond = (IBond) iter.next();
}
| Modifier and Type | Field and Description |
|---|---|
protected int |
atomCount
Number of atoms contained by this object.
|
protected IAtom[] |
atoms
Internal array of atoms.
|
protected int |
bondCount
Number of bonds contained by this object.
|
protected IBond[] |
bonds
Internal array of bonds.
|
protected int |
growArraySize
Amount by which the bond and atom arrays grow when elements are added and
the arrays are not large enough for that.
|
protected int |
lonePairCount
Number of lone pairs contained by this object.
|
protected ILonePair[] |
lonePairs
Internal array of lone pairs.
|
protected int |
singleElectronCount
Number of single electrons contained by this object.
|
protected ISingleElectron[] |
singleElectrons
Internal array of single electrons.
|
protected Set<IStereoElement> |
stereoElements
Internal list of atom parities.
|
| Constructor and Description |
|---|
AtomContainer()
Constructs an empty AtomContainer.
|
AtomContainer(IAtomContainer container)
Constructs an AtomContainer with a copy of the atoms and electronContainers
of another AtomContainer (A shallow copy, i.e., with the same objects as in
the original AtomContainer).
|
AtomContainer(int atomCount,
int bondCount,
int lpCount,
int seCount)
Constructs an empty AtomContainer that will contain a certain number of
atoms and electronContainers.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(IAtomContainer that)
Adds all atoms and electronContainers of a given atomcontainer to this
container.
|
void |
addAtom(IAtom atom)
Adds an atom to this container.
|
void |
addBond(IBond bond)
Adds a Bond to this AtomContainer.
|
void |
addBond(int atom1,
int atom2,
IBond.Order order)
Adds a bond to this container.
|
void |
addBond(int atom1,
int atom2,
IBond.Order order,
IBond.Stereo stereo)
Adds a bond to this container.
|
void |
addElectronContainer(IElectronContainer electronContainer)
Adds a ElectronContainer to this AtomContainer.
|
void |
addLonePair(ILonePair lonePair)
Adds a lone pair to this AtomContainer.
|
void |
addLonePair(int atomID)
Adds a LonePair to this Atom.
|
void |
addSingleElectron(int atomID)
Adds a SingleElectron to this Atom.
|
void |
addSingleElectron(ISingleElectron singleElectron)
Adds a single electron to this AtomContainer.
|
void |
addStereoElement(IStereoElement element)
Adds a stereo element to this container.
|
Iterable<IAtom> |
atoms()
Returns an Iterable for looping over all atoms in this container.
|
Iterable<IBond> |
bonds()
Returns an Iterable for looping over all bonds in this container.
|
IAtomContainer |
clone()
Clones this
IChemObject. |
boolean |
contains(IAtom atom)
True, if the AtomContainer contains the given atom object.
|
boolean |
contains(IBond bond)
True, if the AtomContainer contains the given bond object.
|
boolean |
contains(IElectronContainer electronContainer)
True, if the AtomContainer contains the given ElectronContainer object.
|
boolean |
contains(ILonePair lonePair)
True, if the AtomContainer contains the given LonePair object.
|
boolean |
contains(ISingleElectron singleElectron)
True, if the AtomContainer contains the given SingleElectron object.
|
Iterable<IElectronContainer> |
electronContainers()
Returns an Iterable for looping over all electron containers in this container.
|
IAtom |
getAtom(int idx)
Get the atom at the specified idx, the index should be in the
range 0 ≤ idx <
IAtomContainer.getAtomCount(). |
int |
getAtomCount()
Returns the number of Atoms in this Container.
|
int |
getAtomNumber(IAtom atom)
Returns the position of a given atom in the atoms array.
|
IBond |
getBond(IAtom atom1,
IAtom atom2)
Returns the bond that connects the two given atoms.
|
IBond |
getBond(int idx)
Get the bond at the specified idx, the index should be in the
range 0 ≤ idx <
IAtomContainer.getBondCount(). |
int |
getBondCount()
Returns the number of Bonds in this Container.
|
int |
getBondNumber(IAtom atom1,
IAtom atom2)
Returns the position of the bond between two given atoms in the
electronContainers array.
|
int |
getBondNumber(IBond bond)
Returns the position of a given bond in the electronContainers array.
|
double |
getBondOrderSum(IAtom atom)
Returns the sum of the bond orders for a given Atom.
|
int |
getConnectedAtomsCount(IAtom atom)
Returns the number of connected atoms (explicit degree) to the
specified atom.
|
List<IAtom> |
getConnectedAtomsList(IAtom atom)
Returns the atoms connected connected to the specified atom by
a bond.
|
int |
getConnectedBondsCount(IAtom atom)
Returns the number of connected bonds (explicit degree) to the
specified atom.
|
int |
getConnectedBondsCount(int idx)
Returns the number of connected bonds (explicit degree) to atom
at the specified index.
|
List<IBond> |
getConnectedBondsList(IAtom atom)
Returns the bonds connected connected to the specified atom.
|
List<IElectronContainer> |
getConnectedElectronContainersList(IAtom atom)
Returns the electron containers (bonds, radicals, and lone pairs )
connected connected to the specified atom.
|
int |
getConnectedLonePairsCount(IAtom atom)
Returns the number of lone pairs connected to the specified atom.
|
List<ILonePair> |
getConnectedLonePairsList(IAtom atom)
Returns the lone pairs connected connected to the specified atom.
|
int |
getConnectedSingleElectronsCount(IAtom atom)
Returns the number of single electrons connected to the specified atom.
|
List<ISingleElectron> |
getConnectedSingleElectronsList(IAtom atom)
Returns the single electrons connected connected to the specified atom.
|
IElectronContainer |
getElectronContainer(int number)
Returns the ElectronContainer at position
number in the
container. |
int |
getElectronContainerCount()
Returns the number of ElectronContainers in this Container.
|
IAtom |
getFirstAtom()
Returns the atom at position 0 in the container.
|
IAtom |
getLastAtom()
Returns the atom at the last position in the container.
|
ILonePair |
getLonePair(int idx)
Get the lone pair at the specified idx, the index should be in the
range 0 ≤ idx <
IAtomContainer.getLonePairCount(). |
int |
getLonePairCount()
Returns the number of LonePairs in this Container.
|
int |
getLonePairNumber(ILonePair lonePair)
Returns the position of a given lone pair in the lone pair array.
|
IBond.Order |
getMaximumBondOrder(IAtom atom)
Returns the maximum bond order that this atom currently has in the context
of this AtomContainer.
|
IBond.Order |
getMinimumBondOrder(IAtom atom)
Returns the minimum bond order that this atom currently has
in the context of this AtomContainer.
|
ISingleElectron |
getSingleElectron(int idx)
Get the single electron at the specified idx, the index should
be in the range 0 ≤ idx <
IAtomContainer.getSingleElectronCount(). |
int |
getSingleElectronCount()
Returns the number of the single electrons in this container.
|
int |
getSingleElectronNumber(ISingleElectron singleElectron)
Returns the position of a given single electron in the single electron array.
|
String |
getTitle()
Access the title of the record.
|
int |
indexOf(IAtom atom)
Access the storage index of an atom.
|
int |
indexOf(IBond bond)
Access the storage index of a bond.
|
int |
indexOf(ILonePair pair)
Access the storage index of a long pair.
|
int |
indexOf(ISingleElectron electron)
Access the storage index of a single electron (radical).
|
boolean |
isEmpty()
Indicates whether this container is empty.
|
Iterable<ILonePair> |
lonePairs()
Returns an Iterable for looping over all lone pairs in this container.
|
void |
remove(IAtomContainer atomContainer)
Removes all atoms and electronContainers of a given atomcontainer from this
container.
|
void |
removeAllBonds()
Removes all Bonds from this container.
|
void |
removeAllElectronContainers()
Removes electronContainers from this container.
|
void |
removeAllElements()
Removes all atoms, bonds and stereo elements from this container.
|
void |
removeAtom(IAtom atom)
Safely remove an atom from the container.
|
void |
removeAtom(int pos)
Safely remove an atom from the container.
|
void |
removeAtomAndConnectedElectronContainers(IAtom atom)
Deprecated.
|
void |
removeAtomOnly(IAtom atom)
Unsafely remove atom.
|
void |
removeAtomOnly(int position)
Unsafely remove atom at index.
|
IBond |
removeBond(IAtom atom1,
IAtom atom2)
Removes the bond that connects the two given atoms.
|
void |
removeBond(IBond bond)
Removes the bond from this container.
|
IBond |
removeBond(int position)
Removes the bond at the given position from the AtomContainer.
|
void |
removeElectronContainer(IElectronContainer electronContainer)
Removes this ElectronContainer from this container.
|
IElectronContainer |
removeElectronContainer(int number)
Removes the bond at the given position from this container.
|
void |
removeLonePair(ILonePair lonePair)
Removes the lone pair from the AtomContainer.
|
ILonePair |
removeLonePair(int position)
Removes the lone pair at the given position from the AtomContainer.
|
ISingleElectron |
removeSingleElectron(int position)
Removes the single electron at the given position from the AtomContainer.
|
void |
removeSingleElectron(ISingleElectron singleElectron)
Removes the single electron from the AtomContainer.
|
void |
setAtom(int idx,
IAtom atom)
Set the atom at
idx, the index must have an existing atom
and therefore be in the range 0 ≤ idx < mol.getAtomCount(). |
void |
setAtoms(IAtom[] newAtoms)
Sets the array of atoms of this AtomContainer.
|
void |
setBonds(IBond[] newBonds)
Sets the array of bonds of this AtomContainer.
|
void |
setStereoElements(List<IStereoElement> elements)
Set the stereo elements - this will replace the existing instance
with a new instance.
|
void |
setTitle(String title)
Modify the title of the record.
|
Iterable<ISingleElectron> |
singleElectrons()
Returns an Iterable for looping over all single electrons in this container.
|
void |
stateChanged(IChemObjectChangeEvent event)
Called by objects to notify objects that implemented this interface
and registered with them as ChemObjectListeners.
|
Iterable<IStereoElement> |
stereoElements()
Returns the stereo elements defined for this atom container.
|
String |
toString()
Returns a one line description of this IChemObject.
|
addListener, addProperties, compare, getBuilder, getFlag, getFlags, getFlagValue, getID, getListenerCount, getNotification, getProperties, getProperty, getProperty, notifyChanged, notifyChanged, removeListener, removeProperty, setFlag, setFlags, setID, setNotification, setProperties, setProperty, shallowCopyequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddListener, addProperties, getFlag, getFlags, getFlagValue, getID, getListenerCount, getNotification, getProperties, getProperty, getProperty, notifyChanged, notifyChanged, removeListener, removeProperty, setFlag, setFlags, setID, setNotification, setProperties, setPropertygetBuilderprotected int atomCount
protected int bondCount
protected int lonePairCount
protected int singleElectronCount
protected int growArraySize
protected IAtom[] atoms
protected IBond[] bonds
protected ILonePair[] lonePairs
protected ISingleElectron[] singleElectrons
protected Set<IStereoElement> stereoElements
public AtomContainer()
public AtomContainer(IAtomContainer container)
container - An AtomContainer to copy the atoms and electronContainers frompublic AtomContainer(int atomCount,
int bondCount,
int lpCount,
int seCount)
atomCount - Number of atoms to be in this containerbondCount - Number of bonds to be in this containerlpCount - Number of lone pairs to be in this containerseCount - Number of single electrons to be in this containerpublic void addStereoElement(IStereoElement element)
addStereoElement in interface IAtomContainerelement - The new IStereoElement for this containerIAtomContainer.stereoElements()public void setStereoElements(List<IStereoElement> elements)
setStereoElements in interface IAtomContainerelements - the new stereo elementspublic Iterable<IStereoElement> stereoElements()
stereoElements in interface IAtomContainerIterable of IStereoElements.IAtomContainer.addStereoElement(IStereoElement)public void setAtoms(IAtom[] newAtoms)
setAtoms in interface IAtomContainernewAtoms - The array of atoms to be assigned to this AtomContainerIAtomContainer.atoms()public void setBonds(IBond[] newBonds)
setBonds in interface IAtomContainernewBonds - The array of bonds to be assigned to
this AtomContainerIAtomContainer.bonds()public void setAtom(int idx,
IAtom atom)
idx, the index must have an existing atom
and therefore be in the range 0 ≤ idx < mol.getAtomCount().setAtom in interface IAtomContaineridx - The index of the atom to be set.atom - The atom to be stored at position idxIAtomContainer.getAtom(int)public IAtom getAtom(int idx)
IAtomContainer.getAtomCount().getAtom in interface IAtomContaineridx - atom indexIAtomContainer.setAtom(int, org.openscience.cdk.interfaces.IAtom)public IBond getBond(int idx)
IAtomContainer.getBondCount().getBond in interface IAtomContaineridx - bond indexpublic ILonePair getLonePair(int idx)
IAtomContainer.getLonePairCount().getLonePair in interface IAtomContaineridx - lone pair indexpublic ISingleElectron getSingleElectron(int idx)
IAtomContainer.getSingleElectronCount().getSingleElectron in interface IAtomContaineridx - single electron indexpublic Iterable<IAtom> atoms()
atoms in interface IAtomContainerpublic Iterable<IBond> bonds()
bonds in interface IAtomContainerpublic Iterable<ILonePair> lonePairs()
lonePairs in interface IAtomContainerpublic Iterable<ISingleElectron> singleElectrons()
singleElectrons in interface IAtomContainerpublic Iterable<IElectronContainer> electronContainers()
electronContainers in interface IAtomContainerpublic IAtom getFirstAtom()
getFirstAtom in interface IAtomContainerpublic IAtom getLastAtom()
getLastAtom in interface IAtomContainerpublic int getAtomNumber(IAtom atom)
getAtomNumber in interface IAtomContaineratom - The atom to be soughtpublic int getBondNumber(IAtom atom1, IAtom atom2)
getBondNumber in interface IAtomContaineratom1 - The first atomatom2 - The second atompublic int getBondNumber(IBond bond)
getBondNumber in interface IAtomContainerbond - The bond to be soughtpublic int getLonePairNumber(ILonePair lonePair)
getLonePairNumber in interface IAtomContainerlonePair - The lone pair to be soughtpublic int getSingleElectronNumber(ISingleElectron singleElectron)
getSingleElectronNumber in interface IAtomContainersingleElectron - The single electron to be soughtpublic int indexOf(IAtom atom)
indexOf in interface IAtomContaineratom - atom instance to findpublic int indexOf(IBond bond)
indexOf in interface IAtomContainerbond - bond instance to findpublic int indexOf(ISingleElectron electron)
indexOf in interface IAtomContainerelectron - the electronpublic int indexOf(ILonePair pair)
indexOf in interface IAtomContainerpair - the long pairpublic IElectronContainer getElectronContainer(int number)
number in the
container.getElectronContainer in interface IAtomContainernumber - The position of the ElectronContainer to be returned.number.IAtomContainer.addElectronContainer(IElectronContainer)public IBond getBond(IAtom atom1, IAtom atom2)
getBond in interface IAtomContaineratom1 - The first atomatom2 - The second atompublic int getAtomCount()
getAtomCount in interface IAtomContainerpublic int getBondCount()
getBondCount in interface IAtomContainerpublic int getLonePairCount()
getLonePairCount in interface IAtomContainerpublic int getSingleElectronCount()
getSingleElectronCount in interface IAtomContainerpublic int getElectronContainerCount()
getElectronContainerCount in interface IAtomContainerpublic List<IAtom> getConnectedAtomsList(IAtom atom)
getConnectedAtomsList in interface IAtomContaineratom - the atompublic List<IBond> getConnectedBondsList(IAtom atom)
getConnectedBondsList in interface IAtomContaineratom - the atompublic List<ILonePair> getConnectedLonePairsList(IAtom atom)
getConnectedLonePairsList in interface IAtomContaineratom - the atompublic List<ISingleElectron> getConnectedSingleElectronsList(IAtom atom)
getConnectedSingleElectronsList in interface IAtomContaineratom - the atompublic List<IElectronContainer> getConnectedElectronContainersList(IAtom atom)
getConnectedElectronContainersList in interface IAtomContaineratom - the atompublic int getConnectedBondsCount(IAtom atom)
getConnectedBondsCount in interface IAtomContaineratom - the atompublic int getConnectedAtomsCount(IAtom atom)
getConnectedAtomsCount in interface IAtomContaineratom - the atompublic int getConnectedBondsCount(int idx)
getConnectedBondsCount in interface IAtomContaineridx - the atom idxpublic int getConnectedLonePairsCount(IAtom atom)
getConnectedLonePairsCount in interface IAtomContaineratom - the atompublic int getConnectedSingleElectronsCount(IAtom atom)
getConnectedSingleElectronsCount in interface IAtomContaineratom - the atompublic double getBondOrderSum(IAtom atom)
getBondOrderSum in interface IAtomContaineratom - The atompublic IBond.Order getMaximumBondOrder(IAtom atom)
IBond.Order.SINGLE, otherwise the bond is unset
IBond.Order.UNSET.getMaximumBondOrder in interface IAtomContaineratom - The atompublic IBond.Order getMinimumBondOrder(IAtom atom)
IBond.Order.SINGLE, otherwise the bond is unset
IBond.Order.UNSET.getMinimumBondOrder in interface IAtomContaineratom - The atompublic void add(IAtomContainer that)
add in interface IAtomContainerthat - The atomcontainer to be addedpublic void addAtom(IAtom atom)
addAtom in interface IAtomContaineratom - The atom to be added to this containerpublic void addBond(IBond bond)
addBond in interface IAtomContainerbond - The bond to added to this containerpublic void addLonePair(ILonePair lonePair)
addLonePair in interface IAtomContainerlonePair - The LonePair to added to this containerpublic void addSingleElectron(ISingleElectron singleElectron)
addSingleElectron in interface IAtomContainersingleElectron - The SingleElectron to added to this containerpublic void addElectronContainer(IElectronContainer electronContainer)
addElectronContainer in interface IAtomContainerelectronContainer - The ElectronContainer to added to this containerpublic void remove(IAtomContainer atomContainer)
remove in interface IAtomContaineratomContainer - The atomcontainer to be removedpublic void removeAtomOnly(int position)
removeAtomOnly in interface IAtomContainerposition - The position of the atom to be removed.public void removeAtomOnly(IAtom atom)
removeAtomOnly in interface IAtomContaineratom - The atom to be removedpublic IBond removeBond(int position)
removeBond in interface IAtomContainerposition - The position of the bond to be removed.public IBond removeBond(IAtom atom1, IAtom atom2)
removeBond in interface IAtomContaineratom1 - The first atomatom2 - The second atompublic void removeBond(IBond bond)
removeBond in interface IAtomContainerbond - The bond to be removed.public ILonePair removeLonePair(int position)
removeLonePair in interface IAtomContainerposition - The position of the LonePair to be removed.public void removeLonePair(ILonePair lonePair)
removeLonePair in interface IAtomContainerlonePair - The LonePair to be removed.public ISingleElectron removeSingleElectron(int position)
removeSingleElectron in interface IAtomContainerposition - The position of the SingleElectron to be removed.public void removeSingleElectron(ISingleElectron singleElectron)
removeSingleElectron in interface IAtomContainersingleElectron - The SingleElectron to be removed.public IElectronContainer removeElectronContainer(int number)
removeElectronContainer in interface IAtomContainernumber - The position of the bond in the electronContainers arraypublic void removeElectronContainer(IElectronContainer electronContainer)
removeElectronContainer in interface IAtomContainerelectronContainer - The electronContainer to be removed@Deprecated public void removeAtomAndConnectedElectronContainers(IAtom atom)
removeAtomAndConnectedElectronContainers in interface IAtomContainerIAtomContainer.removeAtom(IAtom)public void removeAtom(IAtom atom)
IAtomContainer.remove(IAtomContainer).
removeAtom in interface IAtomContaineratom - the atom to be removedpublic void removeAtom(int pos)
IAtomContainer.remove(IAtomContainer).
removeAtom in interface IAtomContainerpos - the position of the atom to be removedpublic void removeAllElements()
removeAllElements in interface IAtomContainerpublic void removeAllElectronContainers()
removeAllElectronContainers in interface IAtomContainerpublic void removeAllBonds()
removeAllBonds in interface IAtomContainerpublic void addBond(int atom1,
int atom2,
IBond.Order order,
IBond.Stereo stereo)
addBond in interface IAtomContaineratom1 - Id of the first atom of the Bond in [0,..]atom2 - Id of the second atom of the Bond in [0,..]order - Bondorderstereo - Stereochemical orientationpublic void addBond(int atom1,
int atom2,
IBond.Order order)
addBond in interface IAtomContaineratom1 - Id of the first atom of the Bond in [0,..]atom2 - Id of the second atom of the Bond in [0,..]order - Bondorderpublic void addLonePair(int atomID)
addLonePair in interface IAtomContaineratomID - The atom number to which the LonePair is added in [0,..]public void addSingleElectron(int atomID)
addSingleElectron in interface IAtomContaineratomID - The atom number to which the SingleElectron is added in [0,..]public boolean contains(IAtom atom)
contains in interface IAtomContaineratom - the atom this AtomContainer is searched forpublic boolean contains(IBond bond)
contains in interface IAtomContainerbond - the bond this AtomContainer is searched forpublic boolean contains(ILonePair lonePair)
contains in interface IAtomContainerlonePair - the LonePair this AtomContainer is searched forpublic boolean contains(ISingleElectron singleElectron)
contains in interface IAtomContainersingleElectron - the SingleElectron this AtomContainer is searched forpublic boolean contains(IElectronContainer electronContainer)
contains in interface IAtomContainerelectronContainer - ElectronContainer that is searched forpublic String toString()
toString in interface IChemObjecttoString in class Objectpublic IAtomContainer clone() throws CloneNotSupportedException
IChemObject. It clones the identifier, flags,
properties and pointer vectors. The ChemObjectListeners are not cloned, and
neither is the content of the pointer vectors.clone in interface IAtomContainerclone in interface IChemObjectclone in class ChemObjectCloneNotSupportedException - if the IChemObject cannot be clonedpublic void stateChanged(IChemObjectChangeEvent event)
stateChanged in interface IChemObjectListenerevent - a ChemObjectChangeEvent objectpublic boolean isEmpty()
isEmpty in interface IAtomContainerpublic String getTitle()
getTitle in interface IAtomContainerpublic void setTitle(String title)
setTitle in interface IAtomContainertitle - the titleCopyright © 2021. All rights reserved.