API

Below is an outline of the API for the main functions of openff-fragmenter See the examples for details on how to use these objects.

Warning

The openff-fragmenter package is still pre-alpha so the API is still in flux.

Fragmentation Engines

pydantic model openff.fragmenter.fragment.Fragmenter[source]

The base class that all fragmentation engines should inherit from.

Show JSON schema
{
   "title": "Fragmenter",
   "description": "The base class that all fragmentation engines should inherit from.",
   "type": "object",
   "properties": {
      "functional_groups": {
         "title": "Functional Groups",
         "description": "A dictionary of SMARTS of functional groups that should not be fragmented, indexed by an informative name, e.g. 'alcohol': '[#6]-[#8X2H1]'.",
         "type": "object",
         "additionalProperties": {
            "type": "string"
         }
      }
   }
}

Fields
field functional_groups: Dict[str, str] [Optional]

A dictionary of SMARTS of functional groups that should not be fragmented, indexed by an informative name, e.g. ‘alcohol’: ‘[#6]-[#8X2H1]’.

classmethod find_rotatable_bonds(molecule: Molecule, target_bond_smarts: Optional[List[str]]) List[Tuple[int, int]][source]

Finds the rotatable bonds in a molecule including rotatable double bonds.

Parameters
  • molecule – The molecule to search for rotatable bonds.

  • target_bond_smarts

    An optional list of SMARTS patterns that should be used to identify the bonds within the parent molecule to grow fragments around. Each SMARTS pattern should include two indexed atoms that correspond to the two atoms involved in the central bond.

    If no pattern is provided fragments will be constructed around all ‘rotatable bonds’. A ‘rotatable bond’ here means any bond matched by a [!$(*#*)&!D1:1]-,=;!@[!$(*#*)&!D1:2] SMARTS pattern with the added constraint that the heavy degree (i.e. the degree excluding hydrogen) of both atoms in the bond must be >= 2.

Returns

  • A list of the **map* indices of the atoms that form the rotatable*

  • bonds, [(m1, m2),...].

fragment(molecule: Molecule, target_bond_smarts: Optional[List[str]] = None, toolkit_registry: Optional[Union[openff.toolkit.utils.ToolkitRegistry, openff.toolkit.utils.ToolkitWrapper]] = None) FragmentationResult[source]

Fragments a molecule according to this class’ settings.

Notes

  • This method is currently not guaranteed to be thread safe as it uses and modifies the OpenFF toolkits’ GLOBAL_TOOLKIT_REGISTRY.

Parameters
  • molecule – The molecule to fragment.

  • target_bond_smarts

    An optional list of SMARTS patterns that should be used to identify the bonds within the parent molecule to grow fragments around. Each SMARTS pattern should include two indexed atoms that correspond to the two atoms involved in the central bond.

    If no pattern is provided fragments will be constructed around all ‘rotatable bonds’. A ‘rotatable bond’ here means any bond matched by a [!$(*#*)&!D1:1]-,=;!@[!$(*#*)&!D1:2] SMARTS pattern with the added constraint that the heavy degree (i.e. the degree excluding hydrogen) of both atoms in the bond must be >= 2. Note this will not find terminal rotatable bonds such as -OH, -NH2 -CH3.

  • toolkit_registry – The underlying cheminformatics toolkits to use for things like conformer generation, WBO computation etc. If no value is provided, the current GLOBAL_TOOLKIT_REGISTRY will be used. See the OpenFF toolkit documentation for more information.

Returns

  • The results of the fragmentation including the fragments and provenance

  • about the fragmentation.

WBO

pydantic model openff.fragmenter.fragment.WBOFragmenter[source]

Fragment engine for fragmenting molecules using Wiberg Bond Order.

Show JSON schema
{
   "title": "WBOFragmenter",
   "description": "Fragment engine for fragmenting molecules using Wiberg Bond Order.",
   "type": "object",
   "properties": {
      "functional_groups": {
         "title": "Functional Groups",
         "description": "A dictionary of SMARTS of functional groups that should not be fragmented, indexed by an informative name, e.g. 'alcohol': '[#6]-[#8X2H1]'.",
         "type": "object",
         "additionalProperties": {
            "type": "string"
         }
      },
      "scheme": {
         "title": "Scheme",
         "default": "WBO",
         "enum": [
            "WBO"
         ],
         "type": "string"
      },
      "wbo_options": {
         "title": "Wbo Options",
         "description": "The options to use when computing the WBOs.",
         "default": {
            "method": "am1-wiberg-elf10",
            "max_conformers": 800,
            "rms_threshold": 1.0
         },
         "allOf": [
            {
               "$ref": "#/definitions/WBOOptions"
            }
         ]
      },
      "threshold": {
         "title": "Threshold",
         "description": "The threshold for the central bond WBO. If the fragment WBO is below this threshold, fragmenter will grow out the fragment one bond at a time via the path specified by the heuristic option",
         "default": 0.03,
         "type": "number"
      },
      "heuristic": {
         "title": "Heuristic",
         "description": "The path fragmenter should take when fragment needs to be grown out. The options are ``['wbo', 'path_length']``.",
         "default": "path_length",
         "enum": [
            "path_length",
            "wbo"
         ],
         "type": "string"
      },
      "keep_non_rotor_ring_substituents": {
         "title": "Keep Non Rotor Ring Substituents",
         "description": "Whether to always keep all non rotor substituents on rings. If ``False``, rotor substituents on rings will only be retained if they are ortho to the central bond or if it's needed for WBO to be within the threshold.",
         "default": false,
         "type": "boolean"
      }
   },
   "definitions": {
      "WBOOptions": {
         "title": "WBOOptions",
         "description": "A set of options for controlling how Wiberg Bond Orders are computed.",
         "type": "object",
         "properties": {
            "method": {
               "title": "Method",
               "description": "The method to use when computing the WBOs.",
               "default": "am1-wiberg-elf10",
               "enum": [
                  "am1-wiberg-elf10"
               ],
               "type": "string"
            },
            "max_conformers": {
               "title": "Max Conformers",
               "description": "The maximum number of conformers to average the WBOs over.",
               "default": 800,
               "type": "integer"
            },
            "rms_threshold": {
               "title": "Rms Threshold",
               "description": "The minimum RMS value [Angstrom] at which two conformers are considered redundant and one is deleted.",
               "default": 1.0,
               "type": "number"
            }
         }
      }
   }
}

Fields
field scheme: typing_extensions.Literal[WBO] = 'WBO'
field wbo_options: WBOOptions = WBOOptions(method='am1-wiberg-elf10', max_conformers=800, rms_threshold=1.0)

The options to use when computing the WBOs.

field threshold: float = 0.03

The threshold for the central bond WBO. If the fragment WBO is below this threshold, fragmenter will grow out the fragment one bond at a time via the path specified by the heuristic option

field heuristic: typing_extensions.Literal[path_length, wbo] = 'path_length'

The path fragmenter should take when fragment needs to be grown out. The options are ['wbo', 'path_length'].

field keep_non_rotor_ring_substituents: bool = False

Whether to always keep all non rotor substituents on rings. If False, rotor substituents on rings will only be retained if they are ortho to the central bond or if it’s needed for WBO to be within the threshold.

pydantic model openff.fragmenter.fragment.WBOOptions[source]

A set of options for controlling how Wiberg Bond Orders are computed.

Show JSON schema
{
   "title": "WBOOptions",
   "description": "A set of options for controlling how Wiberg Bond Orders are computed.",
   "type": "object",
   "properties": {
      "method": {
         "title": "Method",
         "description": "The method to use when computing the WBOs.",
         "default": "am1-wiberg-elf10",
         "enum": [
            "am1-wiberg-elf10"
         ],
         "type": "string"
      },
      "max_conformers": {
         "title": "Max Conformers",
         "description": "The maximum number of conformers to average the WBOs over.",
         "default": 800,
         "type": "integer"
      },
      "rms_threshold": {
         "title": "Rms Threshold",
         "description": "The minimum RMS value [Angstrom] at which two conformers are considered redundant and one is deleted.",
         "default": 1.0,
         "type": "number"
      }
   }
}

Fields
field method: typing_extensions.Literal[am1-wiberg-elf10] = 'am1-wiberg-elf10'

The method to use when computing the WBOs.

field max_conformers: int = 800

The maximum number of conformers to average the WBOs over.

field rms_threshold: float = 1.0

The minimum RMS value [Angstrom] at which two conformers are considered redundant and one is deleted.

Pfizer

pydantic model openff.fragmenter.fragment.PfizerFragmenter[source]

Fragment engine for fragmenting molecules using Pfizer’s protocol (doi: 10.1021/acs.jcim.9b00373)

Show JSON schema
{
   "title": "PfizerFragmenter",
   "description": "Fragment engine for fragmenting molecules using Pfizer's protocol\n(doi: 10.1021/acs.jcim.9b00373)",
   "type": "object",
   "properties": {
      "functional_groups": {
         "title": "Functional Groups",
         "description": "A dictionary of SMARTS of functional groups that should not be fragmented, indexed by an informative name, e.g. 'alcohol': '[#6]-[#8X2H1]'.",
         "type": "object",
         "additionalProperties": {
            "type": "string"
         }
      },
      "scheme": {
         "title": "Scheme",
         "default": "Pfizer",
         "enum": [
            "Pfizer"
         ],
         "type": "string"
      }
   }
}

Fields
field scheme: typing_extensions.Literal[Pfizer] = 'Pfizer'

Fragmentation Outputs

pydantic model openff.fragmenter.fragment.Fragment[source]

An object which stores minimal information about a molecules fragment.

Show JSON schema
{
   "title": "Fragment",
   "description": "An object which stores minimal information about a molecules fragment.",
   "type": "object",
   "properties": {
      "smiles": {
         "title": "Smiles",
         "description": "A mapped SMILES pattern describing the fragment. The map indices assigned to each atom in the pattern will correspond to the map index of the corresponding parent atom. If an atom does not have a map index it is likely that the atom was added (either H, or C) to ensure every atom in the fragment has a sensible valence.",
         "type": "string"
      },
      "bond_indices": {
         "title": "Bond Indices",
         "description": "The map indices of the atoms involved in the bond that the fragment was built around.",
         "type": "array",
         "minItems": 2,
         "maxItems": 2,
         "items": [
            {
               "type": "integer"
            },
            {
               "type": "integer"
            }
         ]
      }
   },
   "required": [
      "smiles",
      "bond_indices"
   ]
}

Fields
field smiles: str [Required]

A mapped SMILES pattern describing the fragment. The map indices assigned to each atom in the pattern will correspond to the map index of the corresponding parent atom. If an atom does not have a map index it is likely that the atom was added (either H, or C) to ensure every atom in the fragment has a sensible valence.

field bond_indices: Tuple[int, int] [Required]

The map indices of the atoms involved in the bond that the fragment was built around.

property molecule: Molecule

The fragment represented as an OpenFF molecule object.

pydantic model openff.fragmenter.fragment.FragmentationResult[source]

An object which stores the results of fragmenting a molecule.

Show JSON schema
{
   "title": "FragmentationResult",
   "description": "An object which stores the results of fragmenting a molecule.",
   "type": "object",
   "properties": {
      "parent_smiles": {
         "title": "Parent Smiles",
         "description": "A mapped SMILES pattern describing the parent molecule that was fragmented.",
         "type": "string"
      },
      "fragments": {
         "title": "Fragments",
         "description": "The generated fragments.",
         "type": "array",
         "items": {
            "$ref": "#/definitions/Fragment"
         }
      },
      "provenance": {
         "title": "Provenance",
         "description": "A dictionary storing provenance information about how the fragments were generated.",
         "type": "object"
      }
   },
   "required": [
      "parent_smiles",
      "fragments",
      "provenance"
   ],
   "definitions": {
      "Fragment": {
         "title": "Fragment",
         "description": "An object which stores minimal information about a molecules fragment.",
         "type": "object",
         "properties": {
            "smiles": {
               "title": "Smiles",
               "description": "A mapped SMILES pattern describing the fragment. The map indices assigned to each atom in the pattern will correspond to the map index of the corresponding parent atom. If an atom does not have a map index it is likely that the atom was added (either H, or C) to ensure every atom in the fragment has a sensible valence.",
               "type": "string"
            },
            "bond_indices": {
               "title": "Bond Indices",
               "description": "The map indices of the atoms involved in the bond that the fragment was built around.",
               "type": "array",
               "minItems": 2,
               "maxItems": 2,
               "items": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  }
               ]
            }
         },
         "required": [
            "smiles",
            "bond_indices"
         ]
      }
   }
}

Fields
field parent_smiles: str [Required]

A mapped SMILES pattern describing the parent molecule that was fragmented.

field fragments: List[Fragment] [Required]

The generated fragments.

field provenance: Dict[str, Any] [Required]

A dictionary storing provenance information about how the fragments were generated.

property parent_molecule: Molecule

The parent molecule represented as an OpenFF molecule object.

property fragment_molecules: Dict[Tuple[int, int], Molecule]

A dictionary of the fragment molecules represented as OpenFF molecule objects, indexed by the map indices of the bond that each fragment was built around.

property fragments_by_bond: Dict[Tuple[int, int], Fragment]

Returns a dictionary of fragments indexed by the bond (defined in terms of the map indices of the atoms that form it) that the fragment was built around.