Jupyter Notebook Amber Protein Ligand Complex 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 9 10 | import nglview import ipywidgets import plotly from plotly import subplots import plotly.graph_objs as go pdbCode = "3htb" ligandCode = "JZ4" mol_charge = 0 |
14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # Import module from biobb_io.api.pdb import pdb # Create properties dict and inputs/outputs downloaded_pdb = pdbCode+'.pdb' prop = { 'pdb_code': pdbCode, 'filter': False } #Create and launch bb pdb(output_pdb_path=downloaded_pdb, properties=prop) |
31 32 33 34 35 36 37 38 39 | # Show protein view = nglview.show_structure_file(downloaded_pdb) view.clear_representations() view.add_representation(repr_type='cartoon', selection='protein', color='sstruc') view.add_representation(repr_type='ball+stick', radius='0.1', selection='water') view.add_representation(repr_type='ball+stick', radius='0.5', selection='ligand') view.add_representation(repr_type='ball+stick', radius='0.5', selection='ion') view._remote_call('setSize', target='Widget', args=['','600px']) view |
43 44 45 46 47 48 49 50 51 | # Import module from biobb_structure_utils.utils.remove_pdb_water import remove_pdb_water # Create properties dict and inputs/outputs nowat_pdb = pdbCode+'.nowat.pdb' #Create and launch bb remove_pdb_water(input_pdb_path=downloaded_pdb, output_pdb_path=nowat_pdb) |
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | # Import module from biobb_structure_utils.utils.remove_ligand import remove_ligand # Removing PO4 ligands: # Create properties dict and inputs/outputs nopo4_pdb = pdbCode+'.noPO4.pdb' prop = { 'ligand' : 'PO4' } #Create and launch bb remove_ligand(input_structure_path=nowat_pdb, output_structure_path=nopo4_pdb, properties=prop) # Removing BME ligand: # Create properties dict and inputs/outputs nobme_pdb = pdbCode+'.noBME.pdb' prop = { 'ligand' : 'BME' } #Create and launch bb remove_ligand(input_structure_path=nopo4_pdb, output_structure_path=nobme_pdb, properties=prop) |
88 89 90 91 92 93 94 | # Show protein view = nglview.show_structure_file(nobme_pdb) view.clear_representations() view.add_representation(repr_type='cartoon', selection='protein', color='sstruc') view.add_representation(repr_type='ball+stick', radius='0.5', selection='hetero') view._remote_call('setSize', target='Widget', args=['','600px']) view |
98 99 100 101 102 103 104 105 106 107 | # Import module from biobb_amber.pdb4amber.pdb4amber_run import pdb4amber_run # Create prop dict and inputs/outputs output_pdb4amber_path = 'structure.pdb4amber.pdb' # Create and launch bb pdb4amber_run(input_pdb_path=nobme_pdb, output_pdb_path=output_pdb4amber_path, properties=prop) |
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | # Create Ligand system topology, STEP 1 # Extracting Ligand JZ4 # Import module from biobb_structure_utils.utils.extract_heteroatoms import extract_heteroatoms # Create properties dict and inputs/outputs ligandFile = ligandCode+'.pdb' prop = { 'heteroatoms' : [{"name": "JZ4"}] } extract_heteroatoms(input_structure_path=output_pdb4amber_path, output_heteroatom_path=ligandFile, properties=prop) |
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | # Create Ligand system topology, STEP 2 # Reduce_add_hydrogens: add Hydrogen atoms to a small molecule (using Reduce tool from Ambertools package) # Import module from biobb_chemistry.ambertools.reduce_add_hydrogens import reduce_add_hydrogens # Create prop dict and inputs/outputs output_reduce_h = ligandCode+'.reduce.H.pdb' prop = { 'nuclear' : 'true' } # Create and launch bb reduce_add_hydrogens(input_path=ligandFile, output_path=output_reduce_h, properties=prop) |
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | # Create Ligand system topology, STEP 3 # Babel_minimize: Structure energy minimization of a small molecule after being modified adding hydrogen atoms # Import module from biobb_chemistry.babelm.babel_minimize import babel_minimize # Create prop dict and inputs/outputs output_babel_min = ligandCode+'.H.min.mol2' prop = { 'method' : 'sd', 'criteria' : '1e-10', 'force_field' : 'GAFF' } # Create and launch bb babel_minimize(input_path=output_reduce_h, output_path=output_babel_min, properties=prop) |
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | # Show different structures generated (for comparison) view1 = nglview.show_structure_file(ligandFile) view1.add_representation(repr_type='ball+stick') view1._remote_call('setSize', target='Widget', args=['350px','400px']) view1.camera='orthographic' view1 view2 = nglview.show_structure_file(output_reduce_h) view2.add_representation(repr_type='ball+stick') view2._remote_call('setSize', target='Widget', args=['350px','400px']) view2.camera='orthographic' view2 view3 = nglview.show_structure_file(output_babel_min) view3.add_representation(repr_type='ball+stick') view3._remote_call('setSize', target='Widget', args=['350px','400px']) view3.camera='orthographic' view3 ipywidgets.HBox([view1, view2, view3]) |
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | # Create Ligand system topology, STEP 4 # Acpype_params_gmx: Generation of topologies for AMBER with ACPype # Import module from biobb_chemistry.acpype.acpype_params_ac import acpype_params_ac # Create prop dict and inputs/outputs output_acpype_inpcrd = ligandCode+'params.inpcrd' output_acpype_frcmod = ligandCode+'params.frcmod' output_acpype_lib = ligandCode+'params.lib' output_acpype_prmtop = ligandCode+'params.prmtop' output_acpype = ligandCode+'params' prop = { 'basename' : output_acpype, 'charge' : mol_charge } # Create and launch bb acpype_params_ac(input_path=output_babel_min, output_path_inpcrd=output_acpype_inpcrd, output_path_frcmod=output_acpype_frcmod, output_path_lib=output_acpype_lib, output_path_prmtop=output_acpype_prmtop, properties=prop) |
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | # 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","gaff"] } # Create and launch bb leap_gen_top(input_pdb_path=output_pdb4amber_path, input_lib_path=output_acpype_lib, input_frcmod_path=output_acpype_frcmod, output_pdb_path=output_pdb_path, output_top_path=output_top_path, output_crd_path=output_crd_path, properties=prop) |
241 242 243 244 245 246 247 248 249 250 251 | import nglview import ipywidgets # Show protein view = nglview.show_structure_file(output_pdb_path) view.clear_representations() view.add_representation(repr_type='cartoon', selection='protein', opacity='0.4') view.add_representation(repr_type='ball+stick', selection='protein') view.add_representation(repr_type='ball+stick', radius='0.5', selection='JZ4') view._remote_call('setSize', target='Widget', args=['','600px']) view |
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 281 | # Import module from biobb_amber.sander.sander_mdrun import sander_mdrun # Create prop dict and inputs/outputs output_h_min_traj_path = 'sander.h_min.x' output_h_min_rst_path = 'sander.h_min.rst' output_h_min_log_path = 'sander.h_min.log' prop = { 'simulation_type' : "min_vacuo", "mdin" : { 'maxcyc' : 500, 'ntpr' : 5, 'ntr' : 1, 'restraintmask' : '\":*&!@H=\"', 'restraint_wt' : 50.0 } } # Create and launch bb sander_mdrun(input_top_path=output_top_path, input_crd_path=output_crd_path, input_ref_path=output_crd_path, output_traj_path=output_h_min_traj_path, output_rst_path=output_h_min_rst_path, output_log_path=output_h_min_log_path, properties=prop) |
285 286 287 288 289 290 291 292 293 294 295 296 297 298 | # Import module from biobb_amber.process.process_minout import process_minout # Create prop dict and inputs/outputs output_h_min_dat_path = 'sander.h_min.energy.dat' prop = { "terms" : ['ENERGY'] } # Create and launch bb process_minout(input_log_path=output_h_min_log_path, output_dat_path=output_h_min_dat_path, properties=prop) |
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | #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) |
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_n_min_traj_path = 'sander.n_min.x' output_n_min_rst_path = 'sander.n_min.rst' output_n_min_log_path = 'sander.n_min.log' prop = { 'simulation_type' : "min_vacuo", "mdin" : { 'maxcyc' : 500, 'ntpr' : 5, 'restraintmask' : '\":' + ligandCode + '\"', 'restraint_wt' : 500.0 } } # Create and launch bb sander_mdrun(input_top_path=output_top_path, input_crd_path=output_h_min_rst_path, output_traj_path=output_n_min_traj_path, output_rst_path=output_n_min_rst_path, output_log_path=output_n_min_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_minout import process_minout # Create prop dict and inputs/outputs output_n_min_dat_path = 'sander.n_min.energy.dat' prop = { "terms" : ['ENERGY'] } # Create and launch bb process_minout(input_log_path=output_n_min_log_path, output_dat_path=output_n_min_dat_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_n_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) |
399 400 401 402 403 404 405 406 407 408 | # Import module from biobb_amber.ambpdb.amber_to_pdb import amber_to_pdb # Create prop dict and inputs/outputs output_ambpdb_path = 'structure.ambpdb.pdb' # Create and launch bb amber_to_pdb(input_top_path=output_top_path, input_crd_path=output_h_min_rst_path, output_pdb_path=output_ambpdb_path) |
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | # 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","gaff"], "water_type": "TIP3PBOX", "distance_to_molecule": "9.0", "box_type": "truncated_octahedron" } # Create and launch bb leap_solvate(input_pdb_path=output_ambpdb_path, input_lib_path=output_acpype_lib, input_frcmod_path=output_acpype_frcmod, output_pdb_path=output_solv_pdb_path, output_top_path=output_solv_top_path, output_crd_path=output_solv_crd_path, properties=prop) |
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 | # 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","gaff"], "neutralise" : True, "positive_ions_type": "Na+", "negative_ions_type": "Cl-", "ionic_concentration" : 150, # 150mM "box_type": "truncated_octahedron" } # Create and launch bb leap_add_ions(input_pdb_path=output_solv_pdb_path, input_lib_path=output_acpype_lib, input_frcmod_path=output_acpype_frcmod, output_pdb_path=output_ions_pdb_path, output_top_path=output_ions_top_path, output_crd_path=output_ions_crd_path, properties=prop) |
466 467 468 469 470 471 472 473 | # 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='solvent') view.add_representation(repr_type='spacefill', selection='Cl- Na+') view._remote_call('setSize', target='Widget', args=['','600px']) view |
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | # Import module from biobb_amber.sander.sander_mdrun import sander_mdrun # Create prop dict and inputs/outputs output_min_traj_path = 'sander.min.x' output_min_rst_path = 'sander.min.rst' output_min_log_path = 'sander.min.log' prop = { "simulation_type" : "minimization", "mdin" : { 'maxcyc' : 300, # Reducing the number of minimization steps for the sake of time 'ntr' : 1, # Overwritting restrain parameter 'restraintmask' : '\"!:WAT,Cl-,Na+\"', # Restraining solute 'restraint_wt' : 15.0 # With a force constant of 50 Kcal/mol*A2 } } # Create and launch bb sander_mdrun(input_top_path=output_ions_top_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) |
506 507 508 509 510 511 512 513 514 515 516 517 518 519 | # Import module from biobb_amber.process.process_minout import process_minout # Create prop dict and inputs/outputs output_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_dat_path, properties=prop) |
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 | #Read data from file and filter energy values higher than 1000 Kj/mol^-1 with open(output_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) |
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 | # 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, # Overwritting restrain parameter 'restraintmask' : '\"!:WAT,Cl-,Na+\"', # Restraining solute 'restraint_wt' : 10.0 # With a force constant of 10 Kcal/mol*A2 } } # Create and launch bb sander_mdrun(input_top_path=output_ions_top_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) |
578 579 580 581 582 583 584 585 586 587 588 589 590 591 | # 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) |
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 | #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) |
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 | # 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, # Overwritting restrain parameter 'restraintmask' : '\"!:WAT,Cl-,Na+ & !@H=\"', # Restraining solute heavy atoms 'restraint_wt' : 5.0 # With a force constant of 5 Kcal/mol*A2 } } # Create and launch bb sander_mdrun(input_top_path=output_ions_top_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) |
650 651 652 653 654 655 656 657 658 659 660 661 662 663 | # 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) |
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 | #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) |
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 | # 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, # Overwritting restrain parameter 'restraintmask' : '\"!:WAT,Cl-,Na+ & !@H=\"', # Restraining solute heavy atoms 'restraint_wt' : 2.5 # With a force constant of 2.5 Kcal/mol*A2 } } # Create and launch bb sander_mdrun(input_top_path=output_ions_top_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) |
722 723 724 725 726 727 728 729 730 731 732 733 734 735 | # 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) |
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 | # 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) |
776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 | # Import module from biobb_amber.sander.sander_mdrun import sander_mdrun # Create prop dict and inputs/outputs output_free_traj_path = 'sander.free.netcdf' output_free_rst_path = 'sander.free.rst' output_free_log_path = 'sander.free.log' 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) } } # Create and launch bb sander_mdrun(input_top_path=output_ions_top_path, input_crd_path=output_npt_rst_path, output_traj_path=output_free_traj_path, output_rst_path=output_free_rst_path, output_log_path=output_free_log_path, properties=prop) |
802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 | # cpptraj_rms: Computing Root Mean Square deviation to analyse structural stability # RMSd against minimized and equilibrated snapshot (backbone atoms) # Import module from biobb_analysis.ambertools.cpptraj_rms import cpptraj_rms # Create prop dict and inputs/outputs output_rms_first = pdbCode+'_rms_first.dat' prop = { 'mask': 'backbone', 'reference': 'first' } # Create and launch bb cpptraj_rms(input_top_path=output_ions_top_path, input_traj_path=output_free_traj_path, output_cpptraj_path=output_rms_first, properties=prop) |
824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 | # cpptraj_rms: Computing Root Mean Square deviation to analyse structural stability # RMSd against experimental structure (backbone atoms) # Import module from biobb_analysis.ambertools.cpptraj_rms import cpptraj_rms # Create prop dict and inputs/outputs output_rms_exp = pdbCode+'_rms_exp.dat' prop = { 'mask': 'backbone', 'reference': 'experimental' } # Create and launch bb cpptraj_rms(input_top_path=output_ions_top_path, input_traj_path=output_free_traj_path, output_cpptraj_path=output_rms_exp, input_exp_path=output_pdb_path, properties=prop) |
847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 | # Read RMS vs first snapshot data from file with open(output_rms_first,'r') as rms_first_file: x,y = map( list, zip(*[ (float(line.split()[0]),float(line.split()[1])) for line in rms_first_file if not line.startswith(("#","@")) ]) ) # Read RMS vs experimental structure data from file with open(output_rms_exp,'r') as rms_exp_file: x2,y2 = map( list, zip(*[ (float(line.split()[0]),float(line.split()[1])) for line in rms_exp_file if not line.startswith(("#","@")) ]) ) trace1 = go.Scatter( x = x, y = y, name = 'RMSd vs first' ) trace2 = go.Scatter( x = x, y = y2, name = 'RMSd vs exp' ) data = [trace1, trace2] plotly.offline.init_notebook_mode(connected=True) fig = { "data": data, "layout": go.Layout(title="RMSd during free MD Simulation", xaxis=dict(title = "Time (ps)"), yaxis=dict(title = "RMSd (Angstrom)") ) } plotly.offline.iplot(fig) |
897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 | # cpptraj_rgyr: Computing Radius of Gyration to measure the protein compactness during the free MD simulation # Import module from biobb_analysis.ambertools.cpptraj_rgyr import cpptraj_rgyr # Create prop dict and inputs/outputs output_rgyr = pdbCode+'_rgyr.dat' prop = { 'mask': 'backbone' } # Create and launch bb cpptraj_rgyr(input_top_path=output_ions_top_path, input_traj_path=output_free_traj_path, output_cpptraj_path=output_rgyr, properties=prop) |
917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 | # Read Rgyr data from file with open(output_rgyr,'r') as rgyr_file: x,y = map( list, zip(*[ (float(line.split()[0]),float(line.split()[1])) for line in rgyr_file if not line.startswith(("#","@")) ]) ) plotly.offline.init_notebook_mode(connected=True) fig = { "data": [go.Scatter(x=x, y=y)], "layout": go.Layout(title="Radius of Gyration", xaxis=dict(title = "Time (ps)"), yaxis=dict(title = "Rgyr (Angstrom)") ) } plotly.offline.iplot(fig) |
942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 | # cpptraj_image: "Imaging" the resulting trajectory # Removing water molecules and ions from the resulting structure # Import module from biobb_analysis.ambertools.cpptraj_image import cpptraj_image # Create prop dict and inputs/outputs output_imaged_traj = pdbCode+'_imaged_traj.trr' prop = { 'mask': 'solute', 'format': 'trr' } # Create and launch bb cpptraj_image(input_top_path=output_ions_top_path, input_traj_path=output_free_traj_path, output_cpptraj_path=output_imaged_traj, properties=prop) |
964 965 966 967 968 969 | # Show trajectory view = nglview.show_simpletraj(nglview.SimpletrajTrajectory(output_imaged_traj, output_ambpdb_path), gui=True) view.clear_representations() view.add_representation('cartoon', color='sstruc') view.add_representation('licorice', selection='JZ4', color='element', radius=1) view |
Support
- Future updates