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,146 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from openff.toolkit import ForceField
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class StaleForceFieldTests:
|
|
7
|
+
@pytest.mark.skip(reason="Needs to be updated for 0.2.0 syntax")
|
|
8
|
+
def test_create_forcefield_from_file_list(self):
|
|
9
|
+
# These offxml files are located in package data path, which is automatically installed and searched
|
|
10
|
+
file_paths = [smirnoff99Frosst_offxml_file_path, tip3p_offxml_file_path]
|
|
11
|
+
# Create a forcefield from multiple offxml files
|
|
12
|
+
ForceField(file_paths)
|
|
13
|
+
|
|
14
|
+
@pytest.mark.skip(reason="Needs to be updated for 0.2.0 syntax")
|
|
15
|
+
def test_create_forcefield_from_file_path_iterator(self):
|
|
16
|
+
# These offxml files are located in package data path, which is automatically installed and searched
|
|
17
|
+
file_paths = [smirnoff99Frosst_offxml_file_path, tip3p_offxml_file_path]
|
|
18
|
+
# A generator should work as well
|
|
19
|
+
ForceField(iter(file_paths))
|
|
20
|
+
|
|
21
|
+
@pytest.mark.skip(reason="Needs to be updated for 0.2.0 syntax")
|
|
22
|
+
def test_create_gbsa(self):
|
|
23
|
+
"""Test reading of ffxml files with GBSA support."""
|
|
24
|
+
ForceField("test_forcefields/Frosst_AlkEthOH_GBSA.offxml")
|
|
25
|
+
|
|
26
|
+
@pytest.mark.skip(reason="Needs to be updated for 0.2.0 syntax")
|
|
27
|
+
def test_create_forcefield_from_url(self):
|
|
28
|
+
urls = [
|
|
29
|
+
"https://raw.githubusercontent.com/openforcefield/openff-toolkit/master/openff/toolkit/data/test_forcefields/test_forcefield.offxml",
|
|
30
|
+
"https://raw.githubusercontent.com/openforcefield/openff-toolkit/master/openff/toolkit/data/test_forcefields/tip3p.offxml",
|
|
31
|
+
]
|
|
32
|
+
# Test creation with smirnoff99frosst URL
|
|
33
|
+
ForceField(urls[0])
|
|
34
|
+
|
|
35
|
+
@pytest.mark.skip(reason="Needs to be updated for 0.2.0 syntax")
|
|
36
|
+
def test_create_forcefield_from_url_list(self):
|
|
37
|
+
urls = [
|
|
38
|
+
"https://raw.githubusercontent.com/openforcefield/openff-toolkit/master/openff/toolkit/data/test_forcefields/test_forcefield.offxml",
|
|
39
|
+
"https://raw.githubusercontent.com/openforcefield/openff-toolkit/master/openff/toolkit/data/test_forcefields/tip3p.offxml",
|
|
40
|
+
]
|
|
41
|
+
# Test creation with multiple URLs
|
|
42
|
+
ForceField(urls)
|
|
43
|
+
|
|
44
|
+
@pytest.mark.skip(reason="Needs to be updated for 0.2.0 syntax")
|
|
45
|
+
def test_create_forcefield_from_url_iterator(self):
|
|
46
|
+
urls = [
|
|
47
|
+
"https://raw.githubusercontent.com/openforcefield/openff-toolkit/master/openff/toolkit/data/test_forcefields/test_forcefield.offxml",
|
|
48
|
+
"https://raw.githubusercontent.com/openforcefield/openff-toolkit/master/openff/toolkit/data/test_forcefields/tip3p.offxml",
|
|
49
|
+
]
|
|
50
|
+
# A generator should work as well
|
|
51
|
+
ForceField(iter(urls))
|
|
52
|
+
|
|
53
|
+
@pytest.mark.skip(reason="Needs to be updated for 0.2.0 syntax")
|
|
54
|
+
def test_charge_increment(self):
|
|
55
|
+
"""Test parameter assignment using smirnoff99Frosst on laromustine with ChargeIncrementModel."""
|
|
56
|
+
molecules_file_path = get_data_file_path("molecules/laromustine_tripos.mol2")
|
|
57
|
+
molecule = Molecule.from_file(molecules_file_path)
|
|
58
|
+
forcefield = ForceField(["test_forcefields/test_forcefield.offxml", "chargeincrement-test"])
|
|
59
|
+
check_system_creation_from_molecule(forcefield, molecule)
|
|
60
|
+
# TODO: We can't implement a test for chargeincrement yet because we
|
|
61
|
+
# haven't settled on a SMIRNOFF spec for chargeincrementmodel
|
|
62
|
+
|
|
63
|
+
@pytest.mark.skip(reason="Needs to be updated for 0.2.0 syntax")
|
|
64
|
+
def test_create_system_molecules_parmatfrosst_gbsa(self):
|
|
65
|
+
"""Test creation of a System object from small molecules to test parm@frosst force field with GBSA support."""
|
|
66
|
+
molecules_file_path = get_data_file_path("molecules/AlkEthOH_test_filt1_tripos.mol2")
|
|
67
|
+
check_parameter_assignment(
|
|
68
|
+
offxml_file_path="test_forcefields/Frosst_AlkEthOH_GBSA.offxml",
|
|
69
|
+
molecules_file_path=molecules_file_path,
|
|
70
|
+
)
|
|
71
|
+
# TODO: Figure out if we just want to check that energy is finite (this is what the original test did,
|
|
72
|
+
# or compare numerically to a reference system.
|
|
73
|
+
|
|
74
|
+
@pytest.mark.skip(reason="Needs to be updated for 0.2.0 syntax")
|
|
75
|
+
def test_deep_copy(self):
|
|
76
|
+
force_field = ForceField(smirnoff99Frosst_offxml_file_path)
|
|
77
|
+
# Deep copy
|
|
78
|
+
force_field2 = copy.deepcopy(force_field)
|
|
79
|
+
assert_forcefields_equal(
|
|
80
|
+
force_field,
|
|
81
|
+
force_field2,
|
|
82
|
+
"ForceField deep copy does not match original ForceField",
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
@pytest.mark.skip(reason="Needs to be updated for 0.2.0 syntax")
|
|
86
|
+
# TODO: This should check the output of forcefield.to_dict
|
|
87
|
+
def test_serialize(self):
|
|
88
|
+
force_field = ForceField(smirnoff99Frosst_offxml_file_path)
|
|
89
|
+
# Serialize/deserialize
|
|
90
|
+
serialized_forcefield = force_field.__getstate__()
|
|
91
|
+
force_field2 = ForceField.__setstate__(serialized_forcefield)
|
|
92
|
+
assert_forcefields_equal(
|
|
93
|
+
force_field,
|
|
94
|
+
force_field2,
|
|
95
|
+
"Deserialized serialized ForceField does not match original ForceField",
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
@pytest.mark.skip(reason="Needs to be updated for 0.2.0 syntax")
|
|
100
|
+
def test_electrostatics_options(self):
|
|
101
|
+
"""Test parameter assignment using smirnoff99Frosst on laromustine with various long-range electrostatics options."""
|
|
102
|
+
from functools import partial
|
|
103
|
+
|
|
104
|
+
molecules_file_path = get_data_file_path("molecules/laromustine_tripos.mol2")
|
|
105
|
+
molecule = Molecule.from_file(molecules_file_path)
|
|
106
|
+
forcefield = ForceField([smirnoff99Frosst_offxml_file_path, charge_increment_offxml_file_path])
|
|
107
|
+
for method in ["PME", "reaction-field", "Coulomb"]:
|
|
108
|
+
# Change electrostatics method
|
|
109
|
+
forcefield.forces["Electrostatics"].method = method
|
|
110
|
+
f = partial(check_system_creation_from_molecule, forcefield, molecule)
|
|
111
|
+
f.description = f"Testing {offxml_file_path} parameter assignment using molecule {molecule.name}"
|
|
112
|
+
# yield f
|
|
113
|
+
# TODO: Implement a similar test, where we compare OpenMM energy evals from an
|
|
114
|
+
# AMBER-parameterized system to OFF-parameterized systems
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class StaleIOTests:
|
|
118
|
+
@pytest.mark.skip(reason="Needs to be updated for 1.0.0 syntax")
|
|
119
|
+
def test_to_xml(self):
|
|
120
|
+
forcefield = ForceField(smirnoff99Frosst_offxml_filename)
|
|
121
|
+
# Retrieve XML as a string
|
|
122
|
+
xml = forcefield.to_xml()
|
|
123
|
+
# Restore ForceField from XML
|
|
124
|
+
forcefield2 = ForceField(xml)
|
|
125
|
+
assert_forcefields_equal(
|
|
126
|
+
cls.forcefield,
|
|
127
|
+
forcefield2,
|
|
128
|
+
"ForceField serialized to XML does not match original ForceField",
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
# TODO: Remove ForceField from this whole file. All tests should be for converting between hierarchical SMIRNOFF
|
|
132
|
+
# dicts and XML
|
|
133
|
+
@pytest.mark.skip(reason="Needs to be updated for 1.0.0 syntax")
|
|
134
|
+
def test_save(self):
|
|
135
|
+
"""Test writing and reading of SMIRNOFF in XML format."""
|
|
136
|
+
forcefield = ForceField(smirnoff99Frosst_offxml_filename)
|
|
137
|
+
# Write XML to a file
|
|
138
|
+
with TemporaryDirectory() as tmpdir:
|
|
139
|
+
offxml_tmpfile = os.path.join(tmpdir, "forcefield.offxml")
|
|
140
|
+
forcefield.save(offxml_tmpfile)
|
|
141
|
+
forcefield2 = ForceField(offxml_tmpfile)
|
|
142
|
+
assert_forcefields_equal(
|
|
143
|
+
cls.forcefield,
|
|
144
|
+
forcefield2,
|
|
145
|
+
"ForceField written to .offxml does not match original ForceField",
|
|
146
|
+
)
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Configuration file for pytest.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
logger = logging.getLogger(__name__)
|
|
10
|
+
|
|
11
|
+
# Ensure QCPortal is imported before any OpenEye modules, see
|
|
12
|
+
# https://github.com/conda-forge/qcfractal-feedstock/issues/43
|
|
13
|
+
try:
|
|
14
|
+
import qcportal # noqa
|
|
15
|
+
except ImportError:
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def untar_full_alkethoh_and_freesolv_set():
|
|
20
|
+
"""When running slow tests, we unpack the full AlkEthOH and FreeSolv test
|
|
21
|
+
sets in advance to speed things up.
|
|
22
|
+
|
|
23
|
+
See
|
|
24
|
+
test_forcefield.py::test_alkethoh_parameters_assignment
|
|
25
|
+
test_forcefield.py::test_freesolv_parameters_assignment
|
|
26
|
+
"""
|
|
27
|
+
import os
|
|
28
|
+
import tarfile
|
|
29
|
+
|
|
30
|
+
from openff.toolkit.utils import get_data_file_path
|
|
31
|
+
|
|
32
|
+
molecule_dir_path = get_data_file_path("molecules")
|
|
33
|
+
for tarfile_name in ["AlkEthOH_tripos.tar.gz", "FreeSolv.tar.gz"]:
|
|
34
|
+
tarfile_path = os.path.join(molecule_dir_path, tarfile_name)
|
|
35
|
+
with tarfile.open(tarfile_path, "r:gz") as tar:
|
|
36
|
+
tar.extractall(path=molecule_dir_path)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def pytest_addoption(parser):
|
|
40
|
+
"""Add the pytest command line option --runslow and --failwip.
|
|
41
|
+
|
|
42
|
+
If --runslow is not given, tests marked with pytest.mark.slow are
|
|
43
|
+
skipped.
|
|
44
|
+
|
|
45
|
+
If --failwip is not given, tests marked with pytest.mark.wip are
|
|
46
|
+
xfailed.
|
|
47
|
+
|
|
48
|
+
Parameters
|
|
49
|
+
----------
|
|
50
|
+
parser : argparsing.parser
|
|
51
|
+
The parser used by pytest to process arguments
|
|
52
|
+
|
|
53
|
+
Returns
|
|
54
|
+
-------
|
|
55
|
+
None
|
|
56
|
+
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
# Loaded pytest plugins define their own arguments, and in certain cases
|
|
60
|
+
# our options use the same name. Although this can define two different
|
|
61
|
+
# behaviors for the same argument, the two options below are fairly
|
|
62
|
+
# unambiguous in their interpretation, so we skip any errors and allow
|
|
63
|
+
# the testing to proceed
|
|
64
|
+
|
|
65
|
+
try:
|
|
66
|
+
parser.addoption("--runslow", action="store_true", default=False, help="run slow tests")
|
|
67
|
+
except ValueError:
|
|
68
|
+
logger.warning("Option --runslow already added elsewhere (from a plugin possibly?). Skipping...")
|
|
69
|
+
|
|
70
|
+
try:
|
|
71
|
+
parser.addoption(
|
|
72
|
+
"--failwip",
|
|
73
|
+
action="store_true",
|
|
74
|
+
default=False,
|
|
75
|
+
help="fail work in progress tests",
|
|
76
|
+
)
|
|
77
|
+
except ValueError:
|
|
78
|
+
logger.warning("Option --failwip already added elsewhere (from a plugin possibly?). Skipping...")
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def pytest_collection_modifyitems(config, items):
|
|
82
|
+
if config.getoption("runslow"):
|
|
83
|
+
# If --runslow is given, we don't have to mark items for skipping,
|
|
84
|
+
# but we need to extract the whole AlkEthOH and FreeSolv sets (see
|
|
85
|
+
# test_forcefield::test_alkethoh/freesolv_parameters_assignment).
|
|
86
|
+
untar_full_alkethoh_and_freesolv_set()
|
|
87
|
+
else:
|
|
88
|
+
# Mark for skipping all items marked as slow.
|
|
89
|
+
skip_slow = pytest.mark.skip(reason="specify --runslow pytest option to run this test.")
|
|
90
|
+
for item in items:
|
|
91
|
+
if "slow" in item.keywords:
|
|
92
|
+
item.add_marker(skip_slow)
|
|
93
|
+
|
|
94
|
+
# Mark work-in-progress tests for xfail.
|
|
95
|
+
if not config.getoption("failwip"):
|
|
96
|
+
xfail_wip_reason = "This is a work in progress test. Specify --failwip pytest option to make this test fail."
|
|
97
|
+
for item in items:
|
|
98
|
+
if "wip" in item.keywords:
|
|
99
|
+
# Augment original reason.
|
|
100
|
+
reason = xfail_wip_reason + item.get_closest_marker("wip").kwargs.get("reason", "")
|
|
101
|
+
item.add_marker(pytest.mark.xfail(reason=reason))
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
@pytest.fixture
|
|
105
|
+
def opc():
|
|
106
|
+
from openff.toolkit import ForceField
|
|
107
|
+
|
|
108
|
+
return ForceField("opc.offxml")
|