Class ReactionManipulator
- java.lang.Object
-
- org.openscience.cdk.tools.manipulator.ReactionManipulator
-
public class ReactionManipulator extends Object
Provides a variety of methods to manipulate and convert from/toIReaction
.- Author:
- uli-f
- See Also:
ChemModelManipulator
- Source code:
- main
- Belongs to CDK module:
- standard
-
-
Constructor Summary
Constructors Constructor Description ReactionManipulator()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
clearAtomConfigurations(IReaction reaction)
This method will reset all atom properties related to atom configuration to the valueCDKConstants.UNSET
.static Set<IBond>
findMappedBonds(IReaction reaction)
Collect the set of bonds that mapped in both a reactant and a product.static IAtomContainerSet
getAllAgents(IReaction reaction)
Returns all agents of anIReaction
.static List<IAtomContainer>
getAllAtomContainers(IReaction reaction)
Returns allIAtomContainers
of the given reaction.static List<IChemObject>
getAllChemObjects(IReaction reaction)
static List<String>
getAllIDs(IReaction reaction)
static IAtomContainerSet
getAllMolecules(IReaction reaction)
Returns all components of anIReaction
, that is, reactants, agents and products.static IAtomContainerSet
getAllProducts(IReaction reaction)
Returns all products of anIReaction
.static IAtomContainerSet
getAllReactants(IReaction reaction)
Returns all reactants of anIReaction
.static int
getAtomCount(IReaction reaction)
Returns the total number of atoms for all components of the givenreaction
.static int
getBondCount(IReaction reaction)
Returns the total number of atoms for all components of the givenreaction
.static IChemObject
getMappedChemObject(IReaction reaction, IChemObject chemObject)
Returns theIAtom
that is mapped.static IAtomContainer
getRelevantAtomContainer(IReaction reaction, IAtom atom)
static IAtomContainer
getRelevantAtomContainer(IReaction reaction, IBond bond)
static void
perceiveAtomTypesAndConfigureAtoms(IReaction reaction)
static void
perceiveAtomTypesAndConfigureUnsetProperties(IReaction reaction)
static void
removeAtomAndConnectedElectronContainers(IReaction reaction, IAtom atom)
Removes the providedatom
and its connected electron containers from the reaction.static void
removeElectronContainer(IReaction reaction, IElectronContainer electrons)
Removes the providedelectrons
from the reaction.static IReaction
reverse(IReaction reaction)
Returns a newIReaction
which is the reverse of the given reaction.static void
setAtomProperties(IReaction reaction, Object propKey, Object propVal)
static IAtomContainer
toMolecule(IReaction rxn)
Converts a reaction to an 'inlined' reaction stored as a molecule.static IReaction
toReaction(IAtomContainer mol)
Converts an 'inlined' reaction stored in a molecule back to a reaction.
-
-
-
Method Detail
-
getAtomCount
public static int getAtomCount(IReaction reaction)
Returns the total number of atoms for all components of the givenreaction
.- Parameters:
reaction
- the number of atoms is summed up for all components of this reaction- Returns:
- total number of atoms for all
IAtomContainer
that are part of this reaction
-
getBondCount
public static int getBondCount(IReaction reaction)
Returns the total number of atoms for all components of the givenreaction
.- Parameters:
reaction
- the number of atoms is summed up for all components of this reaction- Returns:
- total number of atoms for all
IAtomContainer
that are part of this reaction
-
removeAtomAndConnectedElectronContainers
public static void removeAtomAndConnectedElectronContainers(IReaction reaction, IAtom atom)
Removes the providedatom
and its connected electron containers from the reaction.- Parameters:
reaction
- reaction the atom is removed fromatom
- atom that is removed
-
removeElectronContainer
public static void removeElectronContainer(IReaction reaction, IElectronContainer electrons)
Removes the providedelectrons
from the reaction.- Parameters:
reaction
- reaction the electron container is removed fromelectrons
- electron container that is removed
-
getAllMolecules
public static IAtomContainerSet getAllMolecules(IReaction reaction)
Returns all components of anIReaction
, that is, reactants, agents and products.- Parameters:
reaction
- all components of this reaction are returned- Returns:
- IAtomContainerSet containing all components of the reaction provided as an argument
-
getAllProducts
public static IAtomContainerSet getAllProducts(IReaction reaction)
Returns all products of anIReaction
.- Parameters:
reaction
- all products of this reaction are returned- Returns:
- IAtomContainerSet containing all products of the reaction provided as an argument
-
getAllReactants
public static IAtomContainerSet getAllReactants(IReaction reaction)
Returns all reactants of anIReaction
.- Parameters:
reaction
- all reactants of this reaction are returned- Returns:
- IAtomContainerSet containing all reactants of the reaction provided as an argument
-
getAllAgents
public static IAtomContainerSet getAllAgents(IReaction reaction)
Returns all agents of anIReaction
.- Parameters:
reaction
- all agents of this reaction are returned- Returns:
- IAtomContainerSet containing all agents of the reaction provided as an argument
-
reverse
public static IReaction reverse(IReaction reaction)
Returns a newIReaction
which is the reverse of the given reaction. TheIAtomContainer
s of the reversed reaction that is returned are the same that are part of thereaction
provided as an argument.- Parameters:
reaction
- the reaction being considered- Returns:
- the reverse reaction
-
getAllAtomContainers
public static List<IAtomContainer> getAllAtomContainers(IReaction reaction)
Returns allIAtomContainers
of the given reaction.- Parameters:
reaction
- the reaction whoseIAtomContainers
are returned- Returns:
- list of
IAtomContainers
comprising the reaction
-
getRelevantAtomContainer
public static IAtomContainer getRelevantAtomContainer(IReaction reaction, IAtom atom)
-
getRelevantAtomContainer
public static IAtomContainer getRelevantAtomContainer(IReaction reaction, IBond bond)
-
setAtomProperties
public static void setAtomProperties(IReaction reaction, Object propKey, Object propVal)
-
getAllChemObjects
public static List<IChemObject> getAllChemObjects(IReaction reaction)
-
getMappedChemObject
public static IChemObject getMappedChemObject(IReaction reaction, IChemObject chemObject)
Returns theIAtom
that is mapped.- Parameters:
reaction
- reaction that contains the mappingchemObject
- IChemObject which will be searched for the mapped IChemObject- Returns:
- mapped IChemObject
-
toMolecule
public static IAtomContainer toMolecule(IReaction rxn)
Converts a reaction to an 'inlined' reaction stored as a molecule.All reactants, agents, products are added to the molecule as disconnected components with atoms flagged as to their role
ReactionRole
and component group.The inlined reaction, stored in a molecule can be converted back to an explicit reaction with
toReaction(org.openscience.cdk.interfaces.IAtomContainer)
. Data stored on the individual components (e.g. titles is lost in the conversion).- Parameters:
rxn
- reaction to convert- Returns:
- inlined reaction stored in a molecule
- See Also:
toReaction(org.openscience.cdk.interfaces.IAtomContainer)
-
toReaction
public static IReaction toReaction(IAtomContainer mol)
Converts an 'inlined' reaction stored in a molecule back to a reaction.- Parameters:
mol
- molecule to convert- Returns:
- reaction
- See Also:
toMolecule(IReaction)
-
findMappedBonds
public static Set<IBond> findMappedBonds(IReaction reaction)
Collect the set of bonds that mapped in both a reactant and a product. The method uses theCDKConstants.ATOM_ATOM_MAPPING
property of atoms.- Parameters:
reaction
- reaction- Returns:
- mapped bonds
-
perceiveAtomTypesAndConfigureAtoms
public static void perceiveAtomTypesAndConfigureAtoms(IReaction reaction) throws CDKException
Convenience method to perceive atom types for allIAtoms
of all components of the providedIReaction
. This method uses theCDKAtomTypeMatcher
. If the matcher finds a matching atom type, theIAtom
will be configured to have the same properties as theIAtomType
. If no matching atom type is found, no configuration is performed.
This method overwrites existing values.- Parameters:
reaction
- the reaction whose atom types are to be perceived- Throws:
CDKException
- thrown if an error is encountered when finding matching atom types- See Also:
AtomTypeManipulator.configure(IAtom, IAtomType)
-
perceiveAtomTypesAndConfigureUnsetProperties
public static void perceiveAtomTypesAndConfigureUnsetProperties(IReaction reaction) throws CDKException
Convenience method to perceive atom types for allIAtoms
of all components of the providedIReaction
. This method uses theCDKAtomTypeMatcher
. If the matcher finds a matching atom type, theIAtom
will be configured to have the same properties as theIAtomType
. If no matching atom type is found, no configuration is performed.
This method only setsnull
values.- Parameters:
reaction
- the reaction whose atom types are to be perceived- Throws:
CDKException
- thrown if an error is encountered when finding matching atom types- See Also:
AtomTypeManipulator.configureUnsetProperties(IAtom, IAtomType)
-
clearAtomConfigurations
public static void clearAtomConfigurations(IReaction reaction)
This method will reset all atom properties related to atom configuration to the valueCDKConstants.UNSET
.
This method reverses most of the effects ofperceiveAtomTypesAndConfigureAtoms(org.openscience.cdk.interfaces.IReaction)
and after a call to this method all atoms will be "unconfigured".
Note that this method is not a complete reversal ofperceiveAtomTypesAndConfigureAtoms(org.openscience.cdk.interfaces.IReaction)
since the atomic symbol of the atoms remain unchanged. Also, all flags that were set by the configuration method (such asCDKConstants.IS_HYDROGENBOND_ACCEPTOR
orCDKConstants.ISAROMATIC
) will be set to False.- Parameters:
reaction
- the reaction whose atoms confiuration properties are to be cleared- See Also:
perceiveAtomTypesAndConfigureAtoms(org.openscience.cdk.interfaces.IReaction)
-
-