public class DfPattern extends Pattern
DfPattern ptrn = DfPattern.findSubstructure(query);
// has match?
if (ptrn.matches(mol)) {
}
// get lazy mapping iterator
Mappings mappings = ptrn.matchAll(mol);
for (int[] amap : mappings) {
}
// test if pattern matches at a given atom
for (IAtom atom : mol.atoms()) {
if (ptrn.matchesRoot(atom)) {
}
}
References
Modifier and Type | Method and Description |
---|---|
static DfPattern |
findSubstructure(IAtomContainer query)
Create a pattern which can be used to find molecules which contain the
query structure. |
int[] |
match(IAtomContainer target)
Find a matching of this pattern in the
target . |
Mappings |
matchAll(IAtomContainer mol)
Find all mappings of this pattern in the
target . |
boolean |
matches(IAtomContainer target)
Determine if there is a mapping of this pattern in the
target . |
boolean |
matchesRoot(IAtom root)
Test whether the pattern matches at the provided atom.
|
findIdentical, matchAll, matches
public int[] match(IAtomContainer target)
target
. 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! } }
public boolean matches(IAtomContainer target)
target
.
Depending on the implementation stereochemistry may be checked
(recommended).
Pattern pattern = ...; // create pattern for (IAtomContainer m : ms) { if (pattern.matches(m)) { // found mapping! } }
public Mappings matchAll(IAtomContainer mol)
target
. Stereochemistry
should not be checked to allow filtering with Mappings.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();
public boolean matchesRoot(IAtom root)
root
- the root atom of the moleculepublic static DfPattern findSubstructure(IAtomContainer query)
query
structure. If a 'real' molecule is provided is is converted
with QueryAtomContainer.create(IAtomContainer, Expr.Type...)
matching elements, aromaticity status, and bond orders.query
- the substructure to findquery
QueryAtomContainer.create(IAtomContainer, Expr.Type...)
Copyright © 2022. All rights reserved.