Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tutorials #131

Merged
merged 5 commits into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions paprika/restraints/openmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ def apply_positional_restraints(

Parameters
----------
coordinate_path
coordinate_path : str
The path to the coordinate file which the restraints will be applied to.
This should contain either the host or the complex, the dummy atoms and
and solvent.
system: openmm.System
system : openmm.System
The system object to add the positional restraints to.
force_group
force_group : int
The force group to add the positional restraints to.
"""

Expand All @@ -35,7 +35,6 @@ def apply_positional_restraints(
for atom in structure.atoms:

if atom.name == "DUM":

positional_restraint = openmm.CustomExternalForce(
"k * ((x-x0)^2 + (y-y0)^2 + (z-z0)^2)"
)
Expand All @@ -62,6 +61,25 @@ def apply_positional_restraints(
def apply_dat_restraint(
system, restraint, phase, window_number, flat_bottom=False, force_group=None
):
"""A utility function which takes in pAPRika restraints and applies the
restraints to an OpenMM System object.

Parameters
----------
system : openmm.System
The system object to add the positional restraints to.
restraint : list
List of pAPRika defined restraints
phase : str
Phase of calculation ("attach", "pull" or "release")
window_number : int
The corresponding window number of the current phase
flat_bottom : bool
Specify whether the restraint is a flat bottom potential
force_group : int
The force group to add the positional restraints to.

"""

from simtk import openmm, unit

Expand Down
29 changes: 21 additions & 8 deletions tutorial/01-tutorial-cb6-but.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Align the pulling axis"
"### Align the pulling axis\n",
"<a id='guest'></a>"
]
},
{
Expand Down Expand Up @@ -490,10 +491,9 @@
"metadata": {},
"source": [
"## Add restraints using pAPRika\n",
"\n",
"<a id='host_static'></a>\n",
"`pAPRika` supports four different types of restraints:\n",
"\n",
"\n",
"- Static restraints: these six restraints keep the host and in the proper orientation during the simulation (necessary),\n",
"- Guest restraints: these restraints pull the guest away from the host along the $z$ axis (necessary),\n",
"- Conformational restraints: these restraints alter the conformational sampling of the host molecule (optional), and\n",
Expand Down Expand Up @@ -881,8 +881,9 @@
"outputs": [],
"source": [
"import os\n",
"from paprika.restraints.restraints import create_window_list\n",
"\n",
"window_list = restraints.create_window_list(guest_restraints)\n",
"window_list = create_window_list(guest_restraints)\n",
"for window in window_list:\n",
" os.makedirs(f\"windows/{window}\")"
]
Expand Down Expand Up @@ -914,11 +915,13 @@
},
"outputs": [],
"source": [
"from paprika.restraints.amber import amber_restraint_line\n",
"\n",
"host_guest_restraints = static_restraints + guest_restraints\n",
"for window in window_list:\n",
" with open(f\"windows/{window}/disang.rest\", \"a\") as file:\n",
" for restraint in host_guest_restraints:\n",
" string = restraints.amber_restraint_line(restraint, window)\n",
" string = amber_restraint_line(restraint, window)\n",
" if string is not None:\n",
" file.write(string)"
]
Expand Down Expand Up @@ -1451,6 +1454,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<a id='results'></a>\n",
"There is a large uncertainty associated with this calculation because we only simulated for a very short amount of time in each window and we used a large amount of spacing between each window in the pull phase, but the uncertainty will go down with more time.\n",
"\n",
"The experimental value is $-RT \\ln (280*10^3 M)$ = -7.44 kcal/mol."
Expand All @@ -1466,7 +1470,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python [default]",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -1480,9 +1484,18 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
"version": "3.7.8"
},
"pycharm": {
"stem_cell": {
"cell_type": "raw",
"source": [],
"metadata": {
"collapsed": false
}
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
}
18 changes: 15 additions & 3 deletions tutorial/02-tutorial-cb6-but-pbc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,9 @@
"outputs": [],
"source": [
"import os\n",
"from paprika.restraints.restraints import create_window_list\n",
"\n",
"window_list = restraints.create_window_list(guest_restraints)\n",
"window_list = create_window_list(guest_restraints)\n",
"for window in window_list:\n",
" os.makedirs(f\"windows/{window}\")"
]
Expand Down Expand Up @@ -550,11 +551,13 @@
},
"outputs": [],
"source": [
"from paprika.restraints.amber import amber_restraint_line\n",
"\n",
"host_guest_restraints = static_restraints + guest_restraints\n",
"for window in window_list:\n",
" with open(f\"windows/{window}/disang.rest\", \"a\") as file:\n",
" for restraint in host_guest_restraints:\n",
" string = restraints.amber_restraint_line(restraint, window)\n",
" string = amber_restraint_line(restraint, window)\n",
" if string is not None:\n",
" file.write(string)"
]
Expand Down Expand Up @@ -1264,8 +1267,17 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
},
"pycharm": {
"stem_cell": {
"cell_type": "raw",
"source": [],
"metadata": {
"collapsed": false
}
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
}
Loading