Class QueryAtomContainer
- java.lang.Object
-
- org.openscience.cdk.isomorphism.matchers.QueryChemObject
-
- org.openscience.cdk.isomorphism.matchers.QueryAtomContainer
-
- All Implemented Interfaces:
Cloneable
,IAtomContainer
,ICDKObject
,IChemObject
,IChemObjectListener
,IQueryAtomContainer
- Direct Known Subclasses:
PharmacophoreQuery
public class QueryAtomContainer extends QueryChemObject implements IQueryAtomContainer
- Source code:
- main
- Belongs to CDK module:
- isomorphism
-
-
Field Summary
Fields Modifier and Type Field 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 List<IStereoElement>
stereoElements
Internal list of atom parities.-
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
-
-
Constructor Summary
Constructors Constructor Description QueryAtomContainer(int atomCount, int bondCount, int lpCount, int seCount, IChemObjectBuilder builder)
Constructs an empty AtomContainer that will contain a certain number of atoms and electronContainers.QueryAtomContainer(IAtomContainer container, IChemObjectBuilder builder)
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).QueryAtomContainer(IChemObjectBuilder builder)
Constructs an empty AtomContainer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
add(IAtomContainer atomContainer)
Adds all atoms and electronContainers of a given atomcontainer to this container.void
addAtom(IAtom atom)
Adds an atom to this container.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
addBond(IBond bond)
Adds a Bond to this AtomContainer.void
addElectronContainer(IElectronContainer electronContainer)
Adds a ElectronContainer to this AtomContainer.void
addLonePair(int atomID)
Adds a LonePair to this Atom.void
addLonePair(ILonePair lonePair)
Adds a lone pair to this AtomContainer.void
addSingleElectron(int atomID)
Adds a LonePair 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.IQueryAtomContainer
clone()
Clones this AtomContainer object and its content.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.static void
create(IAtomContainer dst, IAtomContainer src, Expr.Type... opts)
Populate a query from a molecule and a provided set of expressions.static QueryAtomContainer
create(IAtomContainer src, Expr.Type... opts)
Create a query from a molecule and a provided set of expressions.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(int idx)
Get the bond at the specified idx, the index should be in the range 0 ≤ idx <IAtomContainer.getBondCount()
.IBond
getBond(IAtom atom1, IAtom atom2)
Returns the bond that connects the two given atoms.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)
Deprecated.Replaced byAtomContainerManipulator#getBondOrderSum(IAtomContainer, IAtom)
int
getConnectedAtomsCount(IAtom atom)
Returns the number of atoms connected to the given atom.List<IAtom>
getConnectedAtomsList(IAtom atom)
Returns an ArrayList of all atoms connected to the given atom.int
getConnectedBondsCount(int idx)
Returns the number of connected atoms (degree) to the given atom.int
getConnectedBondsCount(IAtom atom)
Returns the number of Bonds for a given Atom.List<IBond>
getConnectedBondsList(IAtom atom)
Returns an ArrayList of all Bonds connected to the given atom.List<IElectronContainer>
getConnectedElectronContainersList(IAtom atom)
Returns an ArrayList of all electronContainers connected to the given atom.int
getConnectedLonePairsCount(IAtom atom)
Returns the number of LonePairs for a given Atom.List<ILonePair>
getConnectedLonePairsList(IAtom atom)
Returns the array of lone pairs connected to an atom.int
getConnectedSingleElectronsCount(IAtom atom)
Returns the sum of the SingleElectron for a given Atom.List<ISingleElectron>
getConnectedSingleElectronsList(IAtom atom)
Returns an array of all SingleElectron connected to the given atom.IElectronContainer
getElectronContainer(int number)
Returns the ElectronContainer at positionnumber
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 and bond from this container.void
removeAtom(int pos)
Safely remove an atom from the container.void
removeAtom(IAtom atom)
Removes the given atom and all connected electronContainers from the AtomContainer.void
removeAtomAndConnectedElectronContainers(IAtom atom)
Deprecated.void
removeAtomOnly(int position)
Removes the atom at the given position from the AtomContainer.void
removeAtomOnly(IAtom atom)
Removes the given atom from the AtomContainer.IBond
removeBond(int position)
Removes the bond at the given position from the AtomContainer.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.IElectronContainer
removeElectronContainer(int number)
Removes the bond at the given position from this container.void
removeElectronContainer(IElectronContainer electronContainer)
Removes this ElectronContainer from this container.ILonePair
removeLonePair(int position)
Removes the lone pair at the given position from the AtomContainer.void
removeLonePair(ILonePair lonePair)
Removes the lone pair 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 atidx
, the index must have an existing atom and therefore be in the range 0 ≤ idx < mol.getAtomCount().void
setAtoms(IAtom[] atoms)
Sets the array of atoms of this AtomContainer.void
setBonds(IBond[] bonds)
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 which this object has registered as a listener.Iterable<IStereoElement>
stereoElements()
Returns the stereo elements defined for this atom container.String
toString()
Returns a one line description of this IChemObject.-
Methods inherited from class org.openscience.cdk.isomorphism.matchers.QueryChemObject
addListener, addProperties, clear, flags, getBuilder, getFlag, getFlags, getFlagValue, getID, getListenerCount, getNotification, getProperties, getProperty, getProperty, is, matches, notifyChanged, notifyChanged, removeListener, removeProperty, set, setFlag, setFlags, setID, setNotification, setProperties, setProperty
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.openscience.cdk.interfaces.IAtomContainer
newAtom, newAtom, newAtom, newAtom, newBond, newBond
-
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
-
-
-
-
Field Detail
-
atomCount
protected int atomCount
Number of atoms contained by this object.
-
bondCount
protected int bondCount
Number of bonds contained by this object.
-
lonePairCount
protected int lonePairCount
Number of lone pairs contained by this object.
-
singleElectronCount
protected int singleElectronCount
Number of single electrons contained by this object.
-
growArraySize
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.
-
atoms
protected IAtom[] atoms
Internal array of atoms.
-
bonds
protected IBond[] bonds
Internal array of bonds.
-
lonePairs
protected ILonePair[] lonePairs
Internal array of lone pairs.
-
singleElectrons
protected ISingleElectron[] singleElectrons
Internal array of single electrons.
-
stereoElements
protected final List<IStereoElement> stereoElements
Internal list of atom parities.
-
-
Constructor Detail
-
QueryAtomContainer
public QueryAtomContainer(IChemObjectBuilder builder)
Constructs an empty AtomContainer.
-
QueryAtomContainer
public QueryAtomContainer(IAtomContainer container, IChemObjectBuilder builder)
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).- Parameters:
container
- An AtomContainer to copy the atoms and electronContainers from
-
QueryAtomContainer
public QueryAtomContainer(int atomCount, int bondCount, int lpCount, int seCount, IChemObjectBuilder builder)
Constructs an empty AtomContainer that will contain a certain number of atoms and electronContainers. It will set the starting array lengths to the defined values, but will not create any Atom or ElectronContainer's.- Parameters:
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 container
-
-
Method Detail
-
toString
public String toString()
Description copied from interface:IChemObject
Returns a one line description of this IChemObject.- Specified by:
toString
in interfaceIChemObject
- Overrides:
toString
in classObject
- Returns:
- a String representation of this object
-
addStereoElement
public void addStereoElement(IStereoElement element)
Adds a stereo element to this container.- Specified by:
addStereoElement
in interfaceIAtomContainer
- Parameters:
element
- The newIStereoElement
for this container- See Also:
IAtomContainer.stereoElements()
-
stereoElements
public Iterable<IStereoElement> stereoElements()
Returns the stereo elements defined for this atom container.- Specified by:
stereoElements
in interfaceIAtomContainer
- Returns:
- An
Iterable
ofIStereoElement
s. - See Also:
IAtomContainer.addStereoElement(IStereoElement)
-
setAtoms
public void setAtoms(IAtom[] atoms)
Sets the array of atoms of this AtomContainer.- Specified by:
setAtoms
in interfaceIAtomContainer
- Parameters:
atoms
- The array of atoms to be assigned to this AtomContainer- See Also:
getAtom(int)
-
setBonds
public void setBonds(IBond[] bonds)
Sets the array of bonds of this AtomContainer.- Specified by:
setBonds
in interfaceIAtomContainer
- Parameters:
bonds
- The array of bonds to be assigned to this AtomContainer- See Also:
getBond(int)
-
setAtom
public void setAtom(int idx, IAtom atom)
Set the atom atidx
, the index must have an existing atom and therefore be in the range 0 ≤ idx < mol.getAtomCount().- Specified by:
setAtom
in interfaceIAtomContainer
- Parameters:
idx
- The index of the atom to be set.atom
- The atom to be stored at positionidx
- See Also:
IAtomContainer.getAtom(int)
-
getAtom
public IAtom getAtom(int idx)
Get the atom at the specified idx, the index should be in the range 0 ≤ idx <IAtomContainer.getAtomCount()
.- Specified by:
getAtom
in interfaceIAtomContainer
- Parameters:
idx
- atom index- Returns:
- the atom stored at the index
- See Also:
IAtomContainer.setAtom(int, org.openscience.cdk.interfaces.IAtom)
-
getBond
public IBond getBond(int idx)
Get the bond at the specified idx, the index should be in the range 0 ≤ idx <IAtomContainer.getBondCount()
.- Specified by:
getBond
in interfaceIAtomContainer
- Parameters:
idx
- bond index- Returns:
- the bond stored at the index
-
getLonePair
public ILonePair getLonePair(int idx)
Get the lone pair at the specified idx, the index should be in the range 0 ≤ idx <IAtomContainer.getLonePairCount()
.- Specified by:
getLonePair
in interfaceIAtomContainer
- Parameters:
idx
- lone pair index- Returns:
- the lone pair stored at the index
-
getSingleElectron
public ISingleElectron getSingleElectron(int idx)
Get the single electron at the specified idx, the index should be in the range 0 ≤ idx <IAtomContainer.getSingleElectronCount()
.- Specified by:
getSingleElectron
in interfaceIAtomContainer
- Parameters:
idx
- single electron index- Returns:
- the single electron stored at the index
-
atoms
public Iterable<IAtom> atoms()
Returns an Iterable for looping over all atoms in this container.- Specified by:
atoms
in interfaceIAtomContainer
- Returns:
- An Iterable with the atoms in this container
-
bonds
public Iterable<IBond> bonds()
Returns an Iterable for looping over all bonds in this container.- Specified by:
bonds
in interfaceIAtomContainer
- Returns:
- An Iterable with the bonds in this container
-
lonePairs
public Iterable<ILonePair> lonePairs()
Returns an Iterable for looping over all lone pairs in this container.- Specified by:
lonePairs
in interfaceIAtomContainer
- Returns:
- An Iterable with the lone pairs in this container
-
singleElectrons
public Iterable<ISingleElectron> singleElectrons()
Returns an Iterable for looping over all single electrons in this container.- Specified by:
singleElectrons
in interfaceIAtomContainer
- Returns:
- An Iterable with the single electrons in this container
-
electronContainers
public Iterable<IElectronContainer> electronContainers()
Returns an Iterable for looping over all electron containers in this container.- Specified by:
electronContainers
in interfaceIAtomContainer
- Returns:
- An Iterable with the electron containers in this container
-
getFirstAtom
public IAtom getFirstAtom()
Returns the atom at position 0 in the container.- Specified by:
getFirstAtom
in interfaceIAtomContainer
- Returns:
- The atom at position 0 .
-
getLastAtom
public IAtom getLastAtom()
Returns the atom at the last position in the container.- Specified by:
getLastAtom
in interfaceIAtomContainer
- Returns:
- The atom at the last position
-
getAtomNumber
public int getAtomNumber(IAtom atom)
Returns the position of a given atom in the atoms array. It returns -1 if the atom does not exist.- Specified by:
getAtomNumber
in interfaceIAtomContainer
- Parameters:
atom
- The atom to be sought- Returns:
- The Position of the atom in the atoms array in [0,..].
-
getBondNumber
public int getBondNumber(IAtom atom1, IAtom atom2)
Returns the position of the bond between two given atoms in the electronContainers array. It returns -1 if the bond does not exist.- Specified by:
getBondNumber
in interfaceIAtomContainer
- Parameters:
atom1
- The first atomatom2
- The second atom- Returns:
- The Position of the bond between a1 and a2 in the electronContainers array.
-
getBondNumber
public int getBondNumber(IBond bond)
Returns the position of a given bond in the electronContainers array. It returns -1 if the bond does not exist.- Specified by:
getBondNumber
in interfaceIAtomContainer
- Parameters:
bond
- The bond to be sought- Returns:
- The Position of the bond in the electronContainers array in [0,..].
-
getLonePairNumber
public int getLonePairNumber(ILonePair lonePair)
Returns the position of a given lone pair in the lone pair array. It returns -1 if the lone pair does not exist.- Specified by:
getLonePairNumber
in interfaceIAtomContainer
- Parameters:
lonePair
- The lone pair to be sought- Returns:
- The Position of the lone pair in the array..
-
getSingleElectronNumber
public int getSingleElectronNumber(ISingleElectron singleElectron)
Returns the position of a given single electron in the single electron array. It returns -1 if the single electron does not exist.- Specified by:
getSingleElectronNumber
in interfaceIAtomContainer
- Parameters:
singleElectron
- The single electron to be sought- Returns:
- The Position of the single electron in the array.
-
indexOf
public int indexOf(IAtom atom)
Description copied from interface:IAtomContainer
Access the storage index of an atom.- Specified by:
indexOf
in interfaceIAtomContainer
- Parameters:
atom
- atom instance to find- Returns:
- the index, -1 if not found
-
indexOf
public int indexOf(IBond bond)
Description copied from interface:IAtomContainer
Access the storage index of a bond.- Specified by:
indexOf
in interfaceIAtomContainer
- Parameters:
bond
- bond instance to find- Returns:
- the index, -1 if not found
-
indexOf
public int indexOf(ISingleElectron electron)
Description copied from interface:IAtomContainer
Access the storage index of a single electron (radical).- Specified by:
indexOf
in interfaceIAtomContainer
- Parameters:
electron
- the electron- Returns:
- the index, -1 if not found
-
indexOf
public int indexOf(ILonePair pair)
Description copied from interface:IAtomContainer
Access the storage index of a long pair.- Specified by:
indexOf
in interfaceIAtomContainer
- Parameters:
pair
- the long pair- Returns:
- the index, -1 if not found
-
getElectronContainer
public IElectronContainer getElectronContainer(int number)
Returns the ElectronContainer at positionnumber
in the container.- Specified by:
getElectronContainer
in interfaceIAtomContainer
- Parameters:
number
- The position of the ElectronContainer to be returned.- Returns:
- The ElectronContainer at position
number
. - See Also:
IAtomContainer.addElectronContainer(IElectronContainer)
-
getBond
public IBond getBond(IAtom atom1, IAtom atom2)
Returns the bond that connects the two given atoms.- Specified by:
getBond
in interfaceIAtomContainer
- Parameters:
atom1
- The first atomatom2
- The second atom- Returns:
- The bond that connects the two atoms
-
getAtomCount
public int getAtomCount()
Returns the number of Atoms in this Container.- Specified by:
getAtomCount
in interfaceIAtomContainer
- Returns:
- The number of Atoms in this Container
-
getBondCount
public int getBondCount()
Returns the number of Bonds in this Container.- Specified by:
getBondCount
in interfaceIAtomContainer
- Returns:
- The number of Bonds in this Container
-
getLonePairCount
public int getLonePairCount()
Returns the number of LonePairs in this Container.- Specified by:
getLonePairCount
in interfaceIAtomContainer
- Returns:
- The number of LonePairs in this Container
-
getSingleElectronCount
public int getSingleElectronCount()
Returns the number of the single electrons in this container,- Specified by:
getSingleElectronCount
in interfaceIAtomContainer
- Returns:
- The number of SingleElectron objects of this AtomContainer
-
getElectronContainerCount
public int getElectronContainerCount()
Returns the number of ElectronContainers in this Container.- Specified by:
getElectronContainerCount
in interfaceIAtomContainer
- Returns:
- The number of ElectronContainers in this Container
-
getConnectedAtomsList
public List<IAtom> getConnectedAtomsList(IAtom atom)
Returns an ArrayList of all atoms connected to the given atom.- Specified by:
getConnectedAtomsList
in interfaceIAtomContainer
- Parameters:
atom
- The atom the bond partners are searched of.- Returns:
- The ArrayList with the connected atoms
-
getConnectedBondsList
public List<IBond> getConnectedBondsList(IAtom atom)
Returns an ArrayList of all Bonds connected to the given atom.- Specified by:
getConnectedBondsList
in interfaceIAtomContainer
- Parameters:
atom
- The atom the connected bonds are searched of- Returns:
- The ArrayList with connected atoms
-
getConnectedLonePairsList
public List<ILonePair> getConnectedLonePairsList(IAtom atom)
Returns the array of lone pairs connected to an atom.- Specified by:
getConnectedLonePairsList
in interfaceIAtomContainer
- Parameters:
atom
- The atom for which to get lone pairs- Returns:
- The array of LonePairs of this AtomContainer
- See Also:
getElectronContainer(int)
,electronContainers()
,getBond(int)
-
getConnectedSingleElectronsList
public List<ISingleElectron> getConnectedSingleElectronsList(IAtom atom)
Returns an array of all SingleElectron connected to the given atom.- Specified by:
getConnectedSingleElectronsList
in interfaceIAtomContainer
- Parameters:
atom
- The atom on which the single electron is located- Returns:
- The array of SingleElectron of this AtomContainer
-
getConnectedElectronContainersList
public List<IElectronContainer> getConnectedElectronContainersList(IAtom atom)
Returns an ArrayList of all electronContainers connected to the given atom.- Specified by:
getConnectedElectronContainersList
in interfaceIAtomContainer
- Parameters:
atom
- The atom the connected electronContainers are searched of- Returns:
- The ArrayList with the connected atoms
-
getConnectedAtomsCount
public int getConnectedAtomsCount(IAtom atom)
Returns the number of atoms connected to the given atom.- Specified by:
getConnectedAtomsCount
in interfaceIAtomContainer
- Parameters:
atom
- The atom the number of bond partners are searched of.- Returns:
- The the size of connected atoms
-
getConnectedBondsCount
public int getConnectedBondsCount(IAtom atom)
Returns the number of Bonds for a given Atom.- Specified by:
getConnectedBondsCount
in interfaceIAtomContainer
- Parameters:
atom
- The atom- Returns:
- The number of Bonds for this atom
-
getConnectedBondsCount
public int getConnectedBondsCount(int idx)
Returns the number of connected atoms (degree) to the given atom.- Specified by:
getConnectedBondsCount
in interfaceIAtomContainer
- Parameters:
idx
- The atomnumber the degree is searched for- Returns:
- The number of connected atoms (degree)
-
getConnectedLonePairsCount
public int getConnectedLonePairsCount(IAtom atom)
Returns the number of LonePairs for a given Atom.- Specified by:
getConnectedLonePairsCount
in interfaceIAtomContainer
- Parameters:
atom
- The atom- Returns:
- The number of LonePairs for this atom
-
getConnectedSingleElectronsCount
public int getConnectedSingleElectronsCount(IAtom atom)
Returns the sum of the SingleElectron for a given Atom.- Specified by:
getConnectedSingleElectronsCount
in interfaceIAtomContainer
- Parameters:
atom
- The atom on which the single electron is located- Returns:
- The array of SingleElectron of this AtomContainer
-
getBondOrderSum
public double getBondOrderSum(IAtom atom)
Deprecated.Replaced byAtomContainerManipulator#getBondOrderSum(IAtomContainer, IAtom)
Returns the sum of the bond orders for a given Atom.- Specified by:
getBondOrderSum
in interfaceIAtomContainer
- Parameters:
atom
- The atom- Returns:
- The number of bond orders for this atom
-
getMaximumBondOrder
public IBond.Order getMaximumBondOrder(IAtom atom)
Returns the maximum bond order that this atom currently has in the context of this AtomContainer.- Specified by:
getMaximumBondOrder
in interfaceIAtomContainer
- Parameters:
atom
- The atom- Returns:
- The maximum bond order that this atom currently has
-
getMinimumBondOrder
public IBond.Order getMinimumBondOrder(IAtom atom)
Returns the minimum bond order that this atom currently has in the context of this AtomContainer.- Specified by:
getMinimumBondOrder
in interfaceIAtomContainer
- Parameters:
atom
- The atom- Returns:
- The minimum bond order that this atom currently has
-
add
public void add(IAtomContainer atomContainer)
Adds all atoms and electronContainers of a given atomcontainer to this container.- Specified by:
add
in interfaceIAtomContainer
- Parameters:
atomContainer
- The atomcontainer to be added
-
addAtom
public void addAtom(IAtom atom)
Adds an atom to this container.- Specified by:
addAtom
in interfaceIAtomContainer
- Parameters:
atom
- The atom to be added to this container
-
addBond
public void addBond(IBond bond)
Adds a Bond to this AtomContainer.- Specified by:
addBond
in interfaceIAtomContainer
- Parameters:
bond
- The bond to added to this container
-
addLonePair
public void addLonePair(ILonePair lonePair)
Adds a lone pair to this AtomContainer.- Specified by:
addLonePair
in interfaceIAtomContainer
- Parameters:
lonePair
- The LonePair to added to this container
-
addSingleElectron
public void addSingleElectron(ISingleElectron singleElectron)
Adds a single electron to this AtomContainer.- Specified by:
addSingleElectron
in interfaceIAtomContainer
- Parameters:
singleElectron
- The SingleElectron to added to this container
-
addElectronContainer
public void addElectronContainer(IElectronContainer electronContainer)
Adds a ElectronContainer to this AtomContainer.- Specified by:
addElectronContainer
in interfaceIAtomContainer
- Parameters:
electronContainer
- The ElectronContainer to added to this container
-
remove
public void remove(IAtomContainer atomContainer)
Removes all atoms and electronContainers of a given atomcontainer from this container.- Specified by:
remove
in interfaceIAtomContainer
- Parameters:
atomContainer
- The atomcontainer to be removed
-
removeAtomOnly
public void removeAtomOnly(int position)
Removes the atom at the given position from the AtomContainer. Note that the electronContainers are unaffected: you also have to take care of removing all electronContainers to this atom from the container manually.- Specified by:
removeAtomOnly
in interfaceIAtomContainer
- Parameters:
position
- The position of the atom to be removed.
-
removeAtomOnly
public void removeAtomOnly(IAtom atom)
Removes the given atom from the AtomContainer. Note that the electronContainers are unaffected: you also have to take care of removing all electronContainers to this atom from the container.- Specified by:
removeAtomOnly
in interfaceIAtomContainer
- Parameters:
atom
- The atom to be removed
-
removeBond
public IBond removeBond(int position)
Removes the bond at the given position from the AtomContainer.- Specified by:
removeBond
in interfaceIAtomContainer
- Parameters:
position
- The position of the bond to be removed.- Returns:
- the bond at the given position
-
removeBond
public IBond removeBond(IAtom atom1, IAtom atom2)
Removes the bond that connects the two given atoms.- Specified by:
removeBond
in interfaceIAtomContainer
- Parameters:
atom1
- The first atomatom2
- The second atom- Returns:
- The bond that connects the two atoms
-
removeBond
public void removeBond(IBond bond)
Removes the bond from this container.- Specified by:
removeBond
in interfaceIAtomContainer
- Parameters:
bond
- The bond to be removed.
-
removeLonePair
public ILonePair removeLonePair(int position)
Removes the lone pair at the given position from the AtomContainer.- Specified by:
removeLonePair
in interfaceIAtomContainer
- Parameters:
position
- The position of the LonePair to be removed.- Returns:
- The removed ILonePair.
-
removeLonePair
public void removeLonePair(ILonePair lonePair)
Removes the lone pair from the AtomContainer.- Specified by:
removeLonePair
in interfaceIAtomContainer
- Parameters:
lonePair
- The LonePair to be removed.
-
removeSingleElectron
public ISingleElectron removeSingleElectron(int position)
Removes the single electron at the given position from the AtomContainer.- Specified by:
removeSingleElectron
in interfaceIAtomContainer
- Parameters:
position
- The position of the SingleElectron to be removed.- Returns:
- The removed ISingleElectron
-
removeSingleElectron
public void removeSingleElectron(ISingleElectron singleElectron)
Removes the single electron from the AtomContainer.- Specified by:
removeSingleElectron
in interfaceIAtomContainer
- Parameters:
singleElectron
- The SingleElectron to be removed.
-
removeElectronContainer
public IElectronContainer removeElectronContainer(int number)
Removes the bond at the given position from this container.- Specified by:
removeElectronContainer
in interfaceIAtomContainer
- Parameters:
number
- The position of the bond in the electronContainers array- Returns:
- Bond that was removed
-
removeElectronContainer
public void removeElectronContainer(IElectronContainer electronContainer)
Removes this ElectronContainer from this container.- Specified by:
removeElectronContainer
in interfaceIAtomContainer
- Parameters:
electronContainer
- The electronContainer to be removed
-
removeAtomAndConnectedElectronContainers
@Deprecated public void removeAtomAndConnectedElectronContainers(IAtom atom)
Deprecated.Safely remove an atom from the container.- Specified by:
removeAtomAndConnectedElectronContainers
in interfaceIAtomContainer
- See Also:
IAtomContainer.removeAtom(IAtom)
-
removeAtom
public void removeAtom(IAtom atom)
Removes the given atom and all connected electronContainers from the AtomContainer.- Specified by:
removeAtom
in interfaceIAtomContainer
- Parameters:
atom
- The atom to be removed
-
removeAtom
public void removeAtom(int pos)
Safely remove an atom from the container.
Removes a single atom from the container updating all internal state to be consistent. All bonds connected to the atom will be deleted as well as all stereo elements. If multiple atoms/bonds are being deleted they should be gathered into a single transaction and removed withIAtomContainer.remove(IAtomContainer)
.
If you are removing hydrogens one of the utility methods (e.g. AtomContainerManipulator.removeHydrogens(IAtomContainer)) is preferable.- Specified by:
removeAtom
in interfaceIAtomContainer
- Parameters:
pos
- the position of the atom to be removed
-
removeAllElements
public void removeAllElements()
Removes all atoms and bond from this container.- Specified by:
removeAllElements
in interfaceIAtomContainer
-
removeAllElectronContainers
public void removeAllElectronContainers()
Removes electronContainers from this container.- Specified by:
removeAllElectronContainers
in interfaceIAtomContainer
-
removeAllBonds
public void removeAllBonds()
Removes all Bonds from this container.- Specified by:
removeAllBonds
in interfaceIAtomContainer
-
addBond
public void addBond(int atom1, int atom2, IBond.Order order, IBond.Stereo stereo)
Adds a bond to this container.- Specified by:
addBond
in interfaceIAtomContainer
- Parameters:
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 orientation
-
addBond
public void addBond(int atom1, int atom2, IBond.Order order)
Adds a bond to this container.- Specified by:
addBond
in interfaceIAtomContainer
- Parameters:
atom1
- Id of the first atom of the Bond in [0,..]atom2
- Id of the second atom of the Bond in [0,..]order
- Bondorder
-
addLonePair
public void addLonePair(int atomID)
Adds a LonePair to this Atom.- Specified by:
addLonePair
in interfaceIAtomContainer
- Parameters:
atomID
- The atom number to which the LonePair is added in [0,..]
-
addSingleElectron
public void addSingleElectron(int atomID)
Adds a LonePair to this Atom.- Specified by:
addSingleElectron
in interfaceIAtomContainer
- Parameters:
atomID
- The atom number to which the LonePair is added in [0,..]
-
contains
public boolean contains(IAtom atom)
True, if the AtomContainer contains the given atom object.- Specified by:
contains
in interfaceIAtomContainer
- Parameters:
atom
- the atom this AtomContainer is searched for- Returns:
- true if the AtomContainer contains the given atom object
-
contains
public boolean contains(IBond bond)
True, if the AtomContainer contains the given bond object.- Specified by:
contains
in interfaceIAtomContainer
- Parameters:
bond
- the bond this AtomContainer is searched for- Returns:
- true if the AtomContainer contains the given bond object
-
contains
public boolean contains(ILonePair lonePair)
True, if the AtomContainer contains the given LonePair object.- Specified by:
contains
in interfaceIAtomContainer
- Parameters:
lonePair
- the LonePair this AtomContainer is searched for- Returns:
- true if the AtomContainer contains the given LonePair object
-
contains
public boolean contains(ISingleElectron singleElectron)
True, if the AtomContainer contains the given SingleElectron object.- Specified by:
contains
in interfaceIAtomContainer
- Parameters:
singleElectron
- the LonePair this AtomContainer is searched for- Returns:
- true if the AtomContainer contains the given LonePair object
-
contains
public boolean contains(IElectronContainer electronContainer)
True, if the AtomContainer contains the given ElectronContainer object.- Specified by:
contains
in interfaceIAtomContainer
- Parameters:
electronContainer
- ElectronContainer that is searched for- Returns:
- true if the AtomContainer contains the given bond object
-
clone
public IQueryAtomContainer clone() throws CloneNotSupportedException
Clones this AtomContainer object and its content.- Specified by:
clone
in interfaceIAtomContainer
- Specified by:
clone
in interfaceIChemObject
- Overrides:
clone
in classQueryChemObject
- Returns:
- The cloned object
- Throws:
CloneNotSupportedException
- if the IChemObject cannot be cloned- See Also:
QueryAtomContainer(org.openscience.cdk.interfaces.IAtomContainer, org.openscience.cdk.interfaces.IChemObjectBuilder)
-
stateChanged
public void stateChanged(IChemObjectChangeEvent event)
Called by objects to which this object has registered as a listener.- Specified by:
stateChanged
in interfaceIChemObjectListener
- Parameters:
event
- A change event pointing to the source of the change
-
isEmpty
public boolean isEmpty()
Indicates whether this container is empty. The container is considered empty if there are no atoms. Bonds are not checked as a graph with no vertexes can not have edges.- Specified by:
isEmpty
in interfaceIAtomContainer
- Returns:
- whether the container is empty
-
getTitle
public String getTitle()
Access the title of the record.- Specified by:
getTitle
in interfaceIAtomContainer
- Returns:
- the title
-
setTitle
public void setTitle(String title)
Modify the title of the record.- Specified by:
setTitle
in interfaceIAtomContainer
- Parameters:
title
- the title
-
setStereoElements
public void setStereoElements(List<IStereoElement> elements)
Description copied from interface:IAtomContainer
Set the stereo elements - this will replace the existing instance with a new instance.- Specified by:
setStereoElements
in interfaceIAtomContainer
- Parameters:
elements
- the new stereo elements
-
create
public static void create(IAtomContainer dst, IAtomContainer src, Expr.Type... opts)
Populate a query from a molecule and a provided set of expressions. The molecule is converted and any features specified in theopts
will be matched.
A good starting point is the following options:// [nH]1ccc(=O)cc1 => n1:c:c:c(=O):c:c:1 QueryAtomContainer.create(qry, mol, ALIPHATIC_ELEMENT, AROMATIC_ELEMENT, SINGLE_OR_AROMATIC, ALIPHATIC_ORDER, STEREOCHEMISTRY);
SpecifyingExpr.Type.DEGREE
(orExpr.Type.TOTAL_DEGREE
+Expr.Type.IMPL_H_COUNT
) means the molecule will not match as a substructure.
// [nH]1ccc(=O)cc1 => [nD2]1:[cD2]:[cD2]:[cD2](=[OD1]):[cD2]:[cD2]:1 QueryAtomContainer.create(qry, mol, ALIPHATIC_ELEMENT, AROMATIC_ELEMENT, DEGREE, SINGLE_OR_AROMATIC, ALIPHATIC_ORDER);
TheExpr.Type.RING_BOND_COUNT
property is useful for locking in ring systems. Specifying the ring bond count on benzene means it will not match larger ring systems (e.g. naphthalenee) but can still be substituted.
// [nH]1ccc(=O)cc1 => // [nx2+0]1:[cx2+0]:[cx2+0]:[cx2+0](=[O&x0+0]):[cx2+0]:[cx2+0]:1 // IMPORTANT! use Cycles.markRingAtomsAndBonds(mol) to set ring status QueryAtomContainer.create(qry, mol, ALIPHATIC_ELEMENT, AROMATIC_ELEMENT, FORMAL_CHARGE, ISOTOPE, RING_BOND_COUNT, SINGLE_OR_AROMATIC, ALIPHATIC_ORDER);
Note thatExpr.Type.FORMAL_CHARGE
,Expr.Type.IMPL_H_COUNT
, andExpr.Type.ISOTOPE
are ignored if null. Explicitly setting these to zero (only required for Isotope from SMILES) forces their inclusion.
Please note not all// [nH]1ccc(=O)cc1 => // [0n+0]1:[0c+0]:[0c+0]:[0c+0](=[O+0]):[0c+0]:[0c+0]:1 QueryAtomContainer.create(qry, mol, ALIPHATIC_ELEMENT, AROMATIC_ELEMENT, FORMAL_CHARGE, ISOTOPE, RING_BOND_COUNT, SINGLE_OR_AROMATIC, ALIPHATIC_ORDER);
Expr.Type
s are currently supported, if you require a specific type that you think is useful please open an issue.- Parameters:
dst
- the output destinationsrc
- the input moleculeopts
- set of the expr types to match
-
create
public static QueryAtomContainer create(IAtomContainer src, Expr.Type... opts)
Create a query from a molecule and a provided set of expressions. The molecule is converted and any features specified in theopts
will be matched.
A good starting point is the following options:// [nH]1ccc(=O)cc1 => n1:c:c:c(=O):c:c:1 QueryAtomContainer.create(mol, ALIPHATIC_ELEMENT, AROMATIC_ELEMENT, SINGLE_OR_AROMATIC, ALIPHATIC_ORDER, STEREOCHEMISTRY);
SpecifyingExpr.Type.DEGREE
(orExpr.Type.TOTAL_DEGREE
+Expr.Type.IMPL_H_COUNT
) means the molecule will not match as a substructure.
// [nH]1ccc(=O)cc1 => [nD2]1:[cD2]:[cD2]:[cD2](=[OD1]):[cD2]:[cD2]:1 QueryAtomContainer.create(mol, ALIPHATIC_ELEMENT, AROMATIC_ELEMENT, DEGREE, SINGLE_OR_AROMATIC, ALIPHATIC_ORDER);
TheExpr.Type.RING_BOND_COUNT
property is useful for locking in ring systems. Specifying the ring bond count on benzene means it will not match larger ring systems (e.g. naphthalenee) but can still be substituted.
// [nH]1ccc(=O)cc1 => // [nx2+0]1:[cx2+0]:[cx2+0]:[cx2+0](=[O&x0+0]):[cx2+0]:[cx2+0]:1 // IMPORTANT! use Cycles.markRingAtomsAndBonds(mol) to set ring status QueryAtomContainer.create(mol, ALIPHATIC_ELEMENT, AROMATIC_ELEMENT, FORMAL_CHARGE, ISOTOPE, RING_BOND_COUNT, SINGLE_OR_AROMATIC, ALIPHATIC_ORDER);
Note thatExpr.Type.FORMAL_CHARGE
,Expr.Type.IMPL_H_COUNT
, andExpr.Type.ISOTOPE
are ignored if null. Explicitly setting these to zero (only required for Isotope from SMILES) forces their inclusion.
Please note not all// [nH]1ccc(=O)cc1 => // [0n+0]1:[0c+0]:[0c+0]:[0c+0](=[O+0]):[0c+0]:[0c+0]:1 QueryAtomContainer.create(mol, ALIPHATIC_ELEMENT, AROMATIC_ELEMENT, FORMAL_CHARGE, ISOTOPE, RING_BOND_COUNT, SINGLE_OR_AROMATIC, ALIPHATIC_ORDER);
Expr.Type
s are currently supported, if you require a specific type that you think is useful please open an issue.- Parameters:
src
- the input moleculeopts
- set of the expr types to match- Returns:
- the query container
-
-