Jupyter Notebook Amber Constant pH MD Setup tutorial using Biobb.
Help improve this workflow!
This workflow has been published but could be further improved with some additional meta data:- Keyword(s) in categories input, output
You can help improve this workflow by suggesting the addition or removal of keywords, suggest changes and report issues, or request to become a maintainer of the Workflow .
Based on the official GROMACS tutorial .
This tutorials aim to illustrate the process of setting up a simulation system containing a protein , step by step, using the BioExcel Building Blocks library (biobb) wrapping the Ambertools MD package .
Settings
Biobb modules used
-
biobb_io : Tools to fetch biomolecular data from public databases.
-
biobb_amber : Tools to setup and run Molecular Dynamics simulations using the Ambertools MD package.
-
biobb_analysis : Tools to analyse Molecular Dynamics trajectories.
-
biobb_structure_utils : Tools to modify or extract information from a PDB structure file.
-
biobb_chemistry : Tools to to perform chemical conversions.
Auxiliar libraries used
-
nb_conda_kernels : Enables a Jupyter Notebook or JupyterLab application in one conda environment to access kernels for Python, R, and other languages found in other environments.
-
jupyter_contrib_nbextensions : Contains a collection of community-contributed unofficial extensions that add functionality to the Jupyter notebook.
-
nglview : Jupyter/IPython widget to interactively view molecular structures and trajectories in notebooks.
-
ipywidgets : Interactive HTML widgets for Jupyter notebooks and the IPython kernel.
-
plotly : Python interactive graphing library integrated in Jupyter notebooks.
-
simpletraj : Lightweight coordinate-only trajectory reader based on code from GROMACS, MDAnalysis and VMD.
-
gfortran : Fortran 95/2003/2008/2018 compiler for GCC, the GNU Compiler Collection.
Conda Installation
Take into account that, for this specific workflow, there are two environment files, one for linux OS and the other for mac OS:
linux
git clone https://github.com/bioexcel/biobb_wf_amber_md_setup.git
cd biobb_wf_amber_md_setup
conda env create -f conda_env/environment.linux.yml
conda activate biobb_AMBER_MDsetup_tutorials
jupyter nbextension enable python-markdown/main
macos
git clone https://github.com/bioexcel/biobb_wf_amber_md_setup.git
cd biobb_wf_amber_md_setup
conda env create -f conda_env/environment.macos.yml
conda activate biobb_AMBER_MDsetup_tutorials
jupyter nbextension enable python-markdown/main
Please execute the following commands before launching the Jupyter Notebook if you experience some issues with widgets such as NGL View (3D molecular visualization):
jupyter-nbextension enable --py --user widgetsnbextension
jupyter-nbextension enable --py --user nglview
Launch
Protein MD Setup tutorial
jupyter-notebook biobb_wf_amber_md_setup/notebooks/mdsetup/biobb_amber_setup_notebook.ipynb
Protein-Ligand Complex MD Setup tutorial
jupyter-notebook biobb_wf_amber_md_setup/notebooks/mdsetup_lig/biobb_amber_complex_setup_notebook.ipynb
Constant pH MD Setup tutorial
jupyter-notebook biobb_wf_amber_md_setup/notebooks/mdsetup_ph/biobb_amber_CpHMD_notebook.ipynb
ABC MD Setup tutorial
jupyter-notebook biobb_wf_amber_md_setup/notebooks/abcsetup/biobb_amber_ABC_setup.ipynb
Version
2023.3 Release
Copyright & Licensing
This software has been developed in the MMB group at the BSC & IRB for the European BioExcel , funded by the European Commission (EU H2020 823830 , EU H2020 675728 ).
-
(c) 2015-2023 Barcelona Supercomputing Center
-
(c) 2015-2023 Institute for Research in Biomedicine
Licensed under the Apache License 2.0 , see the file LICENSE for details.
Code Snippets
2 3 4 5 6 7 8 | import nglview import ipywidgets import plotly from plotly import subplots import plotly.graph_objs as go pdbCode="6PTI" |
12 13 14 15 16 17 18 19 20 21 22 23 24 | # Import module from biobb_io.api.pdb import pdb # Create properties dict and inputs/outputs downloaded_pdb = pdbCode+'.pdb' prop = { 'pdb_code': pdbCode } #Create and launch bb pdb(output_pdb_path=downloaded_pdb, properties=prop) |
28 29 30 31 32 | # Show protein view = nglview.show_structure_file(downloaded_pdb) view.add_representation(repr_type='ball+stick', selection='all') view._remote_call('setSize', target='Widget', args=['','600px']) view |
36 37 38 39 40 41 42 43 44 45 46 47 48 49 | # Import module from biobb_amber.pdb4amber.pdb4amber_run import pdb4amber_run # Create prop dict and inputs/outputs output_pdb4amber_path = 'structure.pdb4amber.pdb' prop = { 'constant_pH' : True } # Create and launch bb pdb4amber_run(input_pdb_path=downloaded_pdb, output_pdb_path=output_pdb4amber_path, properties=prop) |
53 54 55 56 57 58 | # Show protein view = nglview.show_structure_file(output_pdb4amber_path) view.add_representation(repr_type='ball+stick', selection='all') view.add_representation(repr_type='ball+stick', radius='0.5', selection='GL4 AS4') view._remote_call('setSize', target='Widget', args=['','600px']) view |
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | # Import module from biobb_amber.leap.leap_gen_top import leap_gen_top # Create prop dict and inputs/outputs output_pdb_path = 'structure.leap.pdb' output_top_path = 'structure.leap.top' output_crd_path = 'structure.leap.crd' prop = { "forcefield" : ["protein.ff14SB","constph"] } # Create and launch bb leap_gen_top(input_pdb_path=output_pdb4amber_path, output_pdb_path=output_pdb_path, output_top_path=output_top_path, output_crd_path=output_crd_path, properties=prop) |
83 84 85 86 87 88 | # Show protein view = nglview.show_structure_file(output_pdb_path) view.add_representation(repr_type='ball+stick', selection='all') view.add_representation(repr_type='ball+stick', radius='0.3', selection='GL4 AS4') view._remote_call('setSize', target='Widget', args=['','600px']) view |
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | # Import module from biobb_amber.leap.leap_solvate import leap_solvate # Create prop dict and inputs/outputs output_solv_pdb_path = 'structure.solv.pdb' output_solv_top_path = 'structure.solv.parmtop' output_solv_crd_path = 'structure.solv.crd' prop = { "forcefield" : ["protein.ff14SB","constph"], "water_type": "TIP3PBOX", "distance_to_molecule": "9.0", "box_type": "truncated_octahedron" } # Create and launch bb leap_solvate(input_pdb_path=output_pdb_path, output_pdb_path=output_solv_pdb_path, output_top_path=output_solv_top_path, output_crd_path=output_solv_crd_path, properties=prop) |
116 117 118 119 120 121 122 123 | # Show protein view = nglview.show_structure_file(output_solv_pdb_path) view.clear_representations() view.add_representation(repr_type='cartoon', selection='protein') view.add_representation(repr_type='ball+stick', selection='protein') view.add_representation(repr_type='line', selection='solvent') view._remote_call('setSize', target='Widget', args=['','600px']) view |
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | # Import module from biobb_amber.leap.leap_add_ions import leap_add_ions # Create prop dict and inputs/outputs output_ions_pdb_path = 'structure.ions.pdb' output_ions_top_path = 'structure.ions.parmtop' output_ions_crd_path = 'structure.ions.crd' prop = { "forcefield" : ["protein.ff14SB","constph"], "neutralise" : True, "box_type": "truncated_octahedron" } # Create and launch bb leap_add_ions(input_pdb_path=output_solv_pdb_path, output_pdb_path=output_ions_pdb_path, output_top_path=output_ions_top_path, output_crd_path=output_ions_crd_path, properties=prop) |
150 151 152 153 154 155 156 157 158 | # Show protein view = nglview.show_structure_file(output_ions_pdb_path) view.clear_representations() view.add_representation(repr_type='cartoon', selection='protein') view.add_representation(repr_type='ball+stick', selection='protein') view.add_representation(repr_type='line', selection='solvent') view.add_representation(repr_type='spacefill', selection='Cl- Na+', color='green') view._remote_call('setSize', target='Widget', args=['','600px']) view |
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | # Import module from biobb_amber.parmed.parmed_cpinutil import parmed_cpinutil # Create prop dict and inputs/outputs output_cpin_path = 'structure.cpin' output_top_cpin_path = 'structure.cpH.parmtop' prop = { "igb" : 2, "resnames": "AS4 GL4 CYS LYS TYR", # No Histidines in our structure "system": "BPTI" } # Create and launch bb parmed_cpinutil(input_top_path=output_ions_top_path, output_cpin_path=output_cpin_path, output_top_path=output_top_cpin_path, properties=prop) |
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | # Import module from biobb_amber.sander.sander_mdrun import sander_mdrun # Create prop dict and inputs/outputs output_min_traj_path = 'sander.cpH.x' output_min_rst_path = 'sander.cpH.rst' output_min_log_path = 'sander.cpH.log' prop = { "simulation_type" : "minimization", "mdin" : { 'maxcyc' : 500, 'ntr' : 1, # Turn on positional restraints 'restraint_wt' : 10, # 10 kcal/mol/A**2 restraint force constant 'restraintmask' : '\"@CA,C,O,N\"' # Restraints on the backbone atoms only } } # Create and launch bb sander_mdrun(input_top_path=output_top_cpin_path, input_crd_path=output_ions_crd_path, input_ref_path=output_ions_crd_path, output_traj_path=output_min_traj_path, output_rst_path=output_min_rst_path, output_log_path=output_min_log_path, properties=prop) |
212 213 214 215 216 217 218 219 220 221 222 223 224 225 | # Import module from biobb_amber.process.process_minout import process_minout # Create prop dict and inputs/outputs output_h_min_dat_path = 'sander.min.energy.dat' prop = { "terms" : ['ENERGY'] } # Create and launch bb process_minout(input_log_path=output_min_log_path, output_dat_path=output_h_min_dat_path, properties=prop) |
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | # Read data from file and filter energy values higher than 1000 Kj/mol^-1 with open(output_h_min_dat_path,'r') as energy_file: x,y = map( list, zip(*[ (float(line.split()[0]),float(line.split()[1])) for line in energy_file if not line.startswith(("#","@")) if float(line.split()[1]) < 1000 ]) ) plotly.offline.init_notebook_mode(connected=True) fig = { "data": [go.Scatter(x=x, y=y)], "layout": go.Layout(title="Energy Minimization", xaxis=dict(title = "Energy Minimization Step"), yaxis=dict(title = "Potential Energy kcal/mol") ) } plotly.offline.iplot(fig) |
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | # Import module from biobb_amber.sander.sander_mdrun import sander_mdrun # Create prop dict and inputs/outputs output_heat_traj_path = 'sander.heat.netcdf' output_heat_rst_path = 'sander.heat.rst' output_heat_log_path = 'sander.heat.log' prop = { "simulation_type" : "heat", "mdin" : { 'nstlim' : 2500, # Reducing the number of steps for the sake of time (5ps) 'ntr' : 1, # Turn on positional restraints 'restraintmask' : '\"@CA,C,O,N\"', # Restraining protein backbone atoms 'restraint_wt' : 2.0 # With a force constant of 2 Kcal/mol*A2 } } # Create and launch bb sander_mdrun(input_top_path=output_top_cpin_path, input_crd_path=output_min_rst_path, input_ref_path=output_min_rst_path, output_traj_path=output_heat_traj_path, output_rst_path=output_heat_rst_path, output_log_path=output_heat_log_path, properties=prop) |
284 285 286 287 288 289 290 291 292 293 294 295 296 297 | # Import module from biobb_amber.process.process_mdout import process_mdout # Create prop dict and inputs/outputs output_dat_heat_path = 'sander.md.temp.dat' prop = { "terms" : ['TEMP'] } # Create and launch bb process_mdout(input_log_path=output_heat_log_path, output_dat_path=output_dat_heat_path, properties=prop) |
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | #Read data from file and filter energy values higher than 1000 Kj/mol^-1 with open(output_dat_heat_path,'r') as energy_file: x,y = map( list, zip(*[ (float(line.split()[0]),float(line.split()[1])) for line in energy_file if not line.startswith(("#","@")) if float(line.split()[1]) < 1000 ]) ) plotly.offline.init_notebook_mode(connected=True) fig = { "data": [go.Scatter(x=x, y=y)], "layout": go.Layout(title="Heating process", xaxis=dict(title = "Heating Step (ps)"), yaxis=dict(title = "Temperature (K)") ) } plotly.offline.iplot(fig) |
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | # Import module from biobb_amber.sander.sander_mdrun import sander_mdrun # Create prop dict and inputs/outputs output_nvt_traj_path = 'sander.nvt.netcdf' output_nvt_rst_path = 'sander.nvt.rst' output_nvt_log_path = 'sander.nvt.log' prop = { "simulation_type" : 'nvt', "mdin" : { 'nstlim' : 500, # Reducing the number of steps for the sake of time (1ps) 'ntr' : 1, # Turn on positional restraints 'restraintmask' : '\"@CA,C,O,N\"', # Restraining protein backbone atoms 'restraint_wt' : 0.1 # With a force constant of 0.1 Kcal/mol*A2 } } # Create and launch bb sander_mdrun(input_top_path=output_top_cpin_path, input_crd_path=output_heat_rst_path, input_ref_path=output_heat_rst_path, output_traj_path=output_nvt_traj_path, output_rst_path=output_nvt_rst_path, output_log_path=output_nvt_log_path, properties=prop) |
356 357 358 359 360 361 362 363 364 365 366 367 368 369 | # Import module from biobb_amber.process.process_mdout import process_mdout # Create prop dict and inputs/outputs output_dat_nvt_path = 'sander.md.nvt.temp.dat' prop = { "terms" : ['TEMP'] } # Create and launch bb process_mdout(input_log_path=output_nvt_log_path, output_dat_path=output_dat_nvt_path, properties=prop) |
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | #Read data from file and filter energy values higher than 1000 Kj/mol^-1 with open(output_dat_nvt_path,'r') as energy_file: x,y = map( list, zip(*[ (float(line.split()[0]),float(line.split()[1])) for line in energy_file if not line.startswith(("#","@")) if float(line.split()[1]) < 1000 ]) ) plotly.offline.init_notebook_mode(connected=True) fig = { "data": [go.Scatter(x=x, y=y)], "layout": go.Layout(title="NVT equilibration", xaxis=dict(title = "Equilibration Step (ps)"), yaxis=dict(title = "Temperature (K)") ) } plotly.offline.iplot(fig) |
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | # Import module from biobb_amber.sander.sander_mdrun import sander_mdrun # Create prop dict and inputs/outputs output_npt_traj_path = 'sander.npt.netcdf' output_npt_rst_path = 'sander.npt.rst' output_npt_log_path = 'sander.npt.log' prop = { "simulation_type" : 'npt', "mdin" : { 'nstlim' : 500, # Reducing the number of steps for the sake of time (1ps) 'ntr' : 1, # Turn on positional restraints 'restraintmask' : '\"@CA,C,O,N\"', # Restraining protein backbone atoms 'restraint_wt' : 0.1 # With a force constant of 0.1 Kcal/mol*A2 } } # Create and launch bb sander_mdrun(input_top_path=output_top_cpin_path, input_crd_path=output_nvt_rst_path, input_ref_path=output_nvt_rst_path, output_traj_path=output_npt_traj_path, output_rst_path=output_npt_rst_path, output_log_path=output_npt_log_path, properties=prop) |
428 429 430 431 432 433 434 435 436 437 438 439 440 441 | # Import module from biobb_amber.process.process_mdout import process_mdout # Create prop dict and inputs/outputs output_dat_npt_path = 'sander.md.npt.dat' prop = { "terms" : ['PRES','DENSITY'] } # Create and launch bb process_mdout(input_log_path=output_npt_log_path, output_dat_path=output_dat_npt_path, properties=prop) |
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 | # Read pressure and density data from file with open(output_dat_npt_path,'r') as pd_file: x,y,z = map( list, zip(*[ (float(line.split()[0]),float(line.split()[1]),float(line.split()[2])) for line in pd_file if not line.startswith(("#","@")) ]) ) plotly.offline.init_notebook_mode(connected=True) trace1 = go.Scatter( x=x,y=y ) trace2 = go.Scatter( x=x,y=z ) fig = subplots.make_subplots(rows=1, cols=2, print_grid=False) fig.append_trace(trace1, 1, 1) fig.append_trace(trace2, 1, 2) fig['layout']['xaxis1'].update(title='Time (ps)') fig['layout']['xaxis2'].update(title='Time (ps)') fig['layout']['yaxis1'].update(title='Pressure (bar)') fig['layout']['yaxis2'].update(title='Density (Kg*m^-3)') fig['layout'].update(title='Pressure and Density during NPT Equilibration') fig['layout'].update(showlegend=False) plotly.offline.iplot(fig) |
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | # Import module from biobb_amber.sander.sander_mdrun import sander_mdrun # Create prop dict and inputs/outputs output_pH_traj_path = 'sander.pH.netcdf' output_pH_rst_path = 'sander.pH.rst' output_pH_cpout_path = 'sander.pH.cpout' output_pH_cprst_path = 'sander.pH.cprst' output_pH_log_path = 'sander.pH.log' output_pH_mdinfo_path = 'sander.pH.mdinfo' prop = { "simulation_type" : 'free', "mdin" : { 'nstlim' : 2500, # Reducing the number of steps for the sake of time (5ps) 'ntwx' : 500, # Print coords to trajectory every 500 steps (1 ps) 'icnstph' : 2, # Turn on constant pH for explicit solvent 'saltcon' : 0.1, # Use the salt concentration CpHMD was parameterized for 'ntcnstph' : 100, # Protonation state change attempt every 100 steps 'ntrelax' : 100, # Number of relaxation steps after a successful protonation state change 'solvph' : 7.0, # Solvent pH # 'solvph' : 3.0, # Acid pH # 'solvph' : 10.0, # Basic (alkaline) pH } } # Create and launch bb sander_mdrun(input_top_path=output_top_cpin_path, input_crd_path=output_npt_rst_path, input_cpin_path=output_cpin_path, output_traj_path=output_pH_traj_path, output_rst_path=output_pH_rst_path, output_cpout_path=output_pH_cpout_path, output_cprst_path=output_pH_cprst_path, output_log_path=output_pH_log_path, output_mdinfo_path=output_pH_mdinfo_path, properties=prop) |
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 | # Import module from biobb_amber.cphstats.cphstats_run import cphstats_run # Create prop dict and inputs/outputs output_pH_dat_path = 'cphstats.pH.dat' output_pH_pop_path = 'cphstats.pH.pop.dat' prop = { 'verbose' : True, 'running_avg_window' : 1 } # Create and launch bb cphstats_run(input_cpin_path=output_cpin_path, input_cpout_path=output_pH_cpout_path, output_dat_path=output_pH_dat_path, output_population_path=output_pH_pop_path, properties=prop) |
Support
- Future updates
Related Workflows





