Skip to content

Commit

Permalink
Revert some changes for simpler diff
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwthompson committed Oct 1, 2024
1 parent 9d86ba4 commit e1d9491
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
complex.*
complex_pointenergy.mdp
receptor.*
ligand.*
protein.pdb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
"repo_url = (\n",
" \"https://raw.githubusercontent.com/MobleyLab/benchmarksets/master/input_files/\"\n",
")\n",
"\n",
"sources = {\n",
" \"receptor.pdb\": f\"{repo_url}BRD4/pdb/BRD4.pdb\",\n",
" \"ligand.pdb\": f\"{repo_url}BRD4/pdb/ligand-1.pdb\",\n",
" \"ligand.sdf\": f\"{repo_url}BRD4/sdf/ligand-1.sdf\",\n",
" \"receptor.pdb\": repo_url + \"BRD4/pdb/BRD4.pdb\",\n",
" \"ligand.pdb\": repo_url + \"BRD4/pdb/ligand-1.pdb\",\n",
" \"ligand.sdf\": repo_url + \"BRD4/sdf/ligand-1.sdf\",\n",
"}\n",
"for filename, url in sources.items():\n",
" r = requests.get(url)\n",
Expand All @@ -41,20 +40,44 @@
"metadata": {},
"outputs": [],
"source": [
"from openff.toolkit import ForceField, Molecule, Quantity, Topology"
"from openff.toolkit import ForceField, Molecule, Topology"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Later we will use `Interchange.__add__`, which is an experimental feature. It needs to be turned on by setting the environment variable below, and by doing so we accept [some stability and accuracy risks](https://docs.openforcefield.org/projects/interchange/en/stable/using/experimental.html)."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"env: INTERCHANGE_EXPERIMENTAL=1\n"
]
}
],
"source": [
"%env INTERCHANGE_EXPERIMENTAL=1"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "48226cb62a2849029c42d579843ef0f7",
"model_id": "2f3b86c392c24705b86721395cf43ea4",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -67,8 +90,8 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/mattthompson/micromamba/envs/openff-toolkit-test/lib/python3.10/site-packages/openff/interchange/operations/_combine.py:52: InterchangeCombinationWarning: Interchange object combination is complex and likely to produce strange results outside of a limited set of use cases it has been tested in. Any workflow using this method is not guaranteed to be suitable for production or stable between versions. Use with extreme caution and thoroughly validate results!\n",
" warnings.warn(\n"
"/Users/jeffreywagner/projects/OpenForceField/openff-interchange/openff/interchange/_experimental.py:35: UserWarning: Interchange object combination is experimental and likely to produce strange results. Any workflow using this method is not guaranteed to be suitable for production. Use with extreme caution and thoroughly validate results!\n",
" return func(*args, **kwargs)\n"
]
}
],
Expand All @@ -84,32 +107,32 @@
"\n",
"receptor = ff14sb.create_interchange(topology=receptor_topology)\n",
"\n",
"# Interchange.combine works nicely for some cases but hasn't been tested for all - use caution\n",
"# if adapting this for more novel workflows!\n",
"complex_system = receptor.combine(ligand)"
"complex_system = receptor.combine(ligand)\n",
"\n",
"# TODO\n",
"# complex.box = pdbfile box vectors ...\n",
"# complex.positions = np.vstack([receptor.positions, ligand.positions])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Export to OpenMM\n",
"\n",
"See [docs](https://docs.openforcefield.org/projects/interchange/en/stable/using/output.html#openmm) for more options."
"### Export to OpenMM"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<openmm.openmm.System; proxy of <Swig Object of type 'OpenMM::System *' at 0x14ba376f0> >"
"<openmm.openmm.System; proxy of <Swig Object of type 'OpenMM::System *' at 0x14380adf0> >"
]
},
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -124,35 +147,31 @@
"tags": []
},
"source": [
"### Export to Amber\n",
"\n",
"See [docs](https://docs.openforcefield.org/projects/interchange/en/stable/using/output.html#amber) for more options."
"### Export to Amber"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"complex_system.to_inpcrd(\"complex.inpcrd\")\n",
"complex_system.to_prmtop(\"complex.prmtop\")"
"# TODO: Fix inferring residue information with mixed topology\n",
"if False:\n",
" complex_system.to_inpcrd(\"complex.inpcrd\")\n",
" complex_system.to_prmtop(\"complex.prmtop\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Export to GROMACS\n",
"\n",
"See [docs](https://docs.openforcefield.org/projects/interchange/en/stable/using/output.html#gromacs) for more options.\n",
"\n",
"GROMACS does not support vacuum simulations. In this example, we didn't add solvent and the original PDB file didn't have box vectors. We'll just arbitrarily add a 4 nm cubic box around the receptor-ligand complex."
"### Export to GROMACS"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {
"tags": []
},
Expand All @@ -161,16 +180,14 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/mattthompson/micromamba/envs/openff-toolkit-test/lib/python3.10/site-packages/openff/interchange/components/mdconfig.py:471: UserWarning: Ambiguous failure while processing constraints. Constraining h-bonds as a stopgap.\n",
" warnings.warn(\n"
"/Users/jeffreywagner/projects/OpenForceField/openff-interchange/openff/interchange/interop/gromacs/export/_export.py:48: UserWarning: WARNING: System defined with no box vectors, which GROMACS does not offically support in versions 2020 or newer (see https://gitlab.com/gromacs/gromacs/-/issues/3526). Setting box vectors to a 5 nm cube.\n",
" self._write_gro(gro, decimal)\n"
]
}
],
"source": [
"complex_system.box = Quantity([4, 4, 4], \"nanometer\")\n",
"\n",
"# This step might be slow, writing some large proteins is not yet optimized\n",
"complex_system.to_gromacs(\"complex\")"
"complex_system.to_gro(\"complex.gro\")\n",
"complex_system.to_top(\"complex.top\")"
]
}
],
Expand All @@ -191,7 +208,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.10.10"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions openff/toolkit/typing/engines/smirnoff/forcefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from packaging.version import Version

from openff.toolkit import Quantity
from openff.toolkit import Quantity, unit
from openff.toolkit.typing.engines.smirnoff.io import ParameterIOHandler
from openff.toolkit.typing.engines.smirnoff.parameters import ParameterHandler
from openff.toolkit.typing.engines.smirnoff.plugins import load_handler_plugins
Expand Down Expand Up @@ -1400,7 +1400,7 @@ def get_partial_charges(self, molecule: "Molecule", **kwargs: Any) -> Quantity:
force_field=self, topology=[molecule], **kwargs
)["Electrostatics"].charges.values()
],
"elementary_charge",
unit.elementary_charge,
)

def __getitem__(self, val: Union[str, ParameterHandler]) -> ParameterHandler:
Expand Down

0 comments on commit e1d9491

Please sign in to comment.