Class QueryBond
- java.lang.Object
-
- org.openscience.cdk.isomorphism.matchers.QueryChemObject
-
- org.openscience.cdk.isomorphism.matchers.QueryBond
-
- All Implemented Interfaces:
Cloneable
,IBond
,ICDKObject
,IChemObject
,IElectronContainer
,IQueryBond
- Direct Known Subclasses:
CTFileQueryBond
,OrderQueryBond
,OrderQueryBondOrderOnly
,SMARTSBond
public class QueryBond extends QueryChemObject implements IQueryBond
Implements the concept of a "query bond" between two or more atoms. Query bonds can be used to capture types such as "Single or Double" or "Any".- Source code:
- main
- Belongs to CDK module:
- isomorphism
- Created on:
- 2010-12-16
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.openscience.cdk.interfaces.IBond
IBond.Display, IBond.Order, IBond.Stereo
-
-
Field Summary
Fields Modifier and Type Field Description protected int
atomCount
Number of atoms contained by this object.protected IAtom[]
atoms
A list of atoms participating in this query bond.protected Integer
electronCount
Number of electrons in the ElectronContainer.protected IBond.Order
order
The bond order of this query bond.protected IBond.Stereo
stereo
A descriptor the stereochemical orientation of this query bond.-
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 QueryBond(IAtom[] atoms, IBond.Order order, IChemObjectBuilder builder)
Constructs a multi-center query bond, with a specified order and no stereo information.QueryBond(IAtom[] atoms, IChemObjectBuilder builder)
Constructs a multi-center query bond, with undefined order and no stereo information.QueryBond(IAtom atom1, IAtom atom2, IBond.Order order, IBond.Stereo stereo, IChemObjectBuilder builder)
Constructs a query bond with a given order and stereo orientation from an array of atoms.QueryBond(IAtom atom1, IAtom atom2, IBond.Order order, IChemObjectBuilder builder)
Constructs a query bond with a given order.QueryBond(IAtom atom1, IAtom atom2, IChemObjectBuilder builder)
Constructs a query bond with a single query bond order..QueryBond(IAtom beg, IAtom end, Expr expr)
Constructs a query bond from an expression.QueryBond(IAtom beg, IAtom end, Expr.Type type)
Constructs a query bond from an expression type.QueryBond(IAtom beg, IAtom end, Expr.Type type, int val)
Constructs a query bond from an expression type and value.QueryBond(IChemObjectBuilder builder)
Constructs an empty query bond.QueryBond(Expr.Type type, IChemObjectBuilder builder)
Constructs an empty query bond.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Iterable<IAtom>
atoms()
Returns the Iterator to atoms making up this query bond.IQueryBond
clone()
Clones this query bond object, including clones of the atoms between which the query bond is defined.boolean
compare(Object object)
Compares a query bond with this query bond.boolean
contains(IAtom atom)
Returns true if the given atom participates in this query bond.boolean
equals(Object obj)
javax.vecmath.Point2d
get2DCenter()
Returns the geometric 2D center of the query bond.javax.vecmath.Point3d
get3DCenter()
Returns the geometric 3D center of the query bond.IAtom
getAtom(int position)
Returns an Atom from this query bond.int
getAtomCount()
Returns the number of Atoms in this Bond.IAtom
getBegin()
Access the begin (or first) atom of the bond.IAtom
getConnectedAtom(IAtom atom)
Returns the other atom in the bond, the atom is connected to the given atom.IAtom[]
getConnectedAtoms(IAtom atom)
Returns all the atoms in the bond connected to the given atom.IAtomContainer
getContainer()
IBond.Display
getDisplay()
Not used for query bonds.Integer
getElectronCount()
Returns the number of electrons in this bondIAtom
getEnd()
Access the end (or second) atom of the bond.Expr
getExpression()
Access the bond expression predicate associated with this query bond.int
getIndex()
IBond.Order
getOrder()
Returns the query bond order of this query bond.IAtom
getOther(IAtom atom)
Returns the other atom in the bond, the atom is connected to the given atom.This method is only correct for two-centre bonds, for n-centre bonds the behaviour is undefined and the more correctIBond.getConnectedAtoms(IAtom)
should be used.IBond.Stereo
getStereo()
Returns the stereo descriptor for this query bond.int
hashCode()
boolean
isAromatic()
Access whether this bond has been marked as aromatic.boolean
isConnectedTo(IBond bond)
Checks whether a query bond is connected to another one.boolean
isInRing()
Access whether this bond has been flagged as in a ring.boolean
matches(IBond bond)
Returns true of the givenbond
matches this IQueryBond.void
setAtom(IAtom atom, int position)
Sets an atom in this query bond.void
setAtoms(IAtom[] atoms)
Sets the array of atoms making up this query bond.void
setDisplay(IBond.Display display)
Not used for query bonds.void
setElectronCount(Integer electronCount)
Sets the number of electrons in this bondvoid
setExpression(Expr expr)
Set the bond expression for this query bond.void
setIsAromatic(boolean arom)
Mark this bond as being aromatic.void
setIsInRing(boolean ring)
Mark this bond as being in a ring.void
setOrder(IBond.Order order)
Sets the bond order of this query bond.void
setStereo(IBond.Stereo stereo)
Sets the stereo descriptor for this query bond.String
toString()
Returns a one line string representation of this query bond.-
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
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.openscience.cdk.interfaces.IBond
getConnectedAtom
-
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
-
order
protected IBond.Order order
The bond order of this query bond.
-
atomCount
protected int atomCount
Number of atoms contained by this object.
-
atoms
protected IAtom[] atoms
A list of atoms participating in this query bond.
-
stereo
protected IBond.Stereo stereo
A descriptor the stereochemical orientation of this query bond.
-
electronCount
protected Integer electronCount
Number of electrons in the ElectronContainer.
-
-
Constructor Detail
-
QueryBond
public QueryBond(IAtom beg, IAtom end, Expr expr)
Constructs a query bond from an expression.// pi-bond in a ring Expr e = new Expr(IS_IN_RING); e.and(new Expr(ALIPHATIC_ORDER, 2)); new QueryBond(beg, end, e);
- Parameters:
expr
- the expression
-
QueryBond
public QueryBond(IAtom beg, IAtom end, Expr.Type type)
Constructs a query bond from an expression type.new QueryBond(beg, end, IS_IN_RING);
- Parameters:
type
- the expression type
-
QueryBond
public QueryBond(IAtom beg, IAtom end, Expr.Type type, int val)
Constructs a query bond from an expression type and value.new QueryBond(beg, end, ALIPHATIC_ORDER, 8);
- Parameters:
type
- the expression typeval
- the expression value
-
QueryBond
public QueryBond(IChemObjectBuilder builder)
Constructs an empty query bond.
-
QueryBond
public QueryBond(Expr.Type type, IChemObjectBuilder builder)
Constructs an empty query bond.
-
QueryBond
public QueryBond(IAtom atom1, IAtom atom2, IChemObjectBuilder builder)
Constructs a query bond with a single query bond order..- Parameters:
atom1
- the first Atom in the query bondatom2
- the second Atom in the query bond
-
QueryBond
public QueryBond(IAtom atom1, IAtom atom2, IBond.Order order, IChemObjectBuilder builder)
Constructs a query bond with a given order.- Parameters:
atom1
- the first Atom in the query bondatom2
- the second Atom in the query bondorder
- the query bond order
-
QueryBond
public QueryBond(IAtom[] atoms, IChemObjectBuilder builder)
Constructs a multi-center query bond, with undefined order and no stereo information.- Parameters:
atoms
- An array of IAtom containing the atoms constituting the query bond
-
QueryBond
public QueryBond(IAtom[] atoms, IBond.Order order, IChemObjectBuilder builder)
Constructs a multi-center query bond, with a specified order and no stereo information.- Parameters:
atoms
- An array of IAtom containing the atoms constituting the query bondorder
- The order of the query bond
-
QueryBond
public QueryBond(IAtom atom1, IAtom atom2, IBond.Order order, IBond.Stereo stereo, IChemObjectBuilder builder)
Constructs a query bond with a given order and stereo orientation from an array of atoms.- Parameters:
atom1
- the first Atom in the query bondatom2
- the second Atom in the query bondorder
- the query bond orderstereo
- a descriptor the stereochemical orientation of this query bond
-
-
Method Detail
-
atoms
public Iterable<IAtom> atoms()
Returns the Iterator to atoms making up this query bond. Iterator.remove() is not implemented.- Specified by:
atoms
in interfaceIBond
- Returns:
- An Iterator to atoms participating in this query bond
- See Also:
setAtoms(org.openscience.cdk.interfaces.IAtom[])
-
getContainer
public IAtomContainer getContainer()
- Specified by:
getContainer
in interfaceIBond
-
setAtoms
public void setAtoms(IAtom[] atoms)
Sets the array of atoms making up this query bond.
-
getAtomCount
public int getAtomCount()
Returns the number of Atoms in this Bond.- Specified by:
getAtomCount
in interfaceIBond
- Returns:
- The number of Atoms in this Bond
-
getAtom
public IAtom getAtom(int position)
Returns an Atom from this query bond.- Specified by:
getAtom
in interfaceIBond
- Parameters:
position
- The position in this query bond where the atom is- Returns:
- The atom at the specified position, null if there are no atoms in the query bond
- See Also:
setAtom(org.openscience.cdk.interfaces.IAtom, int)
-
getBegin
public IAtom getBegin()
Access the begin (or first) atom of the bond.
-
getEnd
public IAtom getEnd()
Access the end (or second) atom of the bond.
-
getOther
public IAtom getOther(IAtom atom)
Returns the other atom in the bond, the atom is connected to the given atom.This method is only correct for two-centre bonds, for n-centre bonds the behaviour is undefined and the more correctIBond.getConnectedAtoms(IAtom)
should be used.IAtom beg = bond.getBegin(); IAtom end = bond.getEnd(); // bond.getOther(beg) == end // bond.getOther(end) == beg
-
getConnectedAtom
public IAtom getConnectedAtom(IAtom atom)
Returns the other atom in the bond, the atom is connected to the given atom. This method is only correct for two-centre bonds, for n-centre bonds the behaviour is undefined and the more correctIBond.getConnectedAtoms(IAtom)
should be used.IAtom beg = bond.getBegin(); IAtom end = bond.getEnd(); // bond.getConnectedAtom(beg) == end // bond.getConnectedAtom(end) == beg
- Specified by:
getConnectedAtom
in interfaceIBond
- Parameters:
atom
- The atom the bond partner is searched of- Returns:
- the connected atom or null if the given atom is not part of the bond
-
getConnectedAtoms
public IAtom[] getConnectedAtoms(IAtom atom)
Returns all the atoms in the bond connected to the given atom.- Specified by:
getConnectedAtoms
in interfaceIBond
- Parameters:
atom
- The atoms the bond partner is searched of- Returns:
- the connected atoms or null if the given atom is not part of the bond
-
contains
public boolean contains(IAtom atom)
Returns true if the given atom participates in this query bond.
-
setAtom
public void setAtom(IAtom atom, int position)
Sets an atom in this query bond.- Specified by:
setAtom
in interfaceIBond
- Parameters:
atom
- The atom to be setposition
- The position in this query bond where the atom is to be inserted- See Also:
getAtom(int)
-
getOrder
public IBond.Order getOrder()
Returns the query bond order of this query bond.- Specified by:
getOrder
in interfaceIBond
- Returns:
- The query bond order of this query bond
- See Also:
org.openscience.cdk.CDKConstants for predefined values.
,setOrder(org.openscience.cdk.interfaces.IBond.Order)
-
setOrder
public void setOrder(IBond.Order order)
Sets the bond order of this query bond.- Specified by:
setOrder
in interfaceIBond
- Parameters:
order
- The query bond order to be assigned to this query bond- See Also:
org.openscience.cdk.CDKConstants for predefined values.
,getOrder()
-
getStereo
public IBond.Stereo getStereo()
Returns the stereo descriptor for this query bond.- Specified by:
getStereo
in interfaceIBond
- Returns:
- The stereo descriptor for this query bond
- See Also:
setStereo(org.openscience.cdk.interfaces.IBond.Stereo)
,for predefined values.
-
setStereo
public void setStereo(IBond.Stereo stereo)
Sets the stereo descriptor for this query bond.- Specified by:
setStereo
in interfaceIBond
- Parameters:
stereo
- The stereo descriptor to be assigned to this query bond.- See Also:
getStereo()
,for predefined values.
-
getDisplay
public IBond.Display getDisplay()
Not used for query bonds. Access the bond display style.- Specified by:
getDisplay
in interfaceIBond
- Returns:
- the bond display
-
setDisplay
public void setDisplay(IBond.Display display)
Not used for query bonds. Set the bond display style.- Specified by:
setDisplay
in interfaceIBond
- Parameters:
display
- the display
-
get2DCenter
public javax.vecmath.Point2d get2DCenter()
Returns the geometric 2D center of the query bond.- Specified by:
get2DCenter
in interfaceIBond
- Returns:
- The geometric 2D center of the query bond
-
get3DCenter
public javax.vecmath.Point3d get3DCenter()
Returns the geometric 3D center of the query bond.- Specified by:
get3DCenter
in interfaceIBond
- Returns:
- The geometric 3D center of the query bond
-
compare
public boolean compare(Object object)
Compares a query bond with this query bond.
-
isConnectedTo
public boolean isConnectedTo(IBond bond)
Checks whether a query bond is connected to another one. This can only be true if the query bonds have an Atom in common.- Specified by:
isConnectedTo
in interfaceIBond
- Parameters:
bond
- bond The query bond which is checked to be connect with this one- Returns:
- true if the query bonds share an atom, otherwise false
-
clone
public IQueryBond clone() throws CloneNotSupportedException
Clones this query bond object, including clones of the atoms between which the query bond is defined.- Specified by:
clone
in interfaceIBond
- Specified by:
clone
in interfaceIChemObject
- Overrides:
clone
in classQueryChemObject
- Returns:
- The cloned object
- Throws:
CloneNotSupportedException
- if the IChemObject cannot be cloned
-
toString
public String toString()
Returns a one line string representation of this query bond.- Specified by:
toString
in interfaceIChemObject
- Overrides:
toString
in classObject
- Returns:
- The string representation of this query bond
-
getElectronCount
public Integer getElectronCount()
Returns the number of electrons in this bond- Specified by:
getElectronCount
in interfaceIElectronContainer
- Returns:
- The number of electrons in this electron container.
- See Also:
setElectronCount(java.lang.Integer)
-
isAromatic
public boolean isAromatic()
Access whether this bond has been marked as aromatic. The default value is false and you must explicitly perceive aromaticity with one of the available models.- Specified by:
isAromatic
in interfaceIBond
- Returns:
- aromatic status
- See Also:
IChemObject.getFlag(int)
,Aromaticity
-
setIsAromatic
public void setIsAromatic(boolean arom)
Mark this bond as being aromatic.- Specified by:
setIsAromatic
in interfaceIBond
- Parameters:
arom
- aromatic status- See Also:
IChemObject.setFlag(int, boolean)
-
isInRing
public boolean isInRing()
Access whether this bond has been flagged as in a ring. The default value is false and you must explicitly find rings first.- Specified by:
isInRing
in interfaceIBond
- Returns:
- ring status
- See Also:
IChemObject.getFlag(int)
,RingSearch
-
setIsInRing
public void setIsInRing(boolean ring)
Mark this bond as being in a ring.- Specified by:
setIsInRing
in interfaceIBond
- Parameters:
ring
- ring status- See Also:
IChemObject.setFlag(int, boolean)
-
setElectronCount
public void setElectronCount(Integer electronCount)
Sets the number of electrons in this bond- Specified by:
setElectronCount
in interfaceIElectronContainer
- Parameters:
electronCount
- The number of electrons in this electron container.- See Also:
getElectronCount()
-
getExpression
public Expr getExpression()
Access the bond expression predicate associated with this query bond.- Returns:
- the bond expression
-
setExpression
public void setExpression(Expr expr)
Set the bond expression for this query bond.- Parameters:
expr
- the new bond expression
-
matches
public boolean matches(IBond bond)
Returns true of the givenbond
matches this IQueryBond.- Specified by:
matches
in interfaceIQueryBond
- Parameters:
bond
- IBond to match against- Returns:
- true, if this IQueryBond matches the given IBond
-
-