Package org.openscience.cdk.interfaces
Interface IChemObject
- All Superinterfaces:
Cloneable,ICDKObject
- All Known Subinterfaces:
IAminoAcid,IAtom,IAtomContainer,IAtomContainerSet,IAtomType,IBioPolymer,IBond,IChemFile,IChemModel,IChemSequence,ICrystal,IElectronContainer,IElement,IFragmentAtom,IIsotope,ILonePair,IMapping,IMonomer,IPDBAtom,IPDBMonomer,IPDBPolymer,IPolymer,IPseudoAtom,IQueryAtom,IQueryAtomContainer,IQueryBond,IReaction,IReactionScheme,IReactionSet,IRGroupQuery,IRing,IRingSet,ISingleElectron,IStrand,ISubstance
- All Known Implementing Classes:
AliphaticAtom,AliphaticSymbolAtom,AminoAcid,AminoAcid,AnyAtom,AnyOrderQueryBond,AromaticAtom,AromaticOrSingleQueryBond,AromaticQueryBond,AromaticSymbolAtom,Association,Atom,Atom,AtomContainer,AtomContainer,AtomContainerLegacy,AtomContainerLegacy,AtomContainerSet,AtomContainerSet,AtomicNumberAtom,AtomRef,AtomType,AtomType,BioPolymer,BioPolymer,Bond,Bond,BondRef,ChargeGroup,ChemFile,ChemFile,ChemModel,ChemModel,ChemObject,ChemObject,ChemSequence,ChemSequence,ChiralityAtom,Crystal,Crystal,CTFileQueryBond,DebugAminoAcid,DebugAtom,DebugAtomContainer,DebugAtomContainerSet,DebugAtomType,DebugBioPolymer,DebugBond,DebugChemFile,DebugChemModel,DebugChemObject,DebugChemSequence,DebugCrystal,DebugElectronContainer,DebugElement,DebugFragmentAtom,DebugIsotope,DebugLonePair,DebugMapping,DebugMonomer,DebugPDBAtom,DebugPDBMonomer,DebugPDBPolymer,DebugPDBStructure,DebugPolymer,DebugPseudoAtom,DebugReaction,DebugReactionScheme,DebugReactionSet,DebugRing,DebugRingSet,DebugSingleElectron,DebugStrand,DebugSubstance,ElectronContainer,ElectronContainer,Element,Element,EnzymeResidueLocator,ExplicitConnectionAtom,FormalChargeAtom,FragmentAtom,FragmentAtom,HybridizationNumberAtom,HydrogenAtom,ImplicitHCountAtom,InverseSymbolSetQueryAtom,Isotope,Isotope,LogicalOperatorAtom,LogicalOperatorBond,LonePair,LonePair,Mapping,Mapping,MassAtom,MDMolecule,Monomer,Monomer,NonCHHeavyAtom,OrderQueryBond,OrderQueryBond,OrderQueryBondOrderOnly,PDBAtom,PDBAtom,PDBMonomer,PDBMonomer,PDBPolymer,PDBPolymer,PDBStrand,PDBStructure,PDBStructure,PeriodicGroupNumberAtom,PharmacophoreAngleBond,PharmacophoreAtom,PharmacophoreBond,PharmacophoreQuery,PharmacophoreQueryAngleBond,PharmacophoreQueryAtom,PharmacophoreQueryBond,Polymer,Polymer,PseudoAtom,PseudoAtom,QueryAtom,QueryAtomContainer,QueryBond,QueryChemObject,Reaction,Reaction,ReactionChain,ReactionRoleQueryAtom,ReactionScheme,ReactionScheme,ReactionSet,ReactionSet,RecursiveSmartsAtom,Residue,RGroupQuery,Ring,Ring,RingBond,RingIdentifierAtom,RingMembershipAtom,RingSet,RingSet,SingleElectron,SingleElectron,SmallestRingAtom,SMARTSAtom,SMARTSBond,StereoBond,Strand,Strand,Substance,Substance,SymbolAndChargeQueryAtom,SymbolChargeIDQueryAtom,SymbolQueryAtom,SymbolSetQueryAtom,TotalConnectionAtom,TotalHCountAtom,TotalRingConnectionAtom,TotalValencyAtom
The base class for all chemical objects in this cdk. It provides methods for
adding listeners and for their notification of events, as well a a hash
table for administration of physical or chemical properties
- Author:
- egonw
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intFlag that is set if a ChemObject is part of an aliphatic chain.static final intFlag is set if ChemObject is part of an aromatic system.static final intFlag is set if ChemObject is part of a conjugated system.static final intSets to true if the atom is a hydrogen bond acceptor.static final intSets to true if the atom is a hydrogen bond donor.static final intFlag that is set when the ChemObject is part of a ring.static final intFlag is set if a ChemObject is mapped to another ChemObject.static final intFlag to indicate a flattened molecule holds a Markush structure, you can work on it as is or it might make more sense to repack into something sensible like a RGroupQuery.static final intFlag that is set when the ChemObject is part of a ring.static final intFlag that is set if the ChemObject is placed when calculating 2D/3D layouts.static final intFlag is set if a ChemObject has reactive center.static final intFlag used for marking uncertainty of the bond order.static final intFlag is set if an atom could be typed.static final intFlag is set if ChemObject has been visited. -
Method Summary
Modifier and TypeMethodDescriptionvoidUse this to add yourself to this IChemObject as a listener.voidaddProperties(Map<Object, Object> properties) Add properties to this object, duplicate keys will replace any existing value.voidclear(int flags) Clear the provided flags.clone()Returns a deep clone of this IChemObject.intflags()Access the current value of the flags for this ChemObject.booleangetFlag(int mask) Returns the value of a given flag.boolean[]getFlags()Returns the whole set of flags.Deprecated.getID()Returns the identifier (ID) of this object.intReturns the number of ChemObjectListeners registered with this object.booleanReturns the flag that indicates whether notification messages are sent around.Returns a Map with the IChemObject's properties.<T> TgetProperty(Object description) Returns a property for the IChemObject - the object is automatically cast to the required type.<T> TgetProperty(Object description, Class<T> c) Access a property of the given description and cast the specified class.booleanis(int flags) Test if a flag(s) are set on this ChemObject.voidThis should be triggered by an method that changes the content of an object to that the registered listeners can react to it.voidThis should be triggered by an method that changes the content of an object to that the registered listeners can react to it.voidUse this to remove a ChemObjectListener from the ListenerList of this IChemObject.voidremoveProperty(Object description) Removes a property for a IChemObject.voidset(int flags) Set the provided flags.voidsetFlag(int mask, boolean value) Sets the value of some flag.voidsetFlags(boolean[] newFlags) Sets the whole set of flags.voidSets the identifier (ID) of this object.voidsetNotification(boolean bool) Set a flag to use or not use notification.voidsetProperties(Map<Object, Object> properties) Set the properties of this object to the provided map (shallow copy).voidsetProperty(Object description, Object property) Sets a property for a IChemObject.toString()Returns a one line description of this IChemObject.Methods inherited from interface org.openscience.cdk.interfaces.ICDKObject
getBuilder
-
Field Details
-
PLACED
static final int PLACEDFlag that is set if the ChemObject is placed when calculating 2D/3D layouts.- See Also:
-
IN_RING
static final int IN_RINGFlag that is set when the ChemObject is part of a ring.- See Also:
-
NOT_IN_RING
static final int NOT_IN_RINGFlag that is set when the ChemObject is part of a ring. Note !isInRing() is preferred.- See Also:
-
ALIPHATIC
static final int ALIPHATICFlag that is set if a ChemObject is part of an aliphatic chain. Since normally ALIPHATIC = !AROMATIC and AROMATIC = !ALIPHATIC.- See Also:
-
VISITED
static final int VISITEDFlag is set if ChemObject has been visited.- See Also:
-
AROMATIC
static final int AROMATICFlag is set if ChemObject is part of an aromatic system.- See Also:
-
CONJUGATED
static final int CONJUGATEDFlag is set if ChemObject is part of a conjugated system.- See Also:
-
MAPPED
static final int MAPPEDFlag is set if a ChemObject is mapped to another ChemObject. It is used for example in subgraph isomorphism search. Note this flag is not currently used.- See Also:
-
HYDROGEN_BOND_DONOR
static final int HYDROGEN_BOND_DONORSets to true if the atom is a hydrogen bond donor.- See Also:
-
HYDROGEN_BOND_ACCEPTOR
static final int HYDROGEN_BOND_ACCEPTORSets to true if the atom is a hydrogen bond acceptor.- See Also:
-
REACTIVE_CENTER
static final int REACTIVE_CENTERFlag is set if a ChemObject has reactive center. It is used for example in reaction.- See Also:
-
TYPEABLE
static final int TYPEABLEFlag is set if an atom could be typed.- See Also:
-
SINGLE_OR_DOUBLE
static final int SINGLE_OR_DOUBLEFlag used for marking uncertainty of the bond order. If used on anIAtomContainerit means that one or several of the bonds have this flag raised (which may indicate aromaticity).IBondit means that it's unclear whether the bond is a single or double bond.IAtomit is a way for the Smiles parser to indicate that this atom was written with a lower case letter, e.g. 'c' rather than 'C'
- See Also:
-
MARKUSH
static final int MARKUSHFlag to indicate a flattened molecule holds a Markush structure, you can work on it as is or it might make more sense to repack into something sensible like a RGroupQuery.- See Also:
-
-
Method Details
-
addListener
Use this to add yourself to this IChemObject as a listener. In order to do so, you must implement the ChemObjectListener Interface.- Parameters:
col- the ChemObjectListener- See Also:
-
getListenerCount
int getListenerCount()Returns the number of ChemObjectListeners registered with this object.- Returns:
- the number of registered listeners.
-
removeListener
Use this to remove a ChemObjectListener from the ListenerList of this IChemObject. It will then not be notified of change in this object anymore.- Parameters:
col- The ChemObjectListener to be removed- See Also:
-
setNotification
void setNotification(boolean bool) Set a flag to use or not use notification. By default it should be set to true.- Parameters:
bool- if true, then notification messages are sent.- See Also:
-
getNotification
boolean getNotification()Returns the flag that indicates whether notification messages are sent around.- Returns:
- true if messages are sent.
- See Also:
-
notifyChanged
void notifyChanged()This should be triggered by an method that changes the content of an object to that the registered listeners can react to it. -
notifyChanged
This should be triggered by an method that changes the content of an object to that the registered listeners can react to it. This is a version of notifyChanged() which allows to propagate a change event while preserving the original origin.- Parameters:
evt- A ChemObjectChangeEvent pointing to the source of where the change happend
-
setProperty
Sets a property for a IChemObject.- Parameters:
description- An object description of the property (most likely a unique string)property- An object with the property itself- See Also:
-
removeProperty
Removes a property for a IChemObject.- Parameters:
description- The object description of the property (most likely a unique string)- See Also:
-
getProperty
Returns a property for the IChemObject - the object is automatically cast to the required type. This does however mean if the wrong type is provided then a runtime ClassCastException will be thrown.IAtom atom = new Atom("C"); atom.setProperty("number", 1); // set an integer property // access the property and automatically cast to an int Integer number = atom.getProperty("number"); // if the method is in a chain or needs to be nested the type // can be provided methodAcceptingInt(atom.getProperty("number", Integer.class)); // the type cannot be checked and so... String number = atom.getProperty("number"); // ClassCastException // if the type is provided a more meaningful error is thrown atom.getProperty("number", String.class); // IllegalArgumentException- Type Parameters:
T- generic return type- Parameters:
description- An object description of the property (most likely a unique string)- Returns:
- The object containing the property. Returns null if property is not set.
- See Also:
-
getProperty
Access a property of the given description and cast the specified class.IAtom atom = new Atom("C"); atom.setProperty("number", 1); // set an integer property // access the property and automatically cast to an int Integer number = atom.getProperty("number"); // if the method is in a chain or needs to be nested the type // can be provided methodAcceptingInt(atom.getProperty("number", Integer.class)); // the type cannot be checked and so... String number = atom.getProperty("number"); // ClassCastException // if the type is provided a more meaningful error is thrown atom.getProperty("number", String.class); // IllegalArgumentException- Type Parameters:
T- generic type (of provided class)- Parameters:
description- description of a property (normally a string)c- type of the value to be returned- Returns:
- the value stored for the specified description.
- See Also:
-
getProperties
Returns a Map with the IChemObject's properties.- Returns:
- The object's properties as an Map
- See Also:
-
getID
String getID()Returns the identifier (ID) of this object.- Returns:
- a String representing the ID value
- See Also:
-
setID
Sets the identifier (ID) of this object.- Parameters:
identifier- a String representing the ID value- See Also:
-
setFlag
void setFlag(int mask, boolean value) Sets the value of some flag. The flag is a mask from a given CDKConstant (e.g.AROMATICorVISITED). The flags are intrinsic internal properties and should not be used to store custom values, please usesetProperty(Object, Object).// set this chem object to be aromatic chemObject.setFlag(CDKConstants.ISAROMATIC, Boolean.TRUE); // ... // indicate we have visited this chem object chemObject.setFlag(CDKConstants.VISITED, Boolean.TRUE);- Parameters:
mask- flag to set the value forvalue- value to assign to flag- See Also:
-
getFlag
boolean getFlag(int mask) Returns the value of a given flag. The flag is a mask from a given CDKConstant (e.g.AROMATIC).if(chemObject.getFlag(CDKConstants.ISAROMATIC)){ // handle aromatic flag on this chem object }- Parameters:
mask- flag to retrieve the value of- Returns:
- true if the flag
flag_typeis set - See Also:
-
setProperties
Set the properties of this object to the provided map (shallow copy). Any existing properties are removed.- Parameters:
properties- map key-value pairs
-
addProperties
Add properties to this object, duplicate keys will replace any existing value.- Parameters:
properties- a Map specifying the property values- See Also:
-
setFlags
void setFlags(boolean[] newFlags) Sets the whole set of flags. This set will iteratively invokesetFlag(int, boolean)for each value in the array and useCDKConstants.FLAG_MASKSto look up the correct mask. If only a single flag is being set it is a lot faster to usesetFlag(int, boolean).- Parameters:
newFlags- the new flags to set.- See Also:
-
getFlags
boolean[] getFlags()Returns the whole set of flags. This method will create a new array on each invocation and it is recommend you usegetFlagValue()if you need all the flags. For individual flags please usegetFlag(int)- Returns:
- the flags.
- See Also:
-
getFlagValue
Deprecated.usedflags()Access the internal value used to store the flags. The flags are stored on a single numeric value and are set/cleared.- Returns:
- numeric representation of the flags
-
set
void set(int flags) Set the provided flags. Any on-bits in the input parameter are set on in the ChemObject.- Parameters:
flags- the flags
-
clear
void clear(int flags) Clear the provided flags. Any on-bits in the input parameter are set on in the ChemObject.- Parameters:
flags- the flags
-
is
boolean is(int flags) Test if a flag(s) are set on this ChemObject. If multiple flags are provided they must all be set to return true.atom.set(IS_IN_RING); atom.is(IS_IN_RING); // false! atom.is(IS_IN_RING+IS_AROMATIC); // false! atom.set(IS_AROMATIC); atom.is(IS_IN_RING+IS_AROMATIC); // true!- Parameters:
flags- the flags
-
flags
int flags()Access the current value of the flags for this ChemObject.- Returns:
- the flag value (32-bit integer)
-
toString
String toString()Returns a one line description of this IChemObject. -
clone
Returns a deep clone of this IChemObject.- Returns:
- Object the clone of this IChemObject.
- Throws:
CloneNotSupportedException- if the IChemObject cannot be cloned
-
flags()