Class Smirks
- java.lang.Object
-
- org.openscience.cdk.smirks.Smirks
-
public class Smirks extends Object
Support for parsing a SMIRKS transform and utilities to parse/apply in one step.if (Smirks.apply(mol, "[*:1][H]>>[*:1]Cl")) { System.err.println("Success!"); }
If the SMIRKS is invalid a runtime exception is thrown. If you expect to be processing possibly invalid inputs consider using the more verbose
parse(org.openscience.cdk.isomorphism.Transform, String)
function and apply it separately. Note you can parse in either the low-levelTransform
or the higher-levelSmirksTransform
.Transform transform = new SmirksTransform(); if (!Smirks.parse(transform, "[*:1][H]>>[*:1]Cl")) System.err.println("BAD SMIRKS: " + transform.message()); IAtomContainer mol = ...; transform.apply(mol);
- See Also:
Transform
,SmirksTransform
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
apply(IAtomContainer mol, String smirks)
Convenience function to compile and apply a SMIRKS string on a molecule to all non-overlapping (exclusive) matches.static Iterable<IAtomContainer>
apply(IAtomContainer mol, String smirks, Transform.Mode mode)
Convenience function to compile and apply a SMIRKS string on a copy of the molecule returning the places the transform matched and applied.static SmirksTransform
compile(String smirks)
Convenience function to compile a SMIRKS string into a transform.static boolean
parse(Transform transform, String smirks)
Parse a SMIRKS string into a transform.static boolean
parse(Transform transform, String smirks, Set<SmirksOption> options)
Parse a SMIRKS string into a transform.static boolean
parse(Transform transform, String smirks, SmirksOption... options)
Parse a SMIRKS string into a transform.
-
-
-
Method Detail
-
compile
public static SmirksTransform compile(String smirks)
Convenience function to compile a SMIRKS string into a transform.Smirks.compile("[*:1][H]>>[*:1]Cl") .apply(mol);
If the SMIRKS is invalid a runtime exception is thrown. If you expect to be processing possibly invalid inputs consider using the more verbose
parse(org.openscience.cdk.isomorphism.Transform, String)
function.- Parameters:
smirks
- the SMIRKS string- Returns:
- a SmirksTransform
-
apply
public static boolean apply(IAtomContainer mol, String smirks)
Convenience function to compile and apply a SMIRKS string on a molecule to all non-overlapping (exclusive) matches.if (Smirks.apply(mol, "[*:1][H]>>[*:1]Cl")) { System.err.println("Success!"); }
If the SMIRKS is invalid a runtime exception is thrown. If you expect to be processing possibly invalid inputs consider using the more verbose
parse(org.openscience.cdk.isomorphism.Transform, String)
function and apply it separately.- Parameters:
mol
- the molecule to apply the SMIRKS tosmirks
- the SMIRKS string- Returns:
- the pattern was applied or not
- See Also:
Transform.apply(org.openscience.cdk.interfaces.IAtomContainer)
-
apply
public static Iterable<IAtomContainer> apply(IAtomContainer mol, String smirks, Transform.Mode mode)
Convenience function to compile and apply a SMIRKS string on a copy of the molecule returning the places the transform matched and applied.for (IAtomContainer res : Smirks.apply(mol, "[*:1][H]>>[*:1]Cl")) { // ... further process result molecule }
If the SMIRKS is invalid a runtime exception is thrown. If you expect to be processing possibly invalid inputs consider using the more verbose
parse(org.openscience.cdk.isomorphism.Transform, String)
function and apply it separately.- Parameters:
mol
- the molecule to apply the SMIRKS tosmirks
- the SMIRKS string- Returns:
- the pattern was applied or not
- See Also:
Transform.apply(org.openscience.cdk.interfaces.IAtomContainer, org.openscience.cdk.isomorphism.Transform.Mode)
-
parse
public static boolean parse(Transform transform, String smirks, Set<SmirksOption> options)
Parse a SMIRKS string into a transform.Transform transform = new SmirksTransform(); if (!Smirks.parse(transform, "[*:1][H]>>[*:1]Cl")) { System.err.println("BAD SMIRKS: " + transform.message()); return; } IAtomContainer mol = ...; transform.apply(mol);
If the SMIRKS could not be interpreted or was invalid this method returns false and sets the transform into an error state meaning calling
apply()
will do nothing. TheTransform.message()
may still be set if there were warnings generated when interpreting the SMIRKS.- Parameters:
transform
- the transform to load intosmirks
- the SMIRKS stringoptions
- options for parsing a SMIRKS- Returns:
- the SMIRKS interpretable or not (there was an error)
- See Also:
Transform
,SmirksTransform
-
parse
public static boolean parse(Transform transform, String smirks, SmirksOption... options)
Parse a SMIRKS string into a transform.Transform transform = new SmirksTransform(); if (!Smirks.parse(transform, "[*:1][H]>>[*:1]Cl")) { System.err.println("BAD SMIRKS: " + transform.message()); return; } IAtomContainer mol = ...; transform.apply(mol);
If the SMIRKS could not be interpreted or was invalid this method returns false and sets the transform into an error state meaning calling
apply()
will do nothing. TheTransform.message()
may still be set if there were warnings generated when interpreting the SMIRKS.- Parameters:
transform
- the transform to load intosmirks
- the SMIRKS stringoptions
- options for parsing a SMIRKS- Returns:
- the SMIRKS interpretable or not (there was an error)
- See Also:
Transform
,SmirksTransform
-
parse
public static boolean parse(Transform transform, String smirks)
Parse a SMIRKS string into a transform.Transform transform = new SmirksTransform(); if (!Smirks.parse(transform, "[*:1][H]>>[*:1]Cl")) { System.err.println("BAD SMIRKS: " + transform.message()); return; } IAtomContainer mol = ...; transform.apply(mol);
If the SMIRKS could not be interpreted or was invalid this method returns false and sets the transform into an error state meaning calling
apply()
will do nothing. TheTransform.message()
may still be set if there were warnings generated when interpreting the SMIRKS.- Parameters:
transform
- the transform to load intosmirks
- the SMIRKS string- Returns:
- the SMIRKS interpretable or not (there was an error)
- See Also:
Transform
,SmirksTransform
-
-