openff-toolkit 0.18.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- devtools/scripts/build_cookiecutter_json.py +22 -0
- docs/conf.py +296 -0
- docs/conftest.py +23 -0
- examples/conformer_energies/conformer_energies.py +143 -0
- examples/deprecated/SMIRNOFF_comparison/compare_molecule_energies.py +48 -0
- examples/deprecated/SMIRNOFF_comparison/compare_set_energies.py +58 -0
- examples/deprecated/liquid_box/create_mol2_pdb/create_mol2_pdb.py +193 -0
- examples/deprecated/liquid_box/openff_simulation.py +72 -0
- examples/deprecated/mixedFF_structure/generate_mixedFF_complex.py +56 -0
- examples/deprecated/testing/test_impropers/tleap_tools.py +120 -0
- examples/examples_helper.py +61 -0
- openff/toolkit/__init__.py +101 -0
- openff/toolkit/_tests/__init__.py +0 -0
- openff/toolkit/_tests/_stale_tests.py +146 -0
- openff/toolkit/_tests/conftest.py +108 -0
- openff/toolkit/_tests/create_molecules.py +494 -0
- openff/toolkit/_tests/mocking.py +145 -0
- openff/toolkit/_tests/molecule/__init__.py +1 -0
- openff/toolkit/_tests/molecule/test_state_enumeration.py +302 -0
- openff/toolkit/_tests/test_energies.py +136 -0
- openff/toolkit/_tests/test_examples.py +109 -0
- openff/toolkit/_tests/test_forcefield.py +3864 -0
- openff/toolkit/_tests/test_interchange.py +19 -0
- openff/toolkit/_tests/test_io.py +19 -0
- openff/toolkit/_tests/test_links.py +73 -0
- openff/toolkit/_tests/test_mm_molecule.py +404 -0
- openff/toolkit/_tests/test_molecule.py +4246 -0
- openff/toolkit/_tests/test_nagl.py +169 -0
- openff/toolkit/_tests/test_parameter_plugins.py +89 -0
- openff/toolkit/_tests/test_parameters.py +2898 -0
- openff/toolkit/_tests/test_toolkit_io.py +1088 -0
- openff/toolkit/_tests/test_toolkits.py +4418 -0
- openff/toolkit/_tests/test_topology.py +2485 -0
- openff/toolkit/_tests/test_utils.py +101 -0
- openff/toolkit/_tests/test_utils_callback.py +178 -0
- openff/toolkit/_tests/test_utils_collections.py +263 -0
- openff/toolkit/_tests/test_utils_serialization.py +168 -0
- openff/toolkit/_tests/utils.py +1747 -0
- openff/toolkit/data/README.md +8 -0
- openff/toolkit/data/molecules/AlkEthOH_test_filt1_ff.mol2 +2026 -0
- openff/toolkit/data/molecules/AlkEthOH_test_filt1_tripos.mol2 +2026 -0
- openff/toolkit/data/molecules/AlkEthOH_tripos.tar.gz +0 -0
- openff/toolkit/data/molecules/CID20742535_anion.sdf +50 -0
- openff/toolkit/data/molecules/CID20742535_neutral.sdf +51 -0
- openff/toolkit/data/molecules/FreeSolv.tar.gz +0 -0
- openff/toolkit/data/molecules/MiniDrugBank.sdf +33988 -0
- openff/toolkit/data/molecules/MiniDrugBank_tripos.mol2 +35462 -0
- openff/toolkit/data/molecules/PT2385.sdf +90 -0
- openff/toolkit/data/molecules/QL8.sdf +401 -0
- openff/toolkit/data/molecules/README.md +21 -0
- openff/toolkit/data/molecules/benzene.crd +8 -0
- openff/toolkit/data/molecules/benzene.mol2 +34 -0
- openff/toolkit/data/molecules/benzene.top +166 -0
- openff/toolkit/data/molecules/butane_multi.sdf +231 -0
- openff/toolkit/data/molecules/cyclohexane.mol2 +44 -0
- openff/toolkit/data/molecules/ethanol.mol2 +25 -0
- openff/toolkit/data/molecules/ethanol.sdf +23 -0
- openff/toolkit/data/molecules/ethanol_partial_charges.sdf +26 -0
- openff/toolkit/data/molecules/ethanol_reordered.mol2 +25 -0
- openff/toolkit/data/molecules/ethanol_reordered.sdf +23 -0
- openff/toolkit/data/molecules/ethene_rdkit.sdf +17 -0
- openff/toolkit/data/molecules/laromustine_ff.mol2 +71 -0
- openff/toolkit/data/molecules/laromustine_tripos.mol2 +71 -0
- openff/toolkit/data/molecules/methane_multiconformer.sdf +32 -0
- openff/toolkit/data/molecules/methane_multiconformer_properties.sdf +45 -0
- openff/toolkit/data/molecules/nh4.pdb +7 -0
- openff/toolkit/data/molecules/po4_phenylphosphate.pdb +46 -0
- openff/toolkit/data/molecules/ruxolitinib_conformers.sdf +910 -0
- openff/toolkit/data/molecules/toluene.mol2 +38 -0
- openff/toolkit/data/molecules/toluene.mol2.gz +0 -0
- openff/toolkit/data/molecules/toluene.pdb +30 -0
- openff/toolkit/data/molecules/toluene.sdf +36 -0
- openff/toolkit/data/molecules/toluene_charged.mol2 +38 -0
- openff/toolkit/data/molecules/z_3_hydroxy_propenal.sdf +23 -0
- openff/toolkit/data/proteins/5tbm_complex_solv.pdb +1928 -0
- openff/toolkit/data/proteins/5tbm_complex_solv_box.pdb +19563 -0
- openff/toolkit/data/proteins/CTerminal_ALA.pdb +20 -0
- openff/toolkit/data/proteins/CTerminal_ALA.sdf +43 -0
- openff/toolkit/data/proteins/CTerminal_ALA_ALA.pdb +30 -0
- openff/toolkit/data/proteins/CTerminal_ALA_ALA_misnamedH.pdb +30 -0
- openff/toolkit/data/proteins/CTerminal_ARG.pdb +34 -0
- openff/toolkit/data/proteins/CTerminal_TRP.pdb +34 -0
- openff/toolkit/data/proteins/MainChain_ALA.pdb +25 -0
- openff/toolkit/data/proteins/MainChain_ALA.sdf +52 -0
- openff/toolkit/data/proteins/MainChain_ALA_ALA.pdb +35 -0
- openff/toolkit/data/proteins/MainChain_ALA_ALA.sdf +69 -0
- openff/toolkit/data/proteins/MainChain_ALA_ALA_icodes.pdb +35 -0
- openff/toolkit/data/proteins/MainChain_ALA_ALA_no_hydrogens.pdb +17 -0
- openff/toolkit/data/proteins/MainChain_ARG.pdb +39 -0
- openff/toolkit/data/proteins/MainChain_ARG.sdf +81 -0
- openff/toolkit/data/proteins/MainChain_CYM.pdb +25 -0
- openff/toolkit/data/proteins/MainChain_CYS.pdb +26 -0
- openff/toolkit/data/proteins/MainChain_CYX.pdb +48 -0
- openff/toolkit/data/proteins/MainChain_CYX.sdf +96 -0
- openff/toolkit/data/proteins/MainChain_GLH.sdf +64 -0
- openff/toolkit/data/proteins/MainChain_GLU.sdf +63 -0
- openff/toolkit/data/proteins/MainChain_HID.pdb +32 -0
- openff/toolkit/data/proteins/MainChain_HIE.pdb +32 -0
- openff/toolkit/data/proteins/MainChain_HIE.sdf +67 -0
- openff/toolkit/data/proteins/MainChain_HIP.pdb +33 -0
- openff/toolkit/data/proteins/MainChain_HIP.sdf +70 -0
- openff/toolkit/data/proteins/MainChain_PRO.pdb +29 -0
- openff/toolkit/data/proteins/MainChain_TRP.pdb +39 -0
- openff/toolkit/data/proteins/NTerminal_ALA.pdb +21 -0
- openff/toolkit/data/proteins/NTerminal_ALA.sdf +45 -0
- openff/toolkit/data/proteins/NTerminal_ALA_ALA.pdb +31 -0
- openff/toolkit/data/proteins/NTerminal_ARG.pdb +35 -0
- openff/toolkit/data/proteins/NTerminal_TRP.pdb +35 -0
- openff/toolkit/data/proteins/T4-protein-unprocessed-4w51.pdb +1892 -0
- openff/toolkit/data/proteins/T4-protein.mol2 +5461 -0
- openff/toolkit/data/proteins/T4-protein.pdb +2637 -0
- openff/toolkit/data/proteins/T4-protein.sdf +5318 -0
- openff/toolkit/data/proteins/T4_protein_waters.pdb +2965 -0
- openff/toolkit/data/proteins/TwoMol_SER_CYS.pdb +50 -0
- openff/toolkit/data/proteins/aa_residues_substructures_explicit_bond_orders_with_caps.json +6435 -0
- openff/toolkit/data/proteins/aa_residues_substructures_explicit_bond_orders_with_caps_explicit_connectivity.json +6675 -0
- openff/toolkit/data/proteins/aa_residues_substructures_with_caps.json +6297 -0
- openff/toolkit/data/proteins/ace-ZZZ-gly-nme.pdb +78 -0
- openff/toolkit/data/proteins/ace-ZZZ-gly-nme.sdf +98 -0
- openff/toolkit/data/proteins/ace-a10-nme.sdf +229 -0
- openff/toolkit/data/proteins/ace-ala-nh2.pdb +21 -0
- openff/toolkit/data/proteins/fluoresceine_dyed_helix_capped.pdb +338 -0
- openff/toolkit/data/proteins/neutral_arginine.pdb +31 -0
- openff/toolkit/data/proteins/split_chain.pdb +74 -0
- openff/toolkit/data/proteins/split_chain_reordered.pdb +74 -0
- openff/toolkit/data/reference_energies/README.md +6 -0
- openff/toolkit/data/reference_energies/reference_0.8.0.json +1 -0
- openff/toolkit/data/reference_energies/reference_0.8.0.json.txt +180 -0
- openff/toolkit/data/reference_energies/reference_after_1007.json +1 -0
- openff/toolkit/data/reference_energies/reference_after_1007.json.txt +350 -0
- openff/toolkit/data/reference_energies/reference_after_802.json +1 -0
- openff/toolkit/data/reference_energies/reference_after_802.json.txt +291 -0
- openff/toolkit/data/systems/README.md +3 -0
- openff/toolkit/data/systems/amber/cyclohexane_ethanol_0.4_0.6.inpcrd +1511 -0
- openff/toolkit/data/systems/amber/cyclohexane_ethanol_0.4_0.6.prmtop +13367 -0
- openff/toolkit/data/systems/monomers/butanol.mol2 +38 -0
- openff/toolkit/data/systems/monomers/butanol.sdf +88 -0
- openff/toolkit/data/systems/monomers/cyclohexane.mol2 +45 -0
- openff/toolkit/data/systems/monomers/cyclohexane.sdf +105 -0
- openff/toolkit/data/systems/monomers/ethanol.mol2 +26 -0
- openff/toolkit/data/systems/monomers/ethanol.sdf +58 -0
- openff/toolkit/data/systems/monomers/methane.mol2 +18 -0
- openff/toolkit/data/systems/monomers/methane.sdf +38 -0
- openff/toolkit/data/systems/monomers/propane.mol2 +30 -0
- openff/toolkit/data/systems/monomers/propane.sdf +68 -0
- openff/toolkit/data/systems/monomers/tip3p_water.mol2 +14 -0
- openff/toolkit/data/systems/monomers/water.mol2 +14 -0
- openff/toolkit/data/systems/monomers/water.sdf +28 -0
- openff/toolkit/data/systems/packmol_boxes/cyclohexane_ethanol_0.4_0.6.pdb +6272 -0
- openff/toolkit/data/systems/packmol_boxes/cyclohexane_water.pdb +5524 -0
- openff/toolkit/data/systems/packmol_boxes/ethanol_water.pdb +5174 -0
- openff/toolkit/data/systems/packmol_boxes/propane_methane_butanol_0.2_0.3_0.5.pdb +7959 -0
- openff/toolkit/data/systems/test_systems/1_cyclohexane_1_ethanol.pdb +61 -0
- openff/toolkit/data/systems/test_systems/1_ethanol.pdb +24 -0
- openff/toolkit/data/systems/test_systems/1_ethanol_no_conect.pdb +15 -0
- openff/toolkit/data/systems/test_systems/1_ethanol_reordered.pdb +24 -0
- openff/toolkit/data/systems/test_systems/PE.pdb +67 -0
- openff/toolkit/data/systems/test_systems/README.md +3 -0
- openff/toolkit/data/systems/test_systems/T4_lysozyme_water_ions.pdb +29240 -0
- openff/toolkit/data/test_forcefields/Frosst_AlkEthOH.offxml +61 -0
- openff/toolkit/data/test_forcefields/Frosst_AlkEthOH_GBSA.offxml +78 -0
- openff/toolkit/data/test_forcefields/Frosst_AlkEthOH_MDL.offxml +62 -0
- openff/toolkit/data/test_forcefields/Frosst_AlkEthOH_parmAtFrosst.offxml +64 -0
- openff/toolkit/data/test_forcefields/GBSA_HCT-1.0.offxml +21 -0
- openff/toolkit/data/test_forcefields/GBSA_OBC1-1.0.offxml +18 -0
- openff/toolkit/data/test_forcefields/GBSA_OBC2-1.0.offxml +18 -0
- openff/toolkit/data/test_forcefields/README.md +23 -0
- openff/toolkit/data/test_forcefields/ammonia_minimal.offxml +27 -0
- openff/toolkit/data/test_forcefields/benzene_minimal.offxml +29 -0
- openff/toolkit/data/test_forcefields/chargeincrement-test.offxml +16 -0
- openff/toolkit/data/test_forcefields/frcmod.Frosst_AlkEthOH_withIDs +85 -0
- openff/toolkit/data/test_forcefields/ion_charges.offxml +18 -0
- openff/toolkit/data/test_forcefields/mangled.offxml +9 -0
- openff/toolkit/data/test_forcefields/old/README.md +9 -0
- openff/toolkit/data/test_forcefields/old/hbonds.offxml +11 -0
- openff/toolkit/data/test_forcefields/old/test_ff_0_0_2_spec_0_1.offxml +332 -0
- openff/toolkit/data/test_forcefields/old/test_ff_0_0_2_spec_0_2.offxml +338 -0
- openff/toolkit/data/test_forcefields/old/test_ff_0_0_2_spec_0_3.offxml +329 -0
- openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_fixed_spec_0_1.offxml +342 -0
- openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_fixed_spec_0_2.offxml +348 -0
- openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_fixed_spec_0_3.offxml +337 -0
- openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_spec_0_1.offxml +340 -0
- openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_spec_0_2.offxml +346 -0
- openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_spec_0_3.offxml +337 -0
- openff/toolkit/data/test_forcefields/smirff99Frosst_reference_0_1_spec.offxml +349 -0
- openff/toolkit/data/test_forcefields/smirnoff99Frosst_experimental.offxml +343 -0
- openff/toolkit/data/test_forcefields/smirnoff99Frosst_reference_0_1_spec.offxml +349 -0
- openff/toolkit/data/test_forcefields/smirnoff99Frosst_reference_0_2_spec.offxml +356 -0
- openff/toolkit/data/test_forcefields/test_forcefield.offxml +346 -0
- openff/toolkit/data/test_forcefields/tip3p.offxml +22 -0
- openff/toolkit/data/test_forcefields/unsupported_smirnoff_version.offxml +9 -0
- openff/toolkit/topology/__init__.py +43 -0
- openff/toolkit/topology/_mm_molecule.py +663 -0
- openff/toolkit/topology/molecule.py +6102 -0
- openff/toolkit/topology/topology.py +2555 -0
- openff/toolkit/typing/__init__.py +1 -0
- openff/toolkit/typing/engines/__init__.py +1 -0
- openff/toolkit/typing/engines/smirnoff/__init__.py +31 -0
- openff/toolkit/typing/engines/smirnoff/forcefield.py +1440 -0
- openff/toolkit/typing/engines/smirnoff/io.py +234 -0
- openff/toolkit/typing/engines/smirnoff/parameters.py +3839 -0
- openff/toolkit/typing/engines/smirnoff/plugins.py +91 -0
- openff/toolkit/utils/__init__.py +57 -0
- openff/toolkit/utils/_viz.py +104 -0
- openff/toolkit/utils/ambertools_wrapper.py +507 -0
- openff/toolkit/utils/base_wrapper.py +268 -0
- openff/toolkit/utils/builtin_wrapper.py +136 -0
- openff/toolkit/utils/callback.py +187 -0
- openff/toolkit/utils/collections.py +247 -0
- openff/toolkit/utils/constants.py +18 -0
- openff/toolkit/utils/exceptions.py +766 -0
- openff/toolkit/utils/nagl_wrapper.py +164 -0
- openff/toolkit/utils/openeye_wrapper.py +2750 -0
- openff/toolkit/utils/rdkit_wrapper.py +3302 -0
- openff/toolkit/utils/serialization.py +466 -0
- openff/toolkit/utils/toolkit_registry.py +509 -0
- openff/toolkit/utils/toolkits.py +217 -0
- openff/toolkit/utils/utils.py +805 -0
- openff_toolkit-0.18.0.dist-info/METADATA +109 -0
- openff_toolkit-0.18.0.dist-info/RECORD +231 -0
- openff_toolkit-0.18.0.dist-info/WHEEL +5 -0
- openff_toolkit-0.18.0.dist-info/licenses/LICENSE +21 -0
- openff_toolkit-0.18.0.dist-info/top_level.txt +5 -0
- utilities/deprecated/convert_frosst/convert_frcmod_0.1.py +251 -0
- utilities/deprecated/convert_frosst/convert_frcmod_0.2.py +249 -0
- utilities/deprecated/convert_frosst/convert_frcmod_0.3.py +249 -0
- utilities/make_substructure_dict/_cif_to_substructure_dict.py +955 -0
- utilities/make_substructure_dict/_make_chemical_substructures.py +46 -0
- utilities/make_substructure_dict/_make_metadata_assignment_substructures.py +35 -0
- utilities/test_plugins/custom_plugins/handler_plugins.py +48 -0
- utilities/test_plugins/setup.py +19 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""This module defines functions for loading parameter handler and parser classes which
|
|
2
|
+
have been registered through the `entrypoint plugin system <https://packaging.python.
|
|
3
|
+
org/guides/creating-and-discovering-plugins/#using-package-metadata>`_.
|
|
4
|
+
|
|
5
|
+
.. warning ::
|
|
6
|
+
|
|
7
|
+
This feature is experimental and may be removed / altered in future versions.
|
|
8
|
+
|
|
9
|
+
Currently only ``ParameterHandler`` classes can be registered via the plugin
|
|
10
|
+
system. This is possible by registering the handler class through an entry
|
|
11
|
+
point in your projects ``setup.py`` file::
|
|
12
|
+
|
|
13
|
+
setup(
|
|
14
|
+
...
|
|
15
|
+
entry_points={
|
|
16
|
+
'openff.toolkit.plugins.handlers': ['CustomHandler = myapp:CustomHandler']
|
|
17
|
+
},
|
|
18
|
+
...
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
where in this example your package is named ``myapp`` and contains a class which
|
|
22
|
+
inherits from ``ParameterHandler`` named ``CustomHandler``.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
import logging
|
|
26
|
+
from importlib.metadata import entry_points
|
|
27
|
+
|
|
28
|
+
from openff.toolkit.typing.engines.smirnoff.parameters import ParameterHandler
|
|
29
|
+
|
|
30
|
+
logger = logging.getLogger(__name__)
|
|
31
|
+
|
|
32
|
+
SUPPORTED_PLUGIN_NAMES = ["handlers"] # io_handlers could be supported in future.
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _load_handler_plugins(handler_name: str, expected_type: type) -> list[type]:
|
|
36
|
+
"""Loads parameter handler plugins of a specified type which have been registered
|
|
37
|
+
with the ``entrypoint`` plugin system.
|
|
38
|
+
|
|
39
|
+
Parameters
|
|
40
|
+
----------
|
|
41
|
+
handler_name
|
|
42
|
+
The name of the hander plugin. This can currently be any of the names
|
|
43
|
+
listed in ``SUPPORTED_PLUGIN_NAMES``.
|
|
44
|
+
expected_type
|
|
45
|
+
The expected class type of the plugin. E.g. when loading parameter io
|
|
46
|
+
handler plugins the expected class type is ``ParameterIOHandler``. Any
|
|
47
|
+
classes not matching the expected type will be skipped.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
if handler_name not in SUPPORTED_PLUGIN_NAMES:
|
|
51
|
+
raise NotImplementedError(
|
|
52
|
+
f"Plugins named {handler_name} not supported. The list of currently "
|
|
53
|
+
f"supported plugin names is: {SUPPORTED_PLUGIN_NAMES}."
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
PluginType = type[ParameterHandler]
|
|
57
|
+
|
|
58
|
+
discovered_plugins: list[PluginType] = list()
|
|
59
|
+
|
|
60
|
+
for entry_point in entry_points().select(group=f"openff.toolkit.plugins.{handler_name}"):
|
|
61
|
+
try:
|
|
62
|
+
discovered_plugins.append(entry_point.load())
|
|
63
|
+
except (ImportError, AttributeError):
|
|
64
|
+
logger.exception(f"Could not load the {entry_point} plugin")
|
|
65
|
+
continue
|
|
66
|
+
|
|
67
|
+
valid_plugins: list[PluginType] = list()
|
|
68
|
+
|
|
69
|
+
for discovered_plugin in discovered_plugins:
|
|
70
|
+
if not issubclass(discovered_plugin, expected_type):
|
|
71
|
+
logger.info(
|
|
72
|
+
f"The {discovered_plugin.__name__} object has been registered as a "
|
|
73
|
+
f"{handler_name} plugin, but does not inherit from "
|
|
74
|
+
f"{expected_type.__name__}. This plugin will be skipped."
|
|
75
|
+
)
|
|
76
|
+
continue
|
|
77
|
+
|
|
78
|
+
valid_plugins.append(discovered_plugin)
|
|
79
|
+
|
|
80
|
+
return valid_plugins
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def load_handler_plugins() -> list[type[ParameterHandler]]:
|
|
84
|
+
"""Loads any ``ParameterHandler`` class plugins which have been registered through
|
|
85
|
+
the ``entrypoint`` plugin system.
|
|
86
|
+
|
|
87
|
+
Returns
|
|
88
|
+
-------
|
|
89
|
+
The registered ``ParameterHandler`` plugins.
|
|
90
|
+
"""
|
|
91
|
+
return _load_handler_plugins("handlers", ParameterHandler)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
from openff.toolkit.utils.constants import (
|
|
2
|
+
ALLOWED_AROMATICITY_MODELS,
|
|
3
|
+
ALLOWED_CHARGE_MODELS,
|
|
4
|
+
ALLOWED_FRACTIONAL_BOND_ORDER_MODELS,
|
|
5
|
+
DEFAULT_AROMATICITY_MODEL,
|
|
6
|
+
DEFAULT_CHARGE_MODEL,
|
|
7
|
+
DEFAULT_FRACTIONAL_BOND_ORDER_MODEL,
|
|
8
|
+
)
|
|
9
|
+
from openff.toolkit.utils.toolkit_registry import toolkit_registry_manager
|
|
10
|
+
from openff.toolkit.utils.toolkits import (
|
|
11
|
+
AMBERTOOLS_AVAILABLE,
|
|
12
|
+
BASIC_CHEMINFORMATICS_TOOLKITS,
|
|
13
|
+
GLOBAL_TOOLKIT_REGISTRY,
|
|
14
|
+
OPENEYE_AVAILABLE,
|
|
15
|
+
RDKIT_AVAILABLE,
|
|
16
|
+
AmberToolsToolkitWrapper,
|
|
17
|
+
AntechamberNotFoundError,
|
|
18
|
+
BadMoleculeAssumptionError,
|
|
19
|
+
BuiltInToolkitWrapper,
|
|
20
|
+
ChargeCalculationError,
|
|
21
|
+
ChargeMethodUnavailableError,
|
|
22
|
+
GAFFAtomTypeWarning,
|
|
23
|
+
IncompatibleUnitError,
|
|
24
|
+
IncorrectNumConformersError,
|
|
25
|
+
IncorrectNumConformersWarning,
|
|
26
|
+
InvalidIUPACNameError,
|
|
27
|
+
InvalidToolkitError,
|
|
28
|
+
InvalidToolkitRegistryError,
|
|
29
|
+
LicenseError,
|
|
30
|
+
MissingPackageError,
|
|
31
|
+
OpenEyeToolkitWrapper,
|
|
32
|
+
RDKitToolkitWrapper,
|
|
33
|
+
SMILESParseError,
|
|
34
|
+
ToolkitRegistry,
|
|
35
|
+
ToolkitUnavailableException,
|
|
36
|
+
ToolkitWrapper,
|
|
37
|
+
UndefinedStereochemistryError,
|
|
38
|
+
)
|
|
39
|
+
from openff.toolkit.utils.utils import (
|
|
40
|
+
all_subclasses,
|
|
41
|
+
convert_0_1_smirnoff_to_0_2,
|
|
42
|
+
convert_0_2_smirnoff_to_0_3,
|
|
43
|
+
convert_all_quantities_to_string,
|
|
44
|
+
convert_all_strings_to_quantity,
|
|
45
|
+
deserialize_numpy,
|
|
46
|
+
get_data_file_path,
|
|
47
|
+
get_molecule_parameterIDs,
|
|
48
|
+
inherit_docstrings,
|
|
49
|
+
object_to_quantity,
|
|
50
|
+
quantity_to_string,
|
|
51
|
+
requires_package,
|
|
52
|
+
serialize_numpy,
|
|
53
|
+
string_to_quantity,
|
|
54
|
+
string_to_unit,
|
|
55
|
+
temporary_cd,
|
|
56
|
+
unit_to_string,
|
|
57
|
+
)
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import uuid
|
|
2
|
+
from io import StringIO
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from nglview.base_adaptor import Structure, Trajectory
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from openff.toolkit import Molecule, Topology
|
|
9
|
+
|
|
10
|
+
MOLECULE_DEFAULT_REPS = [dict(type="licorice", params=dict(radius=0.25, multipleBond=True))]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class MoleculeNGLViewTrajectory(Structure, Trajectory):
|
|
14
|
+
"""
|
|
15
|
+
OpenFF Molecule adaptor.
|
|
16
|
+
|
|
17
|
+
The file format used to communicate with NGLView can make a big difference
|
|
18
|
+
in the visualization. For instance, using PDB will require NGLView to infer
|
|
19
|
+
bonds from positions, whereas using MOL2 or SDF may result in a loss of
|
|
20
|
+
residue data.
|
|
21
|
+
|
|
22
|
+
Parameters
|
|
23
|
+
----------
|
|
24
|
+
molecule
|
|
25
|
+
The `Molecule` object to display.
|
|
26
|
+
ext
|
|
27
|
+
The file extension to use to communicate with NGLView. The format must
|
|
28
|
+
be supported for export by the Toolkit via the `Molecule.to_file()
|
|
29
|
+
<openff.toolkit.topology.molecule.to_file>` method, and import by
|
|
30
|
+
NGLView. File formats supported by NGLView can be found at
|
|
31
|
+
https://nglviewer.org/ngl/api/manual/file-formats.html
|
|
32
|
+
|
|
33
|
+
Example
|
|
34
|
+
-------
|
|
35
|
+
>>> import nglview as nv
|
|
36
|
+
>>>
|
|
37
|
+
>>> mol = Molecule.from_polymer_pdb("file.pdb") # doctest: +SKIP
|
|
38
|
+
>>> nv.NGLWidget(MoleculeNGLViewTrajectory(mol)) # doctest: +SKIP
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
def __init__(
|
|
42
|
+
self,
|
|
43
|
+
molecule: "Molecule",
|
|
44
|
+
ext: str = "MOL2",
|
|
45
|
+
):
|
|
46
|
+
if not molecule.conformers:
|
|
47
|
+
raise ValueError("Cannot visualize a molecule without conformers with NGLView")
|
|
48
|
+
self.molecule = molecule
|
|
49
|
+
self.ext = ext.lower()
|
|
50
|
+
self.params: dict = dict()
|
|
51
|
+
self.id = str(uuid.uuid4())
|
|
52
|
+
|
|
53
|
+
def get_coordinates(self, index: int = 0):
|
|
54
|
+
return self.molecule.conformers[index].m_as("angstrom")
|
|
55
|
+
|
|
56
|
+
@property
|
|
57
|
+
def n_frames(self):
|
|
58
|
+
return len(self.molecule.conformers)
|
|
59
|
+
|
|
60
|
+
def get_structure_string(self):
|
|
61
|
+
with StringIO() as f:
|
|
62
|
+
self.molecule.to_file(f, file_format=self.ext)
|
|
63
|
+
structure_string = f.getvalue()
|
|
64
|
+
return structure_string
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class TopologyNGLViewStructure(Structure):
|
|
68
|
+
"""
|
|
69
|
+
OpenFF Topology adaptor.
|
|
70
|
+
|
|
71
|
+
Parameters
|
|
72
|
+
----------
|
|
73
|
+
topology
|
|
74
|
+
The `Topology` object to display.
|
|
75
|
+
ext
|
|
76
|
+
The file extension to use to communicate with NGLView. The format must
|
|
77
|
+
be supported for export by the Toolkit via the `Topology.to_file()
|
|
78
|
+
<openff.toolkit.topology.Topology.to_file>` method, and import by
|
|
79
|
+
NGLView. File formats supported by NGLView can be found at
|
|
80
|
+
https://nglviewer.org/ngl/api/manual/file-formats.html
|
|
81
|
+
|
|
82
|
+
Example
|
|
83
|
+
-------
|
|
84
|
+
>>> import nglview as nv
|
|
85
|
+
>>>
|
|
86
|
+
>>> top = Topology.from_pdb("file.pdb") # doctest: +SKIP
|
|
87
|
+
>>> nv.NGLWidget(TopologyNGLViewStructure(top)) # doctest: +SKIP
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
def __init__(
|
|
91
|
+
self,
|
|
92
|
+
topology: "Topology",
|
|
93
|
+
ext: str = "PDB",
|
|
94
|
+
):
|
|
95
|
+
self.topology = topology
|
|
96
|
+
self.ext = ext.lower()
|
|
97
|
+
self.params: dict = dict()
|
|
98
|
+
self.id = str(uuid.uuid4())
|
|
99
|
+
|
|
100
|
+
def get_structure_string(self):
|
|
101
|
+
with StringIO() as f:
|
|
102
|
+
self.topology.to_file(f, file_format=self.ext)
|
|
103
|
+
structure_string = f.getvalue()
|
|
104
|
+
return structure_string
|