Package org.openscience.cdk.isomorphism
Class Pattern
- java.lang.Object
-
- org.openscience.cdk.isomorphism.Pattern
-
- Direct Known Subclasses:
DfPattern
,SmartsPattern
,SmartsPattern
,Ullmann
,VentoFoggia
public abstract class Pattern extends Object
A structural pattern for finding an exact matching in a target compound.- Author:
- John May
- Belongs to CDK module:
- isomorphism
-
-
Constructor Summary
Constructors Constructor Description Pattern()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static Pattern
findIdentical(IAtomContainer query)
Create a pattern which can be used to find molecules which are the same as thequery
structure.static Pattern
findSubstructure(IAtomContainer query)
Create a pattern which can be used to find molecules which contain thequery
structure.abstract int[]
match(IAtomContainer target)
Find a matching of this pattern in thetarget
.abstract Mappings
matchAll(IAtomContainer target)
Find all mappings of this pattern in thetarget
.Mappings
matchAll(IReaction target)
Find all mappings of this pattern in thetarget
reaction.boolean
matches(IAtomContainer target)
Determine if there is a mapping of this pattern in thetarget
.boolean
matches(IReaction target)
Determine if there is a mapping of this pattern in thetarget
reaction.
-
-
-
Method Detail
-
match
public abstract int[] match(IAtomContainer target)
Find a matching of this pattern in thetarget
. If no such order exist an empty mapping is returned. Depending on the implementation stereochemistry may be checked (recommended).Pattern pattern = ...; // create pattern for (IAtomContainer m : ms) { int[] mapping = pattern.match(m); if (mapping.length > 0) { // found mapping! } }
- Parameters:
target
- the container to search for the pattern in- Returns:
- the mapping from the pattern to the target or an empty array
-
matches
public boolean matches(IAtomContainer target)
Determine if there is a mapping of this pattern in thetarget
. Depending on the implementation stereochemistry may be checked (recommended).Pattern pattern = ...; // create pattern for (IAtomContainer m : ms) { if (pattern.matches(m)) { // found mapping! } }
- Parameters:
target
- the container to search for the pattern in- Returns:
- the mapping from the pattern to the target
-
matches
public final boolean matches(IReaction target)
Determine if there is a mapping of this pattern in thetarget
reaction.Pattern pattern = ...; // create pattern for (IReaction r : rs) { if (pattern.matches(r)) { // found mapping! } }
- Parameters:
target
- the reaction to search for the pattern in- Returns:
- the mapping from the pattern to the target
-
matchAll
public abstract Mappings matchAll(IAtomContainer target)
Find all mappings of this pattern in thetarget
. Stereochemistry should not be checked to allow filtering withMappings.stereochemistry()
.
Using the fluent interface (seePattern pattern = Pattern.findSubstructure(query); for (IAtomContainer m : ms) { for (int[] mapping : pattern.matchAll(m)) { // found mapping } }
Mappings
) we can search and manipulate the mappings. Here's an example of finding the first 5 mappings and creating an array. If the mapper is lazy other states are simply not explored.// find only the first 5 mappings and store them in an array Pattern pattern = Pattern.findSubstructure(query); int[][] mappings = pattern.matchAll(target) .limit(5) .toArray();
- Parameters:
target
- the container to search for the pattern in- Returns:
- the mapping from the pattern to the target
- See Also:
Mappings
-
matchAll
public final Mappings matchAll(IReaction target)
Find all mappings of this pattern in thetarget
reaction.
The reaction is inlined into a molecule and vs mapped id's correspond to the absolute atom index in the reaction when considered as reactants, agents, productsPattern pattern = Pattern.findSubstructure(query); for (IReaction r : rs) { for (int[] mapping : pattern.matchAll(r)) { // found mapping } }
ReactionManipulator.toMolecule(org.openscience.cdk.interfaces.IReaction)
.- Parameters:
target
- the reaction to search for the pattern in- Returns:
- the mapping from the pattern to the target
- See Also:
Mappings
,ReactionManipulator.toMolecule(IReaction)
-
findSubstructure
public static Pattern findSubstructure(IAtomContainer query)
Create a pattern which can be used to find molecules which contain thequery
structure. The default structure search implementation isVentoFoggia
.- Parameters:
query
- the substructure to find- Returns:
- a pattern for finding the
query
- See Also:
VentoFoggia
-
findIdentical
public static Pattern findIdentical(IAtomContainer query)
Create a pattern which can be used to find molecules which are the same as thequery
structure. The default structure search implementation isVentoFoggia
.- Parameters:
query
- the substructure to find- Returns:
- a pattern for finding the
query
- See Also:
VentoFoggia
-
-