2 from openforcefield.utils.toolkits
import OpenEyeToolkitWrapper, RDKitToolkitWrapper, AmberToolsToolkitWrapper
6 oe_original_find_smarts_matches = OpenEyeToolkitWrapper.find_smarts_matches
7 OE_TOOLKIT_CACHE_find_smarts_matches = {}
9 cache_key = hash((molecule, smarts, aromaticity_model))
10 if cache_key
not in OE_TOOLKIT_CACHE_find_smarts_matches:
12 return OE_TOOLKIT_CACHE_find_smarts_matches[cache_key]
14 OpenEyeToolkitWrapper.find_smarts_matches = oe_cached_find_smarts_matches
17 rdk_original_find_smarts_matches = RDKitToolkitWrapper.find_smarts_matches
18 RDK_TOOLKIT_CACHE_find_smarts_matches = {}
20 cache_key = hash((molecule, smarts, aromaticity_model))
21 if cache_key
not in RDK_TOOLKIT_CACHE_find_smarts_matches:
23 return RDK_TOOLKIT_CACHE_find_smarts_matches[cache_key]
25 RDKitToolkitWrapper.find_smarts_matches = rdk_cached_find_smarts_matches
29 from openforcefield.typing.chemistry.environment
import ChemicalEnvironment
30 original_validate = ChemicalEnvironment.validate
31 TOOLKIT_CACHE_ChemicalEnvironment_validate = {}
32 def cached_validate(smirks, validate_valence_type=True, toolkit_registry=OpenEyeToolkitWrapper):
33 cache_key = hash((smirks, validate_valence_type, toolkit_registry))
34 if cache_key
not in TOOLKIT_CACHE_ChemicalEnvironment_validate:
35 TOOLKIT_CACHE_ChemicalEnvironment_validate[cache_key] =
original_validate(smirks, validate_valence_type=validate_valence_type, toolkit_registry=toolkit_registry)
36 return TOOLKIT_CACHE_ChemicalEnvironment_validate[cache_key]
37 ChemicalEnvironment.validate = cached_validate
53 oe_original_assign_partial_charges = OpenEyeToolkitWrapper.assign_partial_charges
54 OE_TOOLKIT_CACHE_assign_partial_charges = {}
56 cache_key = hash((molecule, partial_charge_method, str(use_conformers), strict_n_conformers))
57 if cache_key
not in OE_TOOLKIT_CACHE_assign_partial_charges:
58 oe_original_assign_partial_charges(self, molecule, partial_charge_method=partial_charge_method, use_conformers=use_conformers, strict_n_conformers=strict_n_conformers)
59 OE_TOOLKIT_CACHE_assign_partial_charges[cache_key] = molecule.partial_charges
61 molecule.partial_charges = OE_TOOLKIT_CACHE_assign_partial_charges[cache_key]
63 OpenEyeToolkitWrapper.assign_partial_charges = oe_cached_assign_partial_charges
67 at_original_assign_partial_charges = AmberToolsToolkitWrapper.assign_partial_charges
68 AT_TOOLKIT_CACHE_assign_partial_charges = {}
70 cache_key = hash((molecule, partial_charge_method, str(use_conformers), strict_n_conformers))
71 if cache_key
not in AT_TOOLKIT_CACHE_assign_partial_charges:
72 at_original_assign_partial_charges(self, molecule, partial_charge_method=partial_charge_method, use_conformers=use_conformers, strict_n_conformers=strict_n_conformers)
73 AT_TOOLKIT_CACHE_assign_partial_charges[cache_key] = molecule.partial_charges
75 molecule.partial_charges = AT_TOOLKIT_CACHE_assign_partial_charges[cache_key]
77 AmberToolsToolkitWrapper.assign_partial_charges = at_cached_assign_partial_charges
81 OE_TOOLKIT_CACHE_molecule_conformers = {}
82 oe_original_generate_conformers = OpenEyeToolkitWrapper.generate_conformers
84 cache_key = hash((molecule, n_conformers, str(rms_cutoff), clear_existing))
85 if cache_key
not in OE_TOOLKIT_CACHE_molecule_conformers:
87 OE_TOOLKIT_CACHE_molecule_conformers[cache_key] = molecule._conformers
88 molecule._conformers = OE_TOOLKIT_CACHE_molecule_conformers[cache_key]
89 OpenEyeToolkitWrapper.generate_conformers = oe_cached_generate_conformers
93 RDK_TOOLKIT_CACHE_molecule_conformers = {}
94 rdk_original_generate_conformers = RDKitToolkitWrapper.generate_conformers
96 cache_key = hash((molecule, n_conformers, str(rms_cutoff), clear_existing))
97 if cache_key
not in RDK_TOOLKIT_CACHE_molecule_conformers:
99 RDK_TOOLKIT_CACHE_molecule_conformers[cache_key] = molecule._conformers
100 molecule._conformers = RDK_TOOLKIT_CACHE_molecule_conformers[cache_key]
101 RDKitToolkitWrapper.generate_conformers = rdk_cached_generate_conformers
def rdk_cached_generate_conformers(self, molecule, n_conformers=1, rms_cutoff=None, clear_existing=True)
def rdk_cached_find_smarts_matches(self, molecule, smarts, aromaticity_model='OEAroModel_MDL')
def oe_cached_assign_partial_charges(self, molecule, partial_charge_method=None, use_conformers=None, strict_n_conformers=False)
rdk_original_generate_conformers
rdk_original_find_smarts_matches
def oe_cached_find_smarts_matches(self, molecule, smarts, aromaticity_model='OEAroModel_MDL')
def oe_cached_generate_conformers(self, molecule, n_conformers=1, rms_cutoff=None, clear_existing=True)
oe_original_assign_partial_charges
def cached_validate(smirks, validate_valence_type=True, toolkit_registry=OpenEyeToolkitWrapper)
at_original_assign_partial_charges
oe_original_generate_conformers
oe_original_find_smarts_matches
def at_cached_assign_partial_charges(self, molecule, partial_charge_method=None, use_conformers=None, strict_n_conformers=False)