Class 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-level Transform or the higher-level SmirksTransform.

     
     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 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 to
        smirks - the SMIRKS string
        Returns:
        the pattern was applied or not
        See Also:
        Transform.apply(org.openscience.cdk.interfaces.IAtomContainer)
      • 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. The Transform.message() may still be set if there were warnings generated when interpreting the SMIRKS.

        Parameters:
        transform - the transform to load into
        smirks - the SMIRKS string
        options - 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. The Transform.message() may still be set if there were warnings generated when interpreting the SMIRKS.

        Parameters:
        transform - the transform to load into
        smirks - the SMIRKS string
        options - 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. The Transform.message() may still be set if there were warnings generated when interpreting the SMIRKS.

        Parameters:
        transform - the transform to load into
        smirks - the SMIRKS string
        Returns:
        the SMIRKS interpretable or not (there was an error)
        See Also:
        Transform, SmirksTransform