Class DfPattern

    • Method Detail

      • match

        public int[] match​(IAtomContainer target)
        Find a matching of this pattern in the 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!
             }
         }
         
        Specified by:
        match in class Pattern
        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 the target. Depending on the implementation stereochemistry may be checked (recommended).
         Pattern        pattern = ...; // create pattern
         for (IAtomContainer m : ms) {
             if (pattern.matches(m)) {
                 // found mapping!
             }
         }
         
        Overrides:
        matches in class Pattern
        Parameters:
        target - the container to search for the pattern in
        Returns:
        the mapping from the pattern to the target
      • matchAll

        public Mappings matchAll​(IAtomContainer mol)
        Find all mappings of this pattern in the target. Stereochemistry should not be checked to allow filtering with Mappings.stereochemistry().
         Pattern pattern = Pattern.findSubstructure(query);
         for (IAtomContainer m : ms) {
             for (int[] mapping : pattern.matchAll(m)) {
                 // found mapping
             }
         }
         
        Using the fluent interface (see 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();
         
        Specified by:
        matchAll in class Pattern
        Parameters:
        mol - the container to search for the pattern in
        Returns:
        the mapping from the pattern to the target
        See Also:
        Mappings
      • matchesRoot

        public boolean matchesRoot​(IAtom root)
        Test whether the pattern matches at the provided atom.
        Parameters:
        root - the root atom of the molecule
        Returns:
        the pattern matches