Skip to content

Commit

Permalink
Update Example notebooks to Sage force field (#1065)
Browse files Browse the repository at this point in the history
* Update check_parameter_coverage to Sage FF

* Update conformer-energies to Sage FF

* Update forcefield_modification to Sage FF

* Update inspect_assigned_parameters to Sage FF

* Update smirnoff_simulation to Sage FF

* Update using_smirnoff_in_amber_or_gromacs to Sage FF

* Update swap_amber_parameters to Sage FF

* Update toolkit_showcase to Sage FF

* Update using_smirnoff_with_amber_protein_forcefield to Sage FF

* Update virtual_sites to Sage FF

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update changelog

* Fix references to old force fields in comments

* Update conformer_energies.py to use Sage and print out the used force field

* Add pin for openff-forcefield >=2.0.0 to examples environment

* Add example script behaviour change to changelog

* Merge `master` into `update-example-ffs`

Squashed commit of the following:

commit b3bcc88
Author: Jeff Wagner <jwagnerjpl@gmail.com>
Date:   Fri Sep 10 13:42:37 2021 -0700

    Update latest release tag to be 'stable' instead of 'latest' (#1068)

    * update use of latest tag to refer to 'stable' instead of 'latest' (since 'latest' clashes with the RTD builtin 'latest' keyword)

    * Update .github/workflows/release.yml

    Co-authored-by: Josh A. Mitchell <yoshanuikabundi@gmail.com>

    * Update notebook links from 'latest' to 'stable' tag

    * cosmetic commit to kick ci

    Co-authored-by: Josh A. Mitchell <yoshanuikabundi@gmail.com>

commit 9d9f933
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Thu Sep 9 18:24:25 2021 -0500

    Safely import OpenMM (#1063)

    * Pin to OpenMM 7.5.x

    * Loosen OpenMM pin

    * Fix link to OpenMM ForceField API docs

    * Unpin everything

    * Cleanup

    * Gracefully import OpenMM in examples

    * Safely import OpenMM everywhere

    * Clean up an import

    * Run CI with openmm==7.5 pin

    * Run CI with openmm==7.6 pin

    * Unpin OpenMM, run slow tests

    * Revert addition of slow tests

commit e4b56ab
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Thu Sep 9 17:12:30 2021 -0500

    Catch/raise descriptive error on conformer generation failure (#1050)

    * Catch/raise descriptive error on conformer generation failure

    * Run slow tests in PR

    * Remove useless raise_exception_types, add test in Molecule API

    * Remove unused import

    * Update openff/toolkit/utils/exceptions.py

    Co-authored-by: Lily Wang <31115101+lilyminium@users.noreply.github.com>

    * Use uranium hexafluoride to test conformer generation failures

    * Make conformer generation try other toolkits

    * Explicitly test that both OpenEye and RDKit fail on UF6

    * Update CHANGELOG

    * Fix change pushed to wrong branch

    Co-authored-by: Lily Wang <31115101+lilyminium@users.noreply.github.com>

commit 7a3fad5
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Wed Sep 8 16:01:00 2021 -0500

    nbqa-black -> black (#1064)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Yoshanuikabundi and pre-commit-ci[bot] committed Sep 13, 2021
1 parent b3bcc88 commit 36f3c75
Show file tree
Hide file tree
Showing 26 changed files with 9,531 additions and 4,563 deletions.
9 changes: 5 additions & 4 deletions docs/releasehistory.md
Expand Up @@ -56,12 +56,17 @@ Releases follow the `major.minor.micro` scheme recommended by [PEP440](https://w
[`ForceField.create_parmed_structure`](openff.toolkit.typing.engines.smirnoff.ForceField.create_parmed_structure),
[`Topology.to_parmed`](openff.toolkit.topology.Topology.to_parmed), and
[`Topology.from_parmed`](openff.toolkit.topology.Topology.from_parmed).
- [PR #1065](https://github.com/openforcefield/openforcefield/pull/1065): The example `conformer_energies.py` script
now uses the Sage 2.0.0 force field.

### Tests updated

- [PR #1017](https://github.com/openforcefield/openforcefield/pull/1017): Ensures that OpenEye-only CI builds really
do lack both AmberTools and RDKit.

### Improved documentation and warnings
- [PR #1065](https://github.com/openforcefield/openforcefield/pull/1017): Example notebooks were updated to use the
Sage Open Force Field

## 0.10.0 Improvements for force field fitting

Expand All @@ -76,8 +81,6 @@ Releases follow the `major.minor.micro` scheme recommended by [PEP440](https://w
[`openff.toolkit.utils.exceptions.SMIRNOFFParseError`](openff.toolkit.utils.exceptions.SMIRNOFFParseError).
This `ParseError` is deprecated and will be removed in a future release.

## Current Development

### New features and behaviors changed

- [PR #1027](https://github.com/openforcefield/openforcefield/pull/1027): Corrects interconversion of Molecule objects
Expand Down Expand Up @@ -144,8 +147,6 @@ Releases follow the `major.minor.micro` scheme recommended by [PEP440](https://w
- The RDKit wrapper no longer includes a header line. This improves
the consistency between the OpenEye and RDKit outputs.



### Bugfixes

- [PR #1024](https://github.com/openforcefield/openforcefield/pull/1024): Small changes
Expand Down
2 changes: 2 additions & 0 deletions examples/SMIRNOFF_simulation/.gitignore
@@ -0,0 +1,2 @@
data.csv
trajectory.pdb
25 changes: 9 additions & 16 deletions examples/SMIRNOFF_simulation/run_simulation.ipynb
Expand Up @@ -15,16 +15,17 @@
"source": [
"### Create an OpenMM System\n",
"\n",
"We start by loading a PDB file containing one copy of ethanol and cyclohexane. Our goal is to create an OFF `Topology` object describing this system that we can parametrize with the SMIRNOFF-format \"Parsley\" force field.\n",
"We start by loading a PDB file containing one copy of ethanol and cyclohexane. Our goal is to create an OFF `Topology` object describing this system that we can parametrize with the SMIRNOFF-format \"Sage\" force field.\n",
"\n",
"The two `Molecule` objects created from the SMILES strings can contain information such as partial charges and stereochemistry that is not included in an OpenMM topology. In this example, partial charges are not explicitly given, and `ForceField` will assign AM1/BCC charges as specified by the \"Parsley\" force field."
"The two `Molecule` objects created from the SMILES strings can contain information such as partial charges and stereochemistry that is not included in an OpenMM topology. In this example, partial charges are not explicitly given, and `ForceField` will assign AM1/BCC charges as specified by the \"Sage\" force field."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
],
"source": [
"try:\n",
" from openmm.app import PDBFile\n",
Expand Down Expand Up @@ -67,15 +68,7 @@
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Warning: importing 'simtk.openmm' is deprecated. Import 'openmm' instead.\n"
]
}
],
"outputs": [],
"source": [
"from openff.toolkit.topology import Molecule\n",
"\n",
Expand Down Expand Up @@ -107,7 +100,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We now create the Open Force Field Toolkit `Topology` describing the system from an OpenMM `Topology` object. The OFF `Topology` include more information (supplied by the two `Molecule` objects) than the OpenMM `Topology` such as (optionally) partial charges and stereochemistry. In this example, partial charges are not explicitly given, and `ForceField` will assign AM1/BCC charges as specified by the \"Parsley\" force field.\n",
"We now create the Open Force Field Toolkit `Topology` describing the system from an OpenMM `Topology` object. The OFF `Topology` include more information (supplied by the two `Molecule` objects) than the OpenMM `Topology` such as (optionally) partial charges and stereochemistry. In this example, partial charges are not explicitly given, and `ForceField` will assign AM1/BCC charges as specified by the \"Sage\" force field.\n",
"\n",
"Note that the Open Force Field Toolkit produces deterministic charges that do not depend on the input conformation of parameterized molecules. See the [FAQ](https://open-forcefield-toolkit.readthedocs.io/en/stable/faq.html#the-partial-charges-generated-by-the-toolkit-don-t-seem-to-depend-on-the-molecule-s-conformation-is-this-a-bug) for more information.\n",
"\n",
Expand All @@ -132,8 +125,8 @@
" unique_molecules=[ethanol, cyclohexane],\n",
")\n",
"\n",
"# Load the OpenFF \"Parsley\" force field.\n",
"forcefield = ForceField(\"openff-1.0.0.offxml\")\n",
"# Load the OpenFF \"Sage\" force field.\n",
"forcefield = ForceField(\"openff-2.0.0.offxml\")\n",
"\n",
"# Parametrize the topology and create an OpenMM System.\n",
"system = forcefield.create_openmm_system(off_topology)"
Expand Down Expand Up @@ -207,7 +200,7 @@
"output_type": "stream",
"text": [
"Starting simulation\n",
"Elapsed time 5.62 seconds\n",
"Elapsed time 1.20 seconds\n",
"Done!\n"
]
}
Expand Down
1 change: 1 addition & 0 deletions examples/check_dataset_parameter_coverage/.gitignore
@@ -0,0 +1 @@
molecule_?
431 changes: 312 additions & 119 deletions examples/check_dataset_parameter_coverage/check_parameter_coverage.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions examples/conformer_energies/.gitignore
@@ -0,0 +1,2 @@
ruxolitinib.csv
ruxolitinib_conf*_minimized.sdf
2 changes: 1 addition & 1 deletion examples/conformer_energies/README.md
Expand Up @@ -5,5 +5,5 @@
These examples illustrate how to compute small molecule vacuum energies (for example, for different conformers of the same molecule) using a SMIRNOFF force field.

* [`conformer_energies.ipynb`](conformer_energies.ipynb) contains an example illustrating the computation of conformer energies using a SMIRNOFF force field
* [`conformer_energies.py`](conformer_energies.py) is a CLI utility for computing conformer energies using the "Parsley" (openff-1.1.0) SMIRNOFF force field.
* [`conformer_energies.py`](conformer_energies.py) is a CLI utility for computing conformer energies using the "Sage" (openff-2.0.0) SMIRNOFF force field.
It can be run on example data with `python conformer_energies.py -f ruxolitinib_conformers.sdf`
33 changes: 20 additions & 13 deletions examples/conformer_energies/conformer_energies.ipynb
Expand Up @@ -24,7 +24,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"Warning: importing 'simtk.openmm' is deprecated. Import 'openmm' instead.\n"
"Warning: Unable to load toolkit 'OpenEye Toolkit'. The Open Force Field Toolkit does not require the OpenEye Toolkits, and can use RDKit/AmberTools instead. However, if you have a valid license for the OpenEye Toolkits, consider installing them for faster performance and additional file format support: https://docs.eyesopen.com/toolkits/python/quickstart-python/linuxosx.html OpenEye offers free Toolkit licenses for academics: https://www.eyesopen.com/academic-licensing\n"
]
}
],
Expand Down Expand Up @@ -100,10 +100,10 @@
"metadata": {},
"outputs": [],
"source": [
"# Load the openff-1.1.0 force field appropriate for vacuum calculations (without constraints)\n",
"# Load the openff-2.0.0 force field appropriate for vacuum calculations (without constraints)\n",
"from openff.toolkit.typing.engines.smirnoff import ForceField\n",
"\n",
"forcefield = ForceField(\"openff_unconstrained-1.1.0.offxml\")"
"forcefield = ForceField(\"openff_unconstrained-2.0.0.offxml\")"
]
},
{
Expand All @@ -118,16 +118,16 @@
"ruxolitinib : 10 conformers\n",
"Parametrizing ruxolitinib (may take a moment to calculate charges)\n",
"Conformer Initial PE Minimized PE RMS between initial and minimized conformer\n",
" 1 / 10 : 29.510 kcal/mol -0.956 kcal/mol 0.763 Angstroms\n",
" 2 / 10 : 38.635 kcal/mol 0.395 kcal/mol 0.569 Angstroms\n",
" 3 / 10 : 74.570 kcal/mol 0.242 kcal/mol 0.947 Angstroms\n",
" 4 / 10 : 35.743 kcal/mol 1.107 kcal/mol 0.565 Angstroms\n",
" 5 / 10 : 36.666 kcal/mol 1.474 kcal/mol 1.044 Angstroms\n",
" 6 / 10 : 38.139 kcal/mol -1.264 kcal/mol 0.621 Angstroms\n",
" 7 / 10 : 37.363 kcal/mol 1.165 kcal/mol 1.009 Angstroms\n",
" 8 / 10 : 27.530 kcal/mol -0.516 kcal/mol 1.043 Angstroms\n",
" 9 / 10 : 33.149 kcal/mol -0.923 kcal/mol 1.067 Angstroms\n",
" 10 / 10 : 35.451 kcal/mol -1.900 kcal/mol 0.663 Angstroms\n"
" 1 / 10 : 17.890 kcal/mol -13.860 kcal/mol 0.606 Angstroms\n",
" 2 / 10 : 24.274 kcal/mol -11.793 kcal/mol 0.547 Angstroms\n",
" 3 / 10 : 59.493 kcal/mol -11.919 kcal/mol 0.963 Angstroms\n",
" 4 / 10 : 25.481 kcal/mol -12.201 kcal/mol 0.733 Angstroms\n",
" 5 / 10 : 21.963 kcal/mol -10.797 kcal/mol 0.919 Angstroms\n",
" 6 / 10 : 21.315 kcal/mol -13.756 kcal/mol 0.588 Angstroms\n",
" 7 / 10 : 24.900 kcal/mol -10.122 kcal/mol 0.693 Angstroms\n",
" 8 / 10 : 14.714 kcal/mol -12.981 kcal/mol 0.715 Angstroms\n",
" 9 / 10 : 18.114 kcal/mol -13.708 kcal/mol 0.925 Angstroms\n",
" 10 / 10 : 21.270 kcal/mol -14.699 kcal/mol 0.776 Angstroms\n"
]
}
],
Expand Down Expand Up @@ -216,6 +216,13 @@
" # Clean up OpenMM Simulation\n",
" del simulation, integrator"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
9 changes: 6 additions & 3 deletions examples/conformer_energies/conformer_energies.py
Expand Up @@ -34,10 +34,11 @@ def compute_conformer_energies_from_file(filename):
f"{n_molecules} unique molecule(s) loaded, with {n_conformers} total conformers"
)

# Load the openff-1.1.0 force field appropriate for vacuum calculations (without constraints)
# Load the openff-2.0.0 force field appropriate for vacuum calculations (without constraints)
from openff.toolkit.typing.engines.smirnoff import ForceField

forcefield = ForceField("openff_unconstrained-1.1.0.offxml")
forcefield_str = "openff_unconstrained-2.0.0.offxml"
forcefield = ForceField(forcefield_str)
# Loop over molecules and minimize each conformer
for molecule in molecules:
# If the molecule doesn't have a name, set mol.name to be the hill formula
Expand All @@ -58,7 +59,9 @@ def compute_conformer_energies_from_file(filename):

# Print text header
print(
"Conformer Initial PE Minimized PE RMS between initial and minimized conformer"
"Using force field",
forcefield_str,
"\nConformer Initial PE Minimized PE RMS between initial and minimized conformer",
)
output = [
[
Expand Down
1 change: 1 addition & 0 deletions examples/environment.yaml
Expand Up @@ -16,3 +16,4 @@ dependencies:
- mdtraj
- numpy
- openmm
- openff-forcefields >=2.0.0

0 comments on commit 36f3c75

Please sign in to comment.