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, shallowCopy
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addListener, addProperties, getFlag, getFlags, getFlagValue, getID, getListenerCount, getNotification, getProperties, getProperty, getProperty, notifyChanged, notifyChanged, removeListener, removeProperty, setFlag, setFlags, setID, setNotification, setProperties, setProperty
getBuilder
protected 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 IAtomContainer
element
- The new IStereoElement
for this containerIAtomContainer.stereoElements()
public void setStereoElements(List<IStereoElement> elements)
setStereoElements
in interface IAtomContainer
elements
- the new stereo elementspublic Iterable<IStereoElement> stereoElements()
stereoElements
in interface IAtomContainer
Iterable
of IStereoElement
s.IAtomContainer.addStereoElement(IStereoElement)
public void setAtoms(IAtom[] newAtoms)
setAtoms
in interface IAtomContainer
newAtoms
- The array of atoms to be assigned to this AtomContainerIAtomContainer.atoms()
public void setBonds(IBond[] newBonds)
setBonds
in interface IAtomContainer
newBonds
- 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 IAtomContainer
idx
- The index of the atom to be set.atom
- The atom to be stored at position idx
IAtomContainer.getAtom(int)
public IAtom getAtom(int idx)
IAtomContainer.getAtomCount()
.getAtom
in interface IAtomContainer
idx
- atom indexIAtomContainer.setAtom(int, org.openscience.cdk.interfaces.IAtom)
public IBond getBond(int idx)
IAtomContainer.getBondCount()
.getBond
in interface IAtomContainer
idx
- bond indexpublic ILonePair getLonePair(int idx)
IAtomContainer.getLonePairCount()
.getLonePair
in interface IAtomContainer
idx
- lone pair indexpublic ISingleElectron getSingleElectron(int idx)
IAtomContainer.getSingleElectronCount()
.getSingleElectron
in interface IAtomContainer
idx
- single electron indexpublic Iterable<IAtom> atoms()
atoms
in interface IAtomContainer
public Iterable<IBond> bonds()
bonds
in interface IAtomContainer
public Iterable<ILonePair> lonePairs()
lonePairs
in interface IAtomContainer
public Iterable<ISingleElectron> singleElectrons()
singleElectrons
in interface IAtomContainer
public Iterable<IElectronContainer> electronContainers()
electronContainers
in interface IAtomContainer
public IAtom getFirstAtom()
getFirstAtom
in interface IAtomContainer
public IAtom getLastAtom()
getLastAtom
in interface IAtomContainer
public int getAtomNumber(IAtom atom)
getAtomNumber
in interface IAtomContainer
atom
- The atom to be soughtpublic int getBondNumber(IAtom atom1, IAtom atom2)
getBondNumber
in interface IAtomContainer
atom1
- The first atomatom2
- The second atompublic int getBondNumber(IBond bond)
getBondNumber
in interface IAtomContainer
bond
- The bond to be soughtpublic int getLonePairNumber(ILonePair lonePair)
getLonePairNumber
in interface IAtomContainer
lonePair
- The lone pair to be soughtpublic int getSingleElectronNumber(ISingleElectron singleElectron)
getSingleElectronNumber
in interface IAtomContainer
singleElectron
- The single electron to be soughtpublic int indexOf(IAtom atom)
indexOf
in interface IAtomContainer
atom
- atom instance to findpublic int indexOf(IBond bond)
indexOf
in interface IAtomContainer
bond
- bond instance to findpublic int indexOf(ISingleElectron electron)
indexOf
in interface IAtomContainer
electron
- the electronpublic int indexOf(ILonePair pair)
indexOf
in interface IAtomContainer
pair
- the long pairpublic IElectronContainer getElectronContainer(int number)
number
in the
container.getElectronContainer
in interface IAtomContainer
number
- The position of the ElectronContainer to be returned.number
.IAtomContainer.addElectronContainer(IElectronContainer)
public IBond getBond(IAtom atom1, IAtom atom2)
getBond
in interface IAtomContainer
atom1
- The first atomatom2
- The second atompublic int getAtomCount()
getAtomCount
in interface IAtomContainer
public int getBondCount()
getBondCount
in interface IAtomContainer
public int getLonePairCount()
getLonePairCount
in interface IAtomContainer
public int getSingleElectronCount()
getSingleElectronCount
in interface IAtomContainer
public int getElectronContainerCount()
getElectronContainerCount
in interface IAtomContainer
public List<IAtom> getConnectedAtomsList(IAtom atom)
getConnectedAtomsList
in interface IAtomContainer
atom
- the atompublic List<IBond> getConnectedBondsList(IAtom atom)
getConnectedBondsList
in interface IAtomContainer
atom
- the atompublic List<ILonePair> getConnectedLonePairsList(IAtom atom)
getConnectedLonePairsList
in interface IAtomContainer
atom
- the atompublic List<ISingleElectron> getConnectedSingleElectronsList(IAtom atom)
getConnectedSingleElectronsList
in interface IAtomContainer
atom
- the atompublic List<IElectronContainer> getConnectedElectronContainersList(IAtom atom)
getConnectedElectronContainersList
in interface IAtomContainer
atom
- the atompublic int getConnectedBondsCount(IAtom atom)
getConnectedBondsCount
in interface IAtomContainer
atom
- the atompublic int getConnectedAtomsCount(IAtom atom)
getConnectedAtomsCount
in interface IAtomContainer
atom
- the atompublic int getConnectedBondsCount(int idx)
getConnectedBondsCount
in interface IAtomContainer
idx
- the atom idxpublic int getConnectedLonePairsCount(IAtom atom)
getConnectedLonePairsCount
in interface IAtomContainer
atom
- the atompublic int getConnectedSingleElectronsCount(IAtom atom)
getConnectedSingleElectronsCount
in interface IAtomContainer
atom
- the atompublic double getBondOrderSum(IAtom atom)
getBondOrderSum
in interface IAtomContainer
atom
- The atompublic IBond.Order getMaximumBondOrder(IAtom atom)
IBond.Order.SINGLE
, otherwise the bond is unset
IBond.Order.UNSET
.getMaximumBondOrder
in interface IAtomContainer
atom
- The atompublic IBond.Order getMinimumBondOrder(IAtom atom)
IBond.Order.SINGLE
, otherwise the bond is unset
IBond.Order.UNSET
.getMinimumBondOrder
in interface IAtomContainer
atom
- The atompublic void add(IAtomContainer that)
add
in interface IAtomContainer
that
- The atomcontainer to be addedpublic void addAtom(IAtom atom)
addAtom
in interface IAtomContainer
atom
- The atom to be added to this containerpublic void addBond(IBond bond)
addBond
in interface IAtomContainer
bond
- The bond to added to this containerpublic void addLonePair(ILonePair lonePair)
addLonePair
in interface IAtomContainer
lonePair
- The LonePair to added to this containerpublic void addSingleElectron(ISingleElectron singleElectron)
addSingleElectron
in interface IAtomContainer
singleElectron
- The SingleElectron to added to this containerpublic void addElectronContainer(IElectronContainer electronContainer)
addElectronContainer
in interface IAtomContainer
electronContainer
- The ElectronContainer to added to this containerpublic void remove(IAtomContainer atomContainer)
remove
in interface IAtomContainer
atomContainer
- The atomcontainer to be removedpublic void removeAtomOnly(int position)
removeAtomOnly
in interface IAtomContainer
position
- The position of the atom to be removed.public void removeAtomOnly(IAtom atom)
removeAtomOnly
in interface IAtomContainer
atom
- The atom to be removedpublic IBond removeBond(int position)
removeBond
in interface IAtomContainer
position
- The position of the bond to be removed.public IBond removeBond(IAtom atom1, IAtom atom2)
removeBond
in interface IAtomContainer
atom1
- The first atomatom2
- The second atompublic void removeBond(IBond bond)
removeBond
in interface IAtomContainer
bond
- The bond to be removed.public ILonePair removeLonePair(int position)
removeLonePair
in interface IAtomContainer
position
- The position of the LonePair to be removed.public void removeLonePair(ILonePair lonePair)
removeLonePair
in interface IAtomContainer
lonePair
- The LonePair to be removed.public ISingleElectron removeSingleElectron(int position)
removeSingleElectron
in interface IAtomContainer
position
- The position of the SingleElectron to be removed.public void removeSingleElectron(ISingleElectron singleElectron)
removeSingleElectron
in interface IAtomContainer
singleElectron
- The SingleElectron to be removed.public IElectronContainer removeElectronContainer(int number)
removeElectronContainer
in interface IAtomContainer
number
- The position of the bond in the electronContainers arraypublic void removeElectronContainer(IElectronContainer electronContainer)
removeElectronContainer
in interface IAtomContainer
electronContainer
- The electronContainer to be removed@Deprecated public void removeAtomAndConnectedElectronContainers(IAtom atom)
removeAtomAndConnectedElectronContainers
in interface IAtomContainer
IAtomContainer.removeAtom(IAtom)
public void removeAtom(IAtom atom)
IAtomContainer.remove(IAtomContainer)
.
removeAtom
in interface IAtomContainer
atom
- the atom to be removedpublic void removeAtom(int pos)
IAtomContainer.remove(IAtomContainer)
.
removeAtom
in interface IAtomContainer
pos
- the position of the atom to be removedpublic void removeAllElements()
removeAllElements
in interface IAtomContainer
public void removeAllElectronContainers()
removeAllElectronContainers
in interface IAtomContainer
public void removeAllBonds()
removeAllBonds
in interface IAtomContainer
public void addBond(int atom1, int atom2, IBond.Order order, IBond.Stereo stereo)
addBond
in interface IAtomContainer
atom1
- 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 IAtomContainer
atom1
- 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 IAtomContainer
atomID
- The atom number to which the LonePair is added in [0,..]public void addSingleElectron(int atomID)
addSingleElectron
in interface IAtomContainer
atomID
- The atom number to which the SingleElectron is added in [0,..]public boolean contains(IAtom atom)
contains
in interface IAtomContainer
atom
- the atom this AtomContainer is searched forpublic boolean contains(IBond bond)
contains
in interface IAtomContainer
bond
- the bond this AtomContainer is searched forpublic boolean contains(ILonePair lonePair)
contains
in interface IAtomContainer
lonePair
- the LonePair this AtomContainer is searched forpublic boolean contains(ISingleElectron singleElectron)
contains
in interface IAtomContainer
singleElectron
- the SingleElectron this AtomContainer is searched forpublic boolean contains(IElectronContainer electronContainer)
contains
in interface IAtomContainer
electronContainer
- ElectronContainer that is searched forpublic String toString()
toString
in interface IChemObject
toString
in class Object
public 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 IAtomContainer
clone
in interface IChemObject
clone
in class ChemObject
CloneNotSupportedException
- if the IChemObject cannot be clonedpublic void stateChanged(IChemObjectChangeEvent event)
stateChanged
in interface IChemObjectListener
event
- a ChemObjectChangeEvent objectpublic boolean isEmpty()
isEmpty
in interface IAtomContainer
public String getTitle()
getTitle
in interface IAtomContainer
public void setTitle(String title)
setTitle
in interface IAtomContainer
title
- the titleCopyright © 2021. All rights reserved.