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.
Files changed (231) hide show
  1. devtools/scripts/build_cookiecutter_json.py +22 -0
  2. docs/conf.py +296 -0
  3. docs/conftest.py +23 -0
  4. examples/conformer_energies/conformer_energies.py +143 -0
  5. examples/deprecated/SMIRNOFF_comparison/compare_molecule_energies.py +48 -0
  6. examples/deprecated/SMIRNOFF_comparison/compare_set_energies.py +58 -0
  7. examples/deprecated/liquid_box/create_mol2_pdb/create_mol2_pdb.py +193 -0
  8. examples/deprecated/liquid_box/openff_simulation.py +72 -0
  9. examples/deprecated/mixedFF_structure/generate_mixedFF_complex.py +56 -0
  10. examples/deprecated/testing/test_impropers/tleap_tools.py +120 -0
  11. examples/examples_helper.py +61 -0
  12. openff/toolkit/__init__.py +101 -0
  13. openff/toolkit/_tests/__init__.py +0 -0
  14. openff/toolkit/_tests/_stale_tests.py +146 -0
  15. openff/toolkit/_tests/conftest.py +108 -0
  16. openff/toolkit/_tests/create_molecules.py +494 -0
  17. openff/toolkit/_tests/mocking.py +145 -0
  18. openff/toolkit/_tests/molecule/__init__.py +1 -0
  19. openff/toolkit/_tests/molecule/test_state_enumeration.py +302 -0
  20. openff/toolkit/_tests/test_energies.py +136 -0
  21. openff/toolkit/_tests/test_examples.py +109 -0
  22. openff/toolkit/_tests/test_forcefield.py +3864 -0
  23. openff/toolkit/_tests/test_interchange.py +19 -0
  24. openff/toolkit/_tests/test_io.py +19 -0
  25. openff/toolkit/_tests/test_links.py +73 -0
  26. openff/toolkit/_tests/test_mm_molecule.py +404 -0
  27. openff/toolkit/_tests/test_molecule.py +4246 -0
  28. openff/toolkit/_tests/test_nagl.py +169 -0
  29. openff/toolkit/_tests/test_parameter_plugins.py +89 -0
  30. openff/toolkit/_tests/test_parameters.py +2898 -0
  31. openff/toolkit/_tests/test_toolkit_io.py +1088 -0
  32. openff/toolkit/_tests/test_toolkits.py +4418 -0
  33. openff/toolkit/_tests/test_topology.py +2485 -0
  34. openff/toolkit/_tests/test_utils.py +101 -0
  35. openff/toolkit/_tests/test_utils_callback.py +178 -0
  36. openff/toolkit/_tests/test_utils_collections.py +263 -0
  37. openff/toolkit/_tests/test_utils_serialization.py +168 -0
  38. openff/toolkit/_tests/utils.py +1747 -0
  39. openff/toolkit/data/README.md +8 -0
  40. openff/toolkit/data/molecules/AlkEthOH_test_filt1_ff.mol2 +2026 -0
  41. openff/toolkit/data/molecules/AlkEthOH_test_filt1_tripos.mol2 +2026 -0
  42. openff/toolkit/data/molecules/AlkEthOH_tripos.tar.gz +0 -0
  43. openff/toolkit/data/molecules/CID20742535_anion.sdf +50 -0
  44. openff/toolkit/data/molecules/CID20742535_neutral.sdf +51 -0
  45. openff/toolkit/data/molecules/FreeSolv.tar.gz +0 -0
  46. openff/toolkit/data/molecules/MiniDrugBank.sdf +33988 -0
  47. openff/toolkit/data/molecules/MiniDrugBank_tripos.mol2 +35462 -0
  48. openff/toolkit/data/molecules/PT2385.sdf +90 -0
  49. openff/toolkit/data/molecules/QL8.sdf +401 -0
  50. openff/toolkit/data/molecules/README.md +21 -0
  51. openff/toolkit/data/molecules/benzene.crd +8 -0
  52. openff/toolkit/data/molecules/benzene.mol2 +34 -0
  53. openff/toolkit/data/molecules/benzene.top +166 -0
  54. openff/toolkit/data/molecules/butane_multi.sdf +231 -0
  55. openff/toolkit/data/molecules/cyclohexane.mol2 +44 -0
  56. openff/toolkit/data/molecules/ethanol.mol2 +25 -0
  57. openff/toolkit/data/molecules/ethanol.sdf +23 -0
  58. openff/toolkit/data/molecules/ethanol_partial_charges.sdf +26 -0
  59. openff/toolkit/data/molecules/ethanol_reordered.mol2 +25 -0
  60. openff/toolkit/data/molecules/ethanol_reordered.sdf +23 -0
  61. openff/toolkit/data/molecules/ethene_rdkit.sdf +17 -0
  62. openff/toolkit/data/molecules/laromustine_ff.mol2 +71 -0
  63. openff/toolkit/data/molecules/laromustine_tripos.mol2 +71 -0
  64. openff/toolkit/data/molecules/methane_multiconformer.sdf +32 -0
  65. openff/toolkit/data/molecules/methane_multiconformer_properties.sdf +45 -0
  66. openff/toolkit/data/molecules/nh4.pdb +7 -0
  67. openff/toolkit/data/molecules/po4_phenylphosphate.pdb +46 -0
  68. openff/toolkit/data/molecules/ruxolitinib_conformers.sdf +910 -0
  69. openff/toolkit/data/molecules/toluene.mol2 +38 -0
  70. openff/toolkit/data/molecules/toluene.mol2.gz +0 -0
  71. openff/toolkit/data/molecules/toluene.pdb +30 -0
  72. openff/toolkit/data/molecules/toluene.sdf +36 -0
  73. openff/toolkit/data/molecules/toluene_charged.mol2 +38 -0
  74. openff/toolkit/data/molecules/z_3_hydroxy_propenal.sdf +23 -0
  75. openff/toolkit/data/proteins/5tbm_complex_solv.pdb +1928 -0
  76. openff/toolkit/data/proteins/5tbm_complex_solv_box.pdb +19563 -0
  77. openff/toolkit/data/proteins/CTerminal_ALA.pdb +20 -0
  78. openff/toolkit/data/proteins/CTerminal_ALA.sdf +43 -0
  79. openff/toolkit/data/proteins/CTerminal_ALA_ALA.pdb +30 -0
  80. openff/toolkit/data/proteins/CTerminal_ALA_ALA_misnamedH.pdb +30 -0
  81. openff/toolkit/data/proteins/CTerminal_ARG.pdb +34 -0
  82. openff/toolkit/data/proteins/CTerminal_TRP.pdb +34 -0
  83. openff/toolkit/data/proteins/MainChain_ALA.pdb +25 -0
  84. openff/toolkit/data/proteins/MainChain_ALA.sdf +52 -0
  85. openff/toolkit/data/proteins/MainChain_ALA_ALA.pdb +35 -0
  86. openff/toolkit/data/proteins/MainChain_ALA_ALA.sdf +69 -0
  87. openff/toolkit/data/proteins/MainChain_ALA_ALA_icodes.pdb +35 -0
  88. openff/toolkit/data/proteins/MainChain_ALA_ALA_no_hydrogens.pdb +17 -0
  89. openff/toolkit/data/proteins/MainChain_ARG.pdb +39 -0
  90. openff/toolkit/data/proteins/MainChain_ARG.sdf +81 -0
  91. openff/toolkit/data/proteins/MainChain_CYM.pdb +25 -0
  92. openff/toolkit/data/proteins/MainChain_CYS.pdb +26 -0
  93. openff/toolkit/data/proteins/MainChain_CYX.pdb +48 -0
  94. openff/toolkit/data/proteins/MainChain_CYX.sdf +96 -0
  95. openff/toolkit/data/proteins/MainChain_GLH.sdf +64 -0
  96. openff/toolkit/data/proteins/MainChain_GLU.sdf +63 -0
  97. openff/toolkit/data/proteins/MainChain_HID.pdb +32 -0
  98. openff/toolkit/data/proteins/MainChain_HIE.pdb +32 -0
  99. openff/toolkit/data/proteins/MainChain_HIE.sdf +67 -0
  100. openff/toolkit/data/proteins/MainChain_HIP.pdb +33 -0
  101. openff/toolkit/data/proteins/MainChain_HIP.sdf +70 -0
  102. openff/toolkit/data/proteins/MainChain_PRO.pdb +29 -0
  103. openff/toolkit/data/proteins/MainChain_TRP.pdb +39 -0
  104. openff/toolkit/data/proteins/NTerminal_ALA.pdb +21 -0
  105. openff/toolkit/data/proteins/NTerminal_ALA.sdf +45 -0
  106. openff/toolkit/data/proteins/NTerminal_ALA_ALA.pdb +31 -0
  107. openff/toolkit/data/proteins/NTerminal_ARG.pdb +35 -0
  108. openff/toolkit/data/proteins/NTerminal_TRP.pdb +35 -0
  109. openff/toolkit/data/proteins/T4-protein-unprocessed-4w51.pdb +1892 -0
  110. openff/toolkit/data/proteins/T4-protein.mol2 +5461 -0
  111. openff/toolkit/data/proteins/T4-protein.pdb +2637 -0
  112. openff/toolkit/data/proteins/T4-protein.sdf +5318 -0
  113. openff/toolkit/data/proteins/T4_protein_waters.pdb +2965 -0
  114. openff/toolkit/data/proteins/TwoMol_SER_CYS.pdb +50 -0
  115. openff/toolkit/data/proteins/aa_residues_substructures_explicit_bond_orders_with_caps.json +6435 -0
  116. openff/toolkit/data/proteins/aa_residues_substructures_explicit_bond_orders_with_caps_explicit_connectivity.json +6675 -0
  117. openff/toolkit/data/proteins/aa_residues_substructures_with_caps.json +6297 -0
  118. openff/toolkit/data/proteins/ace-ZZZ-gly-nme.pdb +78 -0
  119. openff/toolkit/data/proteins/ace-ZZZ-gly-nme.sdf +98 -0
  120. openff/toolkit/data/proteins/ace-a10-nme.sdf +229 -0
  121. openff/toolkit/data/proteins/ace-ala-nh2.pdb +21 -0
  122. openff/toolkit/data/proteins/fluoresceine_dyed_helix_capped.pdb +338 -0
  123. openff/toolkit/data/proteins/neutral_arginine.pdb +31 -0
  124. openff/toolkit/data/proteins/split_chain.pdb +74 -0
  125. openff/toolkit/data/proteins/split_chain_reordered.pdb +74 -0
  126. openff/toolkit/data/reference_energies/README.md +6 -0
  127. openff/toolkit/data/reference_energies/reference_0.8.0.json +1 -0
  128. openff/toolkit/data/reference_energies/reference_0.8.0.json.txt +180 -0
  129. openff/toolkit/data/reference_energies/reference_after_1007.json +1 -0
  130. openff/toolkit/data/reference_energies/reference_after_1007.json.txt +350 -0
  131. openff/toolkit/data/reference_energies/reference_after_802.json +1 -0
  132. openff/toolkit/data/reference_energies/reference_after_802.json.txt +291 -0
  133. openff/toolkit/data/systems/README.md +3 -0
  134. openff/toolkit/data/systems/amber/cyclohexane_ethanol_0.4_0.6.inpcrd +1511 -0
  135. openff/toolkit/data/systems/amber/cyclohexane_ethanol_0.4_0.6.prmtop +13367 -0
  136. openff/toolkit/data/systems/monomers/butanol.mol2 +38 -0
  137. openff/toolkit/data/systems/monomers/butanol.sdf +88 -0
  138. openff/toolkit/data/systems/monomers/cyclohexane.mol2 +45 -0
  139. openff/toolkit/data/systems/monomers/cyclohexane.sdf +105 -0
  140. openff/toolkit/data/systems/monomers/ethanol.mol2 +26 -0
  141. openff/toolkit/data/systems/monomers/ethanol.sdf +58 -0
  142. openff/toolkit/data/systems/monomers/methane.mol2 +18 -0
  143. openff/toolkit/data/systems/monomers/methane.sdf +38 -0
  144. openff/toolkit/data/systems/monomers/propane.mol2 +30 -0
  145. openff/toolkit/data/systems/monomers/propane.sdf +68 -0
  146. openff/toolkit/data/systems/monomers/tip3p_water.mol2 +14 -0
  147. openff/toolkit/data/systems/monomers/water.mol2 +14 -0
  148. openff/toolkit/data/systems/monomers/water.sdf +28 -0
  149. openff/toolkit/data/systems/packmol_boxes/cyclohexane_ethanol_0.4_0.6.pdb +6272 -0
  150. openff/toolkit/data/systems/packmol_boxes/cyclohexane_water.pdb +5524 -0
  151. openff/toolkit/data/systems/packmol_boxes/ethanol_water.pdb +5174 -0
  152. openff/toolkit/data/systems/packmol_boxes/propane_methane_butanol_0.2_0.3_0.5.pdb +7959 -0
  153. openff/toolkit/data/systems/test_systems/1_cyclohexane_1_ethanol.pdb +61 -0
  154. openff/toolkit/data/systems/test_systems/1_ethanol.pdb +24 -0
  155. openff/toolkit/data/systems/test_systems/1_ethanol_no_conect.pdb +15 -0
  156. openff/toolkit/data/systems/test_systems/1_ethanol_reordered.pdb +24 -0
  157. openff/toolkit/data/systems/test_systems/PE.pdb +67 -0
  158. openff/toolkit/data/systems/test_systems/README.md +3 -0
  159. openff/toolkit/data/systems/test_systems/T4_lysozyme_water_ions.pdb +29240 -0
  160. openff/toolkit/data/test_forcefields/Frosst_AlkEthOH.offxml +61 -0
  161. openff/toolkit/data/test_forcefields/Frosst_AlkEthOH_GBSA.offxml +78 -0
  162. openff/toolkit/data/test_forcefields/Frosst_AlkEthOH_MDL.offxml +62 -0
  163. openff/toolkit/data/test_forcefields/Frosst_AlkEthOH_parmAtFrosst.offxml +64 -0
  164. openff/toolkit/data/test_forcefields/GBSA_HCT-1.0.offxml +21 -0
  165. openff/toolkit/data/test_forcefields/GBSA_OBC1-1.0.offxml +18 -0
  166. openff/toolkit/data/test_forcefields/GBSA_OBC2-1.0.offxml +18 -0
  167. openff/toolkit/data/test_forcefields/README.md +23 -0
  168. openff/toolkit/data/test_forcefields/ammonia_minimal.offxml +27 -0
  169. openff/toolkit/data/test_forcefields/benzene_minimal.offxml +29 -0
  170. openff/toolkit/data/test_forcefields/chargeincrement-test.offxml +16 -0
  171. openff/toolkit/data/test_forcefields/frcmod.Frosst_AlkEthOH_withIDs +85 -0
  172. openff/toolkit/data/test_forcefields/ion_charges.offxml +18 -0
  173. openff/toolkit/data/test_forcefields/mangled.offxml +9 -0
  174. openff/toolkit/data/test_forcefields/old/README.md +9 -0
  175. openff/toolkit/data/test_forcefields/old/hbonds.offxml +11 -0
  176. openff/toolkit/data/test_forcefields/old/test_ff_0_0_2_spec_0_1.offxml +332 -0
  177. openff/toolkit/data/test_forcefields/old/test_ff_0_0_2_spec_0_2.offxml +338 -0
  178. openff/toolkit/data/test_forcefields/old/test_ff_0_0_2_spec_0_3.offxml +329 -0
  179. openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_fixed_spec_0_1.offxml +342 -0
  180. openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_fixed_spec_0_2.offxml +348 -0
  181. openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_fixed_spec_0_3.offxml +337 -0
  182. openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_spec_0_1.offxml +340 -0
  183. openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_spec_0_2.offxml +346 -0
  184. openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_spec_0_3.offxml +337 -0
  185. openff/toolkit/data/test_forcefields/smirff99Frosst_reference_0_1_spec.offxml +349 -0
  186. openff/toolkit/data/test_forcefields/smirnoff99Frosst_experimental.offxml +343 -0
  187. openff/toolkit/data/test_forcefields/smirnoff99Frosst_reference_0_1_spec.offxml +349 -0
  188. openff/toolkit/data/test_forcefields/smirnoff99Frosst_reference_0_2_spec.offxml +356 -0
  189. openff/toolkit/data/test_forcefields/test_forcefield.offxml +346 -0
  190. openff/toolkit/data/test_forcefields/tip3p.offxml +22 -0
  191. openff/toolkit/data/test_forcefields/unsupported_smirnoff_version.offxml +9 -0
  192. openff/toolkit/topology/__init__.py +43 -0
  193. openff/toolkit/topology/_mm_molecule.py +663 -0
  194. openff/toolkit/topology/molecule.py +6102 -0
  195. openff/toolkit/topology/topology.py +2555 -0
  196. openff/toolkit/typing/__init__.py +1 -0
  197. openff/toolkit/typing/engines/__init__.py +1 -0
  198. openff/toolkit/typing/engines/smirnoff/__init__.py +31 -0
  199. openff/toolkit/typing/engines/smirnoff/forcefield.py +1440 -0
  200. openff/toolkit/typing/engines/smirnoff/io.py +234 -0
  201. openff/toolkit/typing/engines/smirnoff/parameters.py +3839 -0
  202. openff/toolkit/typing/engines/smirnoff/plugins.py +91 -0
  203. openff/toolkit/utils/__init__.py +57 -0
  204. openff/toolkit/utils/_viz.py +104 -0
  205. openff/toolkit/utils/ambertools_wrapper.py +507 -0
  206. openff/toolkit/utils/base_wrapper.py +268 -0
  207. openff/toolkit/utils/builtin_wrapper.py +136 -0
  208. openff/toolkit/utils/callback.py +187 -0
  209. openff/toolkit/utils/collections.py +247 -0
  210. openff/toolkit/utils/constants.py +18 -0
  211. openff/toolkit/utils/exceptions.py +766 -0
  212. openff/toolkit/utils/nagl_wrapper.py +164 -0
  213. openff/toolkit/utils/openeye_wrapper.py +2750 -0
  214. openff/toolkit/utils/rdkit_wrapper.py +3302 -0
  215. openff/toolkit/utils/serialization.py +466 -0
  216. openff/toolkit/utils/toolkit_registry.py +509 -0
  217. openff/toolkit/utils/toolkits.py +217 -0
  218. openff/toolkit/utils/utils.py +805 -0
  219. openff_toolkit-0.18.0.dist-info/METADATA +109 -0
  220. openff_toolkit-0.18.0.dist-info/RECORD +231 -0
  221. openff_toolkit-0.18.0.dist-info/WHEEL +5 -0
  222. openff_toolkit-0.18.0.dist-info/licenses/LICENSE +21 -0
  223. openff_toolkit-0.18.0.dist-info/top_level.txt +5 -0
  224. utilities/deprecated/convert_frosst/convert_frcmod_0.1.py +251 -0
  225. utilities/deprecated/convert_frosst/convert_frcmod_0.2.py +249 -0
  226. utilities/deprecated/convert_frosst/convert_frcmod_0.3.py +249 -0
  227. utilities/make_substructure_dict/_cif_to_substructure_dict.py +955 -0
  228. utilities/make_substructure_dict/_make_chemical_substructures.py +46 -0
  229. utilities/make_substructure_dict/_make_metadata_assignment_substructures.py +35 -0
  230. utilities/test_plugins/custom_plugins/handler_plugins.py +48 -0
  231. utilities/test_plugins/setup.py +19 -0
@@ -0,0 +1,193 @@
1
+ #!/usr/bin/env python
2
+
3
+ from forcebalance.molecule import Molecule
4
+ from forcebalance.nifty import which
5
+ from openeye import oechem
6
+ import openmoltools
7
+ import os, sys, time, argparse, subprocess
8
+
9
+ def CalculateMolecularWeight(mol):
10
+ """
11
+ Calculate the molecular weight for an OpenEye molecule.
12
+
13
+ Parameters
14
+ ----------
15
+ mol : OEGraphMol
16
+
17
+ Returns
18
+ -------
19
+ float
20
+ Molecular weight in g/mol
21
+ """
22
+ result = 0.0
23
+ for atom in mol.GetAtoms():
24
+ elem = atom.GetAtomicNum()
25
+ mass = atom.GetIsotope()
26
+ if (elem != 0 and mass != 0):
27
+ result += oechem.OEGetIsotopicWeight(elem,mass)
28
+ else:
29
+ result += oechem.OEGetAverageWeight(elem)
30
+ return result
31
+
32
+ def CalculateBoxSize(nmol, molwt, density):
33
+ """
34
+ Calculate the size of a solvent box.
35
+
36
+ Parameters
37
+ ----------
38
+ nmol : int
39
+ Number of molecules desired for the box
40
+ molwt : float
41
+ Molecular weight in g/mol
42
+ density : float
43
+ Estimated density in kg/m3 (this should be about 40-50% lower than the real liquid density)
44
+
45
+ Returns
46
+ -------
47
+ float
48
+ Length of a cubic solvent box in nm.
49
+ """
50
+ # Calculate total mass of the box in kg
51
+ mass = nmol * molwt / 1000 / 6.022e23
52
+ volume = mass / density
53
+ length = volume**(1./3)/1e-9
54
+ return length
55
+
56
+ def GenerateBox(pdbin, pdbout, box, nmol, tries):
57
+ """
58
+ Call genbox. (Confirmed working with Gromacs version 4.6.7 and 5.1.4).
59
+ Mainly checks whether genbox ran correctly.
60
+
61
+ Parameters
62
+ ----------
63
+ pdbin : str
64
+ Name of input PDB file containing a single molecule.
65
+ pdbout : str
66
+ Name of output PDB file containing solvent box.
67
+ box : float
68
+ Solvent box size, should be determined previously.
69
+ nmol : int
70
+ Number of molecules to go into the solvent box
71
+ tries : int
72
+ Parameter for genbox to try inserting each molecule (tries) times
73
+
74
+ Returns
75
+ -------
76
+ None
77
+ If successful, produces "pdbout" containing solvent box.
78
+ """
79
+ if which('gmx'):
80
+ gmxcmd='gmx insert-molecules'
81
+ elif which('genbox'):
82
+ gmxcmd='genbox'
83
+ else:
84
+ raise RuntimeError('gmx and/or genbox not in PATH. Please source Gromacs environment variables.')
85
+
86
+ fout=open('genbox.out', 'w')
87
+ ferr=open('genbox.err', 'w')
88
+ subprocess.Popen(f'{gmxcmd} -ci {pdbin} -o genbox.pdb -box {box:.3f} {box:.3f} {box:.3f} -nmol {nmol} -try {tries}',
89
+ shell=True, stdout=fout, stderr=ferr)
90
+ fout.close()
91
+ ferr.close()
92
+ t0 = time.time()
93
+ print(f"Running {gmxcmd} to create a solvent box...")
94
+ print(f"Time elapsed: {(time.time() - t0): .3f} seconds")
95
+ nmol_out = 0
96
+ for line in open('genbox.err').readlines():
97
+ if 'Output configuration contains' in line:
98
+ nmol_out = int(line.split()[-2])
99
+ if nmol_out == 0:
100
+ raise RuntimeError('genbox failed to produce an output configuration')
101
+ elif nmol_out != nmol:
102
+ raise RuntimeError(f'genbox failed to create a box with {nmol} molecules (actual {nmol_out}); '
103
+ 'please retry with increased box size or number of tries')
104
+ else:
105
+ # genbox throws away the CONECT records in the PDB, this operation adds them back.
106
+ M1 = Molecule(pdbin, build_topology=False)
107
+ M = Molecule('genbox.pdb', build_topology=False)
108
+ solventbox_bonds = []
109
+ # Loop over the number of molecules in the solvent box
110
+ for i in range(nmol):
111
+ for j in M1.bonds:
112
+ # Add the bonds for molecule number "i" in the solvent box
113
+ solventbox_bonds.append((j[0]+i*M1.na, j[1]+i*M1.na))
114
+ M.bonds = solventbox_bonds
115
+ M.write(pdbout)
116
+ print(f"-=# Output #=- Created {pdbout} containing solvent box with {nmol} molecules and length {box:.3f}")
117
+
118
+ def run_create_mol2_pdb(**kwargs):
119
+
120
+ nmol = kwargs['nmol']
121
+ input_txt = kwargs['input']
122
+ resname = kwargs['resname']
123
+ density = kwargs['density']
124
+ tries = kwargs['tries']
125
+
126
+ # Disable Gromacs backup file creation
127
+ os.environ['GMX_MAXBACKUP']="-1"
128
+
129
+ smiles_string = open(input_txt).readlines()[0].strip()
130
+ print(f"The following SMILES string will be converted: {smiles_string}")
131
+
132
+ # create a new molecule
133
+ oemol = oechem.OEGraphMol()
134
+ # convert the SMILES string into a molecule
135
+ if oechem.OESmilesToMol(oemol, smiles_string):
136
+ # do something interesting with mol
137
+ pass
138
+ else:
139
+ print("SMILES string was invalid!")
140
+
141
+ # Add explicit
142
+ oechem.OEAddExplicitHydrogens(oemol)
143
+
144
+ # Generate a single conformer
145
+ oemol = openmoltools.openeye.generate_conformers(oemol, max_confs=1)
146
+
147
+ # Modify residue names
148
+ oechem.OEPerceiveResidues(oemol, oechem.OEPreserveResInfo_All)
149
+ for atom in oemol.GetAtoms():
150
+ thisRes = oechem.OEAtomGetResidue(atom)
151
+ thisRes.SetName(resname)
152
+
153
+ # Write output files
154
+ ofs = oechem.oemolostream()
155
+ output_fnms = [f"{resname}.mol2", f'{resname}.pdb']
156
+ for output_fnm in output_fnms:
157
+ if not ofs.open(output_fnm):
158
+ oechem.OEThrow.Fatal(f"Unable to create {output_fnm}")
159
+ oechem.OEWriteMolecule(ofs, oemol)
160
+ print(f"-=# Output #=- Created {output_fnm} containing single molecule")
161
+
162
+ grams_per_mole = CalculateMolecularWeight(oemol)
163
+
164
+ boxlen = CalculateBoxSize(nmol, grams_per_mole, density)
165
+ GenerateBox(f"{resname}.pdb", f'{resname}-box.pdb', boxlen, nmol, tries)
166
+
167
+ def main():
168
+ """
169
+ Provide a text file containing a single SMILES string and three-letter residue name.
170
+ Receive (res).pdb and (res).mol2 files containing a single molecule with conformation.
171
+ Receive (res)-box.pdb containing a box with specified number
172
+
173
+ Dependencies:
174
+ OpenEye tools (for creating molecule from SMILES)
175
+ openmoltools (for calling OpenEye to generate conformer)
176
+ Gromacs 4.6.7 or 5.1.4 (for calling genbox to create solvent box)
177
+ ForceBalance 1.5.x (for putting information back that was thrown away by genbox)
178
+ """
179
+ parser = argparse.ArgumentParser()
180
+ parser.add_argument('--density', type=int, default=600, help='Specify target density of the solvent box; should be somewhat smaller than true liquid density due to imperfect packing.')
181
+ parser.add_argument('--nmol', type=int, default=256, help='Specify desired number of molecules in the solvent box.')
182
+ parser.add_argument('--tries', type=int, default=10, help='Pass number of tries per molecule to be passed to genbox. Higher = longer runtime but may achieve higher density.')
183
+ parser.add_argument('input', type=str, help='Input file containing a single SMILES string')
184
+ parser.add_argument('resname', type=str, help='Specify a custom residue name for the molecule.')
185
+ print(f"{__file__} called with the following command line:")
186
+ print(' '.join(sys.argv))
187
+ args = parser.parse_args(sys.argv[1:])
188
+ # Create the desired files (.mol2 file containing a single conformation and .pdb file containing solvent box).
189
+ run_create_mol2_pdb(**vars(args))
190
+
191
+ if __name__ == "__main__":
192
+ main()
193
+
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env python
2
+
3
+ import time
4
+
5
+ # Import OpenMM tools
6
+ from simtk import openmm, unit
7
+ from simtk.openmm.app import *
8
+
9
+ # Use MDTraj to write simulation trajectories
10
+ from mdtraj.reporters import NetCDFReporter
11
+
12
+ # Import the SMIRNOFF force field engine and some useful tools
13
+ from openff.toolkit.typing.engines.smirnoff import ForceField
14
+ # LPW: Open Force Field's PME is different from openmm's PME
15
+ from openff.toolkit.typing.engines.smirnoff.forcefield import PME
16
+ from openff.toolkit.utils import get_data_file_path
17
+
18
+ # Import the OpenEye toolkit
19
+ from openeye import oechem
20
+
21
+ pdb_filename = 'ETH-box.pdb'
22
+ mol_filename = 'ETH.mol2'
23
+
24
+ # Define a few simulation parameters
25
+ time_step = 2*unit.femtoseconds # simulation timestep
26
+ temperature = 300*unit.kelvin # simulation temperature
27
+ friction = 1/unit.picosecond # collision rate
28
+ num_steps = 1000000 # number of steps to run
29
+ trj_freq = 1000 # number of steps per written trajectory frame
30
+ data_freq = 1000 # number of steps per written simulation statistics
31
+
32
+ # Load molecule and create pdb object
33
+ pdb = PDBFile(pdb_filename)
34
+
35
+ # Load a SMIRNOFF force field
36
+ forcefield = ForceField(get_data_file_path('test_forcefields/Frosst_AlkEthOH_parmAtFrosst.offxml'))
37
+
38
+ # Load molecule using OpenEye tools
39
+ mol = oechem.OEGraphMol()
40
+ ifs = oechem.oemolistream(mol_filename)
41
+ # LPW: I don't understand the meaning of these lines.
42
+ # flavor = oechem.OEIFlavor_Generic_Default | oechem.OEIFlavor_MOL2_Default | oechem.OEIFlavor_MOL2_Forcefield
43
+ # ifs.SetFlavor( oechem.OEFormat_MOL2, flavor)
44
+ oechem.OEReadMolecule(ifs, mol)
45
+ oechem.OETriposAtomNames(mol)
46
+
47
+ # Create the OpenMM system
48
+ system = forcefield.createSystem(pdb.topology, [mol], nonbondedMethod=PME, nonbondedCutoff=1.0*unit.nanometers, rigidWater=True)
49
+
50
+ # Set up an OpenMM simulation
51
+ integrator = openmm.LangevinIntegrator(temperature, friction, time_step)
52
+ platform = openmm.Platform.getPlatformByName('CUDA')
53
+ simulation = Simulation(pdb.topology, system, integrator)
54
+ simulation.context.setPositions(pdb.positions)
55
+ simulation.context.setVelocitiesToTemperature(temperature)
56
+ netcdf_reporter = NetCDFReporter('water_traj.nc', trj_freq)
57
+ simulation.reporters.append(netcdf_reporter)
58
+ simulation.reporters.append(StateDataReporter('water_data.csv', data_freq, step=True, potentialEnergy=True, temperature= True, density=True))
59
+
60
+ print(simulation.context.getState(getEnergy=True).getPotentialEnergy())
61
+ simulation.minimizeEnergy()
62
+ print(simulation.context.getState(getEnergy=True).getPotentialEnergy())
63
+
64
+ # Run the simulation
65
+ print("Starting simulation")
66
+ start = time.clock()
67
+ simulation.step(num_steps)
68
+ end = time.clock()
69
+
70
+ print(f"Elapsed time {end-start:.2f} seconds")
71
+ netcdf_reporter.close()
72
+ print("Done!")
@@ -0,0 +1,56 @@
1
+ #!/bin/env python
2
+
3
+ """
4
+ Illustrate how to combine a SMIRNOFF parameterized small molecule with an AMBER parameterized protein using ParmEd.
5
+
6
+ """
7
+
8
+ #
9
+ # Load and parameterize the small molecule
10
+ #
11
+
12
+ # Load the small molecule
13
+ from openff.toolkit.utils import get_data_file_path
14
+ ligand_filename = get_data_file_path('molecules/toluene.mol2')
15
+ molecule = Molecule.from_file(ligand_filename)
16
+
17
+ # Load the smirnoff99Frosst force field
18
+ from openff.toolkit.typing.engines import smirnoff
19
+ forcefield = smirnoff.ForceField('test_forcefields/test_forcefield.offxml')
20
+
21
+ # Create a ParmEd structure for the molecule
22
+ molecule_structure = forcefield.create_parmed_structure(topology=molecule.to_topology(), positions=molecule.positions)
23
+ print('Molecule:', molecule_structure)
24
+
25
+ #
26
+ # Load and parameterize the protein
27
+ #
28
+
29
+ # Load the protein topology
30
+ protein_pdb_filename = get_data_file_path('proteins/T4-protein.pdb')
31
+ protein_pdbfile = app.PDBFile(protein_pdb_filename)
32
+
33
+ # Load the AMBER protein force field, along with a solvent force field
34
+ from simtk.openmm import app
35
+ protein_forcefield = 'amber99sbildn.xml'
36
+ solvent_forcefield = 'tip3p.xml'
37
+ forcefield = app.ForceField(protein_forcefield, solvent_forcefield)
38
+
39
+ # Parameterize the protein
40
+ protein_system = forcefield.createSystem(proteinpdb.topology)
41
+
42
+ # Create a ParmEd Structure for the protein
43
+ protein_structure = parmed.openmm.load_topology(proteinpdb.topology,
44
+ protein_system,
45
+ xyz=proteinpdb.positions)
46
+ print('Protein:', protein_structure)
47
+
48
+ # Combine the ParmEd Structure objects to produce a fully parameterized complex
49
+ # that can now be exported to AMBER, CHARMM, OpenMM, and other packages
50
+ # Note that the addition should always add the small molecule second so the box vectors if the first item (the protein) are to be preserved
51
+ complex_structure = protein_structure + molecule_structure
52
+ print('Complex:', complex_structure)
53
+
54
+ # TODO: How can we add solvent while ensuring the ligand doesn't overlap with solvent molecules?
55
+ # TODO: Can we have SMIRNOFF ForceField create an OpenMM ffxml file for the ligand, and then use the OpenMM pipeline?
56
+ # TODO: Or can OpenMM just use dummy parameters?
@@ -0,0 +1,120 @@
1
+ import mdtraj.utils
2
+ import os
3
+ import shutil
4
+ import logging
5
+ logger = logging.getLogger(__name__)
6
+ from openmoltools.utils import getoutput
7
+
8
+ # Functionality below adapted from openmoltools.amber.run_tleap
9
+
10
+ def run_tleap(molecule_name, mol2_filename, frcmod_filename, prmtop_filename=None, inpcrd_filename=None, log_debug_output=False, verbose = True):
11
+ """Run AmberTools tleap to create simulation files for AMBER
12
+ Parameters
13
+ ----------
14
+ molecule_name : str
15
+ The name of the molecule
16
+ mol2_filename : str
17
+ mol2 filename with target atom type names
18
+ frcmod_filename : str
19
+ Amber frcmod file produced by prmchk
20
+ prmtop_filename : str, optional, default=None
21
+ Amber prmtop file produced by tleap, defaults to molecule_name
22
+ inpcrd_filename : str, optional, default=None
23
+ Amber inpcrd file produced by tleap, defaults to molecule_name
24
+ log_debug_output : bool, optional, default=False
25
+ If true, will send output of tleap to logger.
26
+ verbose : bool
27
+ Be verbose
28
+ Returns
29
+ -------
30
+ prmtop_filename : str
31
+ Amber prmtop file produced by tleap
32
+ inpcrd_filename : str
33
+ Amber inpcrd file produced by tleap
34
+ """
35
+ if prmtop_filename is None:
36
+ prmtop_filename = f"{molecule_name}.prmtop"
37
+ if inpcrd_filename is None:
38
+ inpcrd_filename = f"{molecule_name}.inpcrd"
39
+
40
+ #Get absolute paths for input/output
41
+ mol2_filename = os.path.abspath( mol2_filename )
42
+ frcmod_filename = os.path.abspath( frcmod_filename )
43
+ prmtop_filename = os.path.abspath( prmtop_filename )
44
+ inpcrd_filename = os.path.abspath( inpcrd_filename )
45
+
46
+ #Work in a temporary directory, on hard coded filenames, to avoid any issues AMBER may have with spaces and other special characters in filenames
47
+ with mdtraj.utils.enter_temp_directory():
48
+ shutil.copy( mol2_filename, 'file.mol2' )
49
+ shutil.copy( frcmod_filename, 'file.frcmod' )
50
+
51
+ tleap_input = """
52
+ source oldff/leaprc.ff99
53
+ LIG = loadmol2 file.mol2
54
+ loadamberparams file.frcmod
55
+ check LIG
56
+ saveamberparm LIG out.prmtop out.inpcrd
57
+ quit
58
+ """
59
+
60
+ file_handle = open('tleap_commands', 'w')
61
+ file_handle.writelines(tleap_input)
62
+ file_handle.close()
63
+
64
+ cmd = f"tleap -f {file_handle.name} "
65
+ if log_debug_output: logger.debug(cmd)
66
+ if verbose: print(cmd)
67
+
68
+ output = getoutput(cmd)
69
+ if log_debug_output: logger.debug(output)
70
+ if verbose: print(output)
71
+
72
+ check_for_errors( output, other_errors = ['Improper number of arguments'], ignore_errors=['Perhaps a format error'])
73
+
74
+ #Copy back target files
75
+ shutil.copy( 'out.prmtop', prmtop_filename )
76
+ shutil.copy( 'out.inpcrd', inpcrd_filename )
77
+
78
+ return prmtop_filename, inpcrd_filename
79
+
80
+
81
+ def check_for_errors( outputtext, other_errors = None, ignore_errors = None ):
82
+ """Check AMBER package output for the string 'ERROR' (upper or lowercase) and (optionally) specified other strings and raise an exception if it is found (to avoid silent failures which might be noted to log but otherwise ignored).
83
+ Parameters
84
+ ----------
85
+ outputtext : str
86
+ String listing output text from an (AMBER) command which should be checked for errors.
87
+ other_errors : list(str), default None
88
+ If specified, provide strings for other errors which will be chcked for, such as "improper number of arguments", etc.
89
+ ignore_errors: list(str), default None
90
+ If specified, AMBER output lines containing errors but also containing any of the specified strings will be ignored (because, for example, AMBER issues an "ERROR" for non-integer charges in some cases when only a warning is needed).
91
+ Notes
92
+ -----
93
+ If error(s) are found, raise a RuntimeError and attept to print the appropriate errors from the processed text."""
94
+ lines = outputtext.split('\n')
95
+ error_lines = []
96
+ for line in lines:
97
+ if 'ERROR' in line.upper():
98
+ error_lines.append( line )
99
+ if not other_errors == None:
100
+ for err in other_errors:
101
+ if err.upper() in line.upper():
102
+ error_lines.append( line )
103
+
104
+ if not ignore_errors == None and len(error_lines)>0:
105
+ new_error_lines = []
106
+ for ign in ignore_errors:
107
+ ignore = False
108
+ for err in error_lines:
109
+ if ign in err:
110
+ ignore = True
111
+ if not ignore:
112
+ new_error_lines.append( err )
113
+ error_lines = new_error_lines
114
+
115
+ if len(error_lines) > 0:
116
+ print("Unexpected errors encountered running AMBER tool. Offending output:")
117
+ for line in error_lines: print(line)
118
+ raise(RuntimeError("Error encountered running AMBER tool. Exiting."))
119
+
120
+ return
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env python3
2
+ """Copy the openff-toolkit examples suite to a local directory"""
3
+
4
+ import argparse
5
+ from os import environ
6
+ from pathlib import Path
7
+ from shutil import copytree, ignore_patterns
8
+
9
+
10
+ class NoExamplesLibraryError(Exception):
11
+ """Slightly more descriptive error for when the examples library is not found"""
12
+
13
+ def __init__(self):
14
+ message = "\n".join(
15
+ (
16
+ "Could not find examples library.",
17
+ "",
18
+ "Is the openff-toolkit-examples Conda package installed?",
19
+ )
20
+ )
21
+ super().__init__(message)
22
+
23
+
24
+ def main():
25
+ """Entrypoint for the script"""
26
+ parser = argparse.ArgumentParser(description=__doc__)
27
+
28
+ default_target = "./examples/"
29
+ parser.add_argument(
30
+ "--target",
31
+ default=default_target,
32
+ type=Path,
33
+ help=f"Target directory to store the examples suite. Defaults to {default_target}",
34
+ )
35
+
36
+ parser.add_argument(
37
+ "--include-deprecated",
38
+ action="store_true",
39
+ help="Copy over deprecated examples in addition to current examples",
40
+ )
41
+
42
+ args = parser.parse_args()
43
+
44
+ if args.include_deprecated:
45
+ copytree_ignore = None
46
+ else:
47
+ copytree_ignore = ignore_patterns("deprecated")
48
+
49
+ target_path = args.target
50
+ library_path = Path(environ["CONDA_PREFIX"]) / "share/openff-toolkit/examples"
51
+
52
+ try:
53
+ copytree(library_path, target_path, ignore=copytree_ignore)
54
+ except FileNotFoundError as err:
55
+ if Path(err.filename) == library_path and err.filename2 is None:
56
+ raise NoExamplesLibraryError() from err
57
+ raise err
58
+
59
+
60
+ if __name__ == "__main__":
61
+ main()
@@ -0,0 +1,101 @@
1
+ """
2
+ openff-toolkit
3
+ A modern, extensible library for molecular mechanics force field science from the Open Force Field Consortium.
4
+ """
5
+
6
+ import importlib
7
+ from importlib.metadata import version
8
+ from typing import TYPE_CHECKING
9
+
10
+ if TYPE_CHECKING:
11
+ # These types are imported lazily at runtime, but we need to tell type
12
+ # checkers what they are
13
+ from openff.units import Quantity, unit
14
+
15
+ from openff.toolkit.topology import Molecule, Topology
16
+ from openff.toolkit.typing.engines.smirnoff import (
17
+ ForceField,
18
+ get_available_force_fields,
19
+ )
20
+ from openff.toolkit.utils.toolkits import (
21
+ GLOBAL_TOOLKIT_REGISTRY,
22
+ AmberToolsToolkitWrapper,
23
+ BuiltInToolkitWrapper,
24
+ NAGLToolkitWrapper,
25
+ OpenEyeToolkitWrapper,
26
+ RDKitToolkitWrapper,
27
+ ToolkitRegistry,
28
+ )
29
+
30
+ __version__ = version("openff.toolkit")
31
+
32
+ __all__ = [
33
+ "GLOBAL_TOOLKIT_REGISTRY",
34
+ "AmberToolsToolkitWrapper",
35
+ "BuiltInToolkitWrapper",
36
+ "ForceField",
37
+ "Molecule",
38
+ "OpenEyeToolkitWrapper",
39
+ "Quantity",
40
+ "RDKitToolkitWrapper",
41
+ "ToolkitRegistry",
42
+ "Topology",
43
+ "__version__",
44
+ "get_available_force_fields",
45
+ "unit",
46
+ ]
47
+
48
+ # Dictionary of objects to lazily import; maps the object's name to its module path
49
+ _lazy_imports_obj = {
50
+ "ForceField": "openff.toolkit.typing.engines.smirnoff",
51
+ "get_available_force_fields": "openff.toolkit.typing.engines.smirnoff",
52
+ "Molecule": "openff.toolkit.topology",
53
+ "Topology": "openff.toolkit.topology",
54
+ "GLOBAL_TOOLKIT_REGISTRY": "openff.toolkit.utils.toolkits",
55
+ "AmberToolsToolkitWrapper": "openff.toolkit.utils.toolkits",
56
+ "BuiltInToolkitWrapper": "openff.toolkit.utils.toolkits",
57
+ "NAGLToolkitWrapper": "openff.toolkit.utils.toolkits",
58
+ "OpenEyeToolkitWrapper": "openff.toolkit.utils.toolkits",
59
+ "RDKitToolkitWrapper": "openff.toolkit.utils.toolkits",
60
+ "ToolkitRegistry": "openff.toolkit.utils.toolkits",
61
+ "Quantity": "openff.units",
62
+ "unit": "openff.units",
63
+ # Remember to add new lazy imports to __all__ and the if TYPE_CHECKING imports
64
+ }
65
+
66
+ # Dictionary of modules to lazily import; maps the modules's name to its path
67
+ _lazy_imports_mod = {
68
+ "topology": "openff.toolkit.topology",
69
+ "typing": "openff.toolkit.typing",
70
+ "utils": "openff.toolkit.utils",
71
+ "unit": "openff.units.units",
72
+ }
73
+
74
+
75
+ def __getattr__(name):
76
+ """Lazily import objects from _lazy_imports_obj or _lazy_imports_mod
77
+
78
+ Note that this method is only called by Python if the name cannot be found
79
+ in the current module."""
80
+ obj_mod = _lazy_imports_obj.get(name)
81
+ if obj_mod is not None:
82
+ mod = importlib.import_module(obj_mod)
83
+ # This only causes an infinite recursive loop if an object that does not
84
+ # exist is declared in `_lazy_imports_obj` to be lazy loaded from the
85
+ # current module. Since there is no reason to include either an object
86
+ # from the current module or an object that does not exist in
87
+ # `_lazy_imports_obj`, and since the function would fail in this case
88
+ # anyway, this is safe.
89
+ return getattr(mod, name)
90
+
91
+ lazy_mod = _lazy_imports_mod.get(name)
92
+ if lazy_mod is not None:
93
+ return importlib.import_module(lazy_mod)
94
+
95
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
96
+
97
+
98
+ def __dir__():
99
+ """Add _lazy_imports_obj and _lazy_imports_mod to dir(<module>)"""
100
+ keys = (*globals().keys(), *_lazy_imports_obj.keys(), *_lazy_imports_mod.keys())
101
+ return sorted(keys)
File without changes