Jupyter Notebook 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 tutorial aims to illustrate the process of setting up a simulation system containing a protein in complex with a ligand , step by step, using the BioExcel Building Blocks library (biobb) . The particular example used is the T4 lysozyme L99A/M102Q protein (PDB code 3HTB), in complex with the 2-propylphenol small molecule (3-letter Code JZ4).
Settings
Biobb modules used
-
biobb_io : Tools to fetch biomolecular data from public databases.
-
biobb_model : Tools to model macromolecular structures.
-
biobb_chemistry : Tools to manipulate chemical data.
-
biobb_gromacs : Tools to setup and run Molecular Dynamics simulations.
-
biobb_analysis : Tools to analyse Molecular Dynamics trajectories.
-
biobb_structure_utils : Tools to modify or extract information from a PDB structure file.
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.
-
nglview : Jupyter/IPython widget to interactively view molecular structures and trajectories in notebooks.
-
ipywidgets : Interactive HTML widgets for Jupyter notebooks and the IPython kernel.
-
os : Python miscellaneous operating system interfaces
-
plotly : Python interactive graphing library integrated in Jupyter notebooks.
-
simpletraj : Lightweight coordinate-only trajectory reader based on code from GROMACS, MDAnalysis and VMD.
Conda Installation and Launch
git clone https://github.com/bioexcel/biobb_wf_protein-complex_md_setup.git
cd biobb_wf_protein-complex_md_setup
conda env create -f conda_env/environment.yml
conda activate biobb_Protein-Complex_MDsetup_tutorial
jupyter nbextension enable python-markdown/main
jupyter-notebook biobb_wf_protein-complex_md_setup/notebooks/biobb_Protein-Complex_MDsetup_tutorial.ipynb
Please execute the following commands before launching the Jupyter Notebook if you experience some
jupyter-nbextension enable --py --user widgetsnbextension
jupyter-nbextension enable --py --user nglview
Tutorial
Click here to view tutorial in Read the Docs
Version
2023.3
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 | import nglview import ipywidgets import os import zipfile pdbCode = "3HTB" ligandCode = "JZ4" mol_charge = 0 |
13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # Downloading desired PDB file # Import module from biobb_io.api.pdb import pdb # Create properties dict and inputs/outputs downloaded_pdb = pdbCode+'.orig.pdb' prop = { 'pdb_code': pdbCode, 'filter': False } # Create and launch bb pdb(output_pdb_path=downloaded_pdb, properties=prop) |
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | # Extracting Protein, Ligand and Protein-Ligand Complex to three different files # Import module from biobb_structure_utils.utils.extract_heteroatoms import extract_heteroatoms from biobb_structure_utils.utils.extract_molecule import extract_molecule from biobb_structure_utils.utils.cat_pdb import cat_pdb # Create properties dict and inputs/outputs proteinFile = pdbCode+'.pdb' ligandFile = ligandCode+'.pdb' complexFile = pdbCode+'_'+ligandCode+'.pdb' prop = { 'heteroatoms' : [{"name": "JZ4"}] } extract_heteroatoms(input_structure_path=downloaded_pdb, output_heteroatom_path=ligandFile, properties=prop) extract_molecule(input_structure_path=downloaded_pdb, output_molecule_path=proteinFile) print(proteinFile, ligandFile, complexFile) cat_pdb(input_structure1=proteinFile, input_structure2=ligandFile, output_structure_path=complexFile) |
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | # Show structures: protein, ligand and protein-ligand complex view1 = nglview.show_structure_file(proteinFile) view1._remote_call('setSize', target='Widget', args=['350px','400px']) view1.camera='orthographic' view1 view2 = nglview.show_structure_file(ligandFile) 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(complexFile) view3.add_representation(repr_type='licorice', radius='.5', selection=ligandCode) view3._remote_call('setSize', target='Widget', args=['350px','400px']) view3.camera='orthographic' view3 ipywidgets.HBox([view1, view2, view3]) |
79 80 81 82 83 84 85 86 87 88 | # Check & Fix Protein Structure # Import module from biobb_model.model.fix_side_chain import fix_side_chain # Create prop dict and inputs/outputs fixed_pdb = pdbCode+'_fixed.pdb' # Create and launch bb fix_side_chain(input_pdb_path=proteinFile, output_pdb_path=fixed_pdb) |
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | # Create Protein system topology # Import module from biobb_gromacs.gromacs.pdb2gmx import pdb2gmx # Create inputs/outputs output_pdb2gmx_gro = pdbCode+'_pdb2gmx.gro' output_pdb2gmx_top_zip = pdbCode+'_pdb2gmx_top.zip' prop = { 'force_field' : 'amber99sb-ildn', 'water_type': 'spce' } # Create and launch bb pdb2gmx(input_pdb_path=fixed_pdb, output_gro_path=output_pdb2gmx_gro, output_top_zip_path=output_pdb2gmx_top_zip, properties=prop) |
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | # Create Ligand system topology, STEP 1 # 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) |
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | # Create Ligand system topology, STEP 2 # 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) |
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | # 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]) |
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | # Create Ligand system topology, STEP 3 # Acpype_params_gmx: Generation of topologies for GROMACS with ACPype # Import module from biobb_chemistry.acpype.acpype_params_gmx import acpype_params_gmx # Create prop dict and inputs/outputs output_acpype_gro = ligandCode+'params.gro' output_acpype_itp = ligandCode+'params.itp' output_acpype_top = ligandCode+'params.top' output_acpype = ligandCode+'params' prop = { 'basename' : output_acpype, 'charge' : mol_charge } # Create and launch bb acpype_params_gmx(input_path=output_babel_min, output_path_gro=output_acpype_gro, output_path_itp=output_acpype_itp, output_path_top=output_acpype_top, properties=prop) |
196 197 198 199 200 201 202 203 204 205 206 207 208 | # MakeNdx: Creating index file with a new group (small molecule heavy atoms) from biobb_gromacs.gromacs.make_ndx import make_ndx # Create prop dict and inputs/outputs output_ligand_ndx = ligandCode+'_index.ndx' prop = { 'selection': "0 & ! a H*" } # Create and launch bb make_ndx(input_structure_path=output_acpype_gro, output_ndx_path=output_ligand_ndx, properties=prop) |
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | # Genrestr: Generating the position restraints file from biobb_gromacs.gromacs.genrestr import genrestr # Create prop dict and inputs/outputs output_restraints_top = ligandCode+'_posres.itp' prop = { 'force_constants': "1000 1000 1000", 'restrained_group': "System" } # Create and launch bb genrestr(input_structure_path=output_acpype_gro, input_ndx_path=output_ligand_ndx, output_itp_path=output_restraints_top, properties=prop) |
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | # biobb analysis module from biobb_analysis.gromacs.gmx_trjconv_str import gmx_trjconv_str from biobb_structure_utils.utils.cat_pdb import cat_pdb # Convert gro (with hydrogens) to pdb (PROTEIN) proteinFile_H = pdbCode+'_'+ligandCode+'_complex_H.pdb' prop = { 'selection' : 'System' } # Create and launch bb gmx_trjconv_str(input_structure_path=output_pdb2gmx_gro, input_top_path=output_pdb2gmx_gro, output_str_path=proteinFile_H, properties=prop) # Convert gro (with hydrogens) to pdb (LIGAND) ligandFile_H = ligandCode+'_complex_H.pdb' prop = { 'selection' : 'System' } # Create and launch bb gmx_trjconv_str(input_structure_path=output_acpype_gro, input_top_path=output_acpype_gro, output_str_path=ligandFile_H, properties=prop) # Concatenating both PDB files: Protein + Ligand complexFile_H = pdbCode+'_'+ligandCode+'_H.pdb' # Create and launch bb cat_pdb(input_structure1=proteinFile_H, input_structure2=ligandFile_H, output_structure_path=complexFile_H) |
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | # AppendLigand: Append a ligand to a GROMACS topology # Import module from biobb_gromacs.gromacs_extra.append_ligand import append_ligand # Create prop dict and inputs/outputs output_complex_top = pdbCode+'_'+ligandCode+'_complex.top.zip' posresifdef = "POSRES_"+ligandCode.upper() prop = { 'posres_name': posresifdef } # Create and launch bb append_ligand(input_top_zip_path=output_pdb2gmx_top_zip, input_posres_itp_path=output_restraints_top, input_itp_path=output_acpype_itp, output_top_zip_path=output_complex_top, properties=prop) |
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | # Editconf: Create solvent box # Import module from biobb_gromacs.gromacs.editconf import editconf # Create prop dict and inputs/outputs output_editconf_gro = pdbCode+'_'+ligandCode+'_complex_editconf.gro' prop = { 'box_type': 'octahedron', 'distance_to_molecule': 0.8 } # Create and launch bb editconf(input_gro_path=complexFile_H, output_gro_path=output_editconf_gro, properties=prop) |
309 310 311 312 313 314 315 316 317 318 319 320 | # Solvate: Fill the box with water molecules from biobb_gromacs.gromacs.solvate import solvate # Create prop dict and inputs/outputs output_solvate_gro = pdbCode+'_'+ligandCode+'_solvate.gro' output_solvate_top_zip = pdbCode+'_'+ligandCode+'_solvate_top.zip' # Create and launch bb solvate(input_solute_gro_path=output_editconf_gro, output_gro_path=output_solvate_gro, input_top_zip_path=output_complex_top, output_top_zip_path=output_solvate_top_zip) |
324 325 326 327 328 329 330 331 332 | #Show protein view = nglview.show_structure_file(output_solvate_gro) view.clear_representations() view.add_representation(repr_type='cartoon', selection='protein', color='sstruc') view.add_representation(repr_type='licorice', radius='.5', selection=ligandCode) view.add_representation(repr_type='line', linewidth='1', selection='SOL', opacity='.3') view._remote_call('setSize', target='Widget', args=['','600px']) view.camera='orthographic' view |
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | # Grompp: Creating portable binary run file for ion generation from biobb_gromacs.gromacs.grompp import grompp # Create prop dict and inputs/outputs prop = { 'mdp':{ 'nsteps':'5000' }, 'simulation_type':'minimization', 'maxwarn': 1 } output_gppion_tpr = pdbCode+'_'+ligandCode+'_complex_gppion.tpr' # Create and launch bb grompp(input_gro_path=output_solvate_gro, input_top_zip_path=output_solvate_top_zip, output_tpr_path=output_gppion_tpr, properties=prop) |
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | # Genion: Adding ions to reach a 0.05 molar concentration from biobb_gromacs.gromacs.genion import genion # Create prop dict and inputs/outputs prop={ 'neutral':True, 'concentration':0.05 } output_genion_gro = pdbCode+'_'+ligandCode+'_genion.gro' output_genion_top_zip = pdbCode+'_'+ligandCode+'_genion_top.zip' # Create and launch bb genion(input_tpr_path=output_gppion_tpr, output_gro_path=output_genion_gro, input_top_zip_path=output_solvate_top_zip, output_top_zip_path=output_genion_top_zip, properties=prop) |
377 378 379 380 381 382 383 384 385 386 | #Show protein view = nglview.show_structure_file(output_genion_gro) view.clear_representations() view.add_representation(repr_type='cartoon', selection='protein', color='sstruc') view.add_representation(repr_type='licorice', radius='.5', selection=ligandCode) view.add_representation(repr_type='ball+stick', selection='NA') view.add_representation(repr_type='ball+stick', selection='CL') view._remote_call('setSize', target='Widget', args=['','600px']) view.camera='orthographic' view |
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | # Grompp: Creating portable binary run file for mdrun from biobb_gromacs.gromacs.grompp import grompp # Create prop dict and inputs/outputs prop = { 'mdp':{ 'nsteps':'5000', 'emstep': 0.01, 'emtol':'500' }, 'simulation_type':'minimization' } output_gppmin_tpr = pdbCode+'_'+ligandCode+'_gppmin.tpr' # Create and launch bb grompp(input_gro_path=output_genion_gro, input_top_zip_path=output_genion_top_zip, output_tpr_path=output_gppmin_tpr, properties=prop) |
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | # Mdrun: Running minimization from biobb_gromacs.gromacs.mdrun import mdrun # Create prop dict and inputs/outputs output_min_trr = pdbCode+'_'+ligandCode+'_min.trr' output_min_gro = pdbCode+'_'+ligandCode+'_min.gro' output_min_edr = pdbCode+'_'+ligandCode+'_min.edr' output_min_log = pdbCode+'_'+ligandCode+'_min.log' # Create and launch bb mdrun(input_tpr_path=output_gppmin_tpr, output_trr_path=output_min_trr, output_gro_path=output_min_gro, output_edr_path=output_min_edr, output_log_path=output_min_log) |
430 431 432 433 434 435 436 437 438 439 440 441 442 | # GMXEnergy: Getting system energy by time from biobb_analysis.gromacs.gmx_energy import gmx_energy # Create prop dict and inputs/outputs output_min_ene_xvg = pdbCode+'_'+ligandCode+'_min_ene.xvg' prop = { 'terms': ["Potential"] } # Create and launch bb gmx_energy(input_energy_path=output_min_edr, output_xvg_path=output_min_ene_xvg, properties=prop) |
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 | import plotly import plotly.graph_objs as go #Read data from file and filter energy values higher than 1000 Kj/mol^-1 with open(output_min_ene_xvg,'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 KJ/mol-1") ) }) plotly.offline.iplot(fig) |
475 476 477 478 479 480 481 482 483 484 485 486 487 | # MakeNdx: Creating index file with a new group (protein-ligand complex) from biobb_gromacs.gromacs.make_ndx import make_ndx # Create prop dict and inputs/outputs output_complex_ndx = pdbCode+'_'+ligandCode+'_index.ndx' prop = { 'selection': "\"Protein\"|\"Other\"" } # Create and launch bb make_ndx(input_structure_path=output_min_gro, output_ndx_path=output_complex_ndx, properties=prop) |
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | # Grompp: Creating portable binary run file for NVT System Equilibration from biobb_gromacs.gromacs.grompp import grompp # Create prop dict and inputs/outputs output_gppnvt_tpr = pdbCode+'_'+ligandCode+'gppnvt.tpr' prop = { 'mdp':{ 'nsteps':'5000', 'tc-grps': 'Protein_Other Water_and_ions', 'Define': '-DPOSRES -D' + posresifdef }, 'simulation_type':'nvt' } # Create and launch bb grompp(input_gro_path=output_min_gro, input_top_zip_path=output_genion_top_zip, input_ndx_path=output_complex_ndx, output_tpr_path=output_gppnvt_tpr, properties=prop) |
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 | # Mdrun: Running NVT System Equilibration from biobb_gromacs.gromacs.mdrun import mdrun # Create prop dict and inputs/outputs output_nvt_trr = pdbCode+'_'+ligandCode+'_nvt.trr' output_nvt_gro = pdbCode+'_'+ligandCode+'_nvt.gro' output_nvt_edr = pdbCode+'_'+ligandCode+'_nvt.edr' output_nvt_log = pdbCode+'_'+ligandCode+'_nvt.log' output_nvt_cpt = pdbCode+'_'+ligandCode+'_nvt.cpt' # Create and launch bb mdrun(input_tpr_path=output_gppnvt_tpr, output_trr_path=output_nvt_trr, output_gro_path=output_nvt_gro, output_edr_path=output_nvt_edr, output_log_path=output_nvt_log, output_cpt_path=output_nvt_cpt) |
534 535 536 537 538 539 540 541 542 543 544 545 546 | # GMXEnergy: Getting system temperature by time during NVT Equilibration from biobb_analysis.gromacs.gmx_energy import gmx_energy # Create prop dict and inputs/outputs output_nvt_temp_xvg = pdbCode+'_'+ligandCode+'_nvt_temp.xvg' prop = { 'terms': ["Temperature"] } # Create and launch bb gmx_energy(input_energy_path=output_nvt_edr, output_xvg_path=output_nvt_temp_xvg, properties=prop) |
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 plotly import plotly.graph_objs as go # Read temperature data from file with open(output_nvt_temp_xvg,'r') as temperature_file: x,y = map( list, zip(*[ (float(line.split()[0]),float(line.split()[1])) for line in temperature_file if not line.startswith(("#","@")) ]) ) plotly.offline.init_notebook_mode(connected=True) fig = ({ "data": [go.Scatter(x=x, y=y)], "layout": go.Layout(title="Temperature during NVT Equilibration", xaxis=dict(title = "Time (ps)"), yaxis=dict(title = "Temperature (K)") ) }) plotly.offline.iplot(fig) |
578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 | # Grompp: Creating portable binary run file for (NPT) System Equilibration from biobb_gromacs.gromacs.grompp import grompp # Create prop dict and inputs/outputs output_gppnpt_tpr = pdbCode+'_'+ligandCode+'_gppnpt.tpr' prop = { 'mdp':{ 'type': 'npt', 'nsteps':'5000', 'tc-grps': 'Protein_Other Water_and_ions', 'Define': '-DPOSRES -D' + posresifdef }, 'simulation_type':'npt' } # Create and launch bb grompp(input_gro_path=output_nvt_gro, input_top_zip_path=output_genion_top_zip, input_ndx_path=output_complex_ndx, output_tpr_path=output_gppnpt_tpr, input_cpt_path=output_nvt_cpt, properties=prop) |
603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 | # Mdrun: Running NPT System Equilibration from biobb_gromacs.gromacs.mdrun import mdrun # Create prop dict and inputs/outputs output_npt_trr = pdbCode+'_'+ligandCode+'_npt.trr' output_npt_gro = pdbCode+'_'+ligandCode+'_npt.gro' output_npt_edr = pdbCode+'_'+ligandCode+'_npt.edr' output_npt_log = pdbCode+'_'+ligandCode+'_npt.log' output_npt_cpt = pdbCode+'_'+ligandCode+'_npt.cpt' # Create and launch bb mdrun(input_tpr_path=output_gppnpt_tpr, output_trr_path=output_npt_trr, output_gro_path=output_npt_gro, output_edr_path=output_npt_edr, output_log_path=output_npt_log, output_cpt_path=output_npt_cpt) |
623 624 625 626 627 628 629 630 631 632 633 634 635 | # GMXEnergy: Getting system pressure and density by time during NPT Equilibration from biobb_analysis.gromacs.gmx_energy import gmx_energy # Create prop dict and inputs/outputs output_npt_pd_xvg = pdbCode+'_'+ligandCode+'_npt_PD.xvg' prop = { 'terms': ["Pressure","Density"] } # Create and launch bb gmx_energy(input_energy_path=output_npt_edr, output_xvg_path=output_npt_pd_xvg, properties=prop) |
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 | import plotly from plotly import subplots import plotly.graph_objs as go # Read pressure and density data from file with open(output_npt_pd_xvg,'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) |
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 | # Grompp: Creating portable binary run file for mdrun from biobb_gromacs.gromacs.grompp import grompp # Create prop dict and inputs/outputs prop = { 'mdp':{ #'nsteps':'500000' # 1 ns (500,000 steps x 2fs per step) #'nsteps':'5000' # 10 ps (5,000 steps x 2fs per step) 'nsteps':'25000' # 50 ps (25,000 steps x 2fs per step) }, 'simulation_type':'free' } output_gppmd_tpr = pdbCode+'_'+ligandCode + '_gppmd.tpr' # Create and launch bb grompp(input_gro_path=output_npt_gro, input_top_zip_path=output_genion_top_zip, output_tpr_path=output_gppmd_tpr, input_cpt_path=output_npt_cpt, properties=prop) |
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 | # Mdrun: Running free dynamics from biobb_gromacs.gromacs.mdrun import mdrun # Create prop dict and inputs/outputs output_md_trr = pdbCode+'_'+ligandCode+'_md.trr' output_md_gro = pdbCode+'_'+ligandCode+'_md.gro' output_md_edr = pdbCode+'_'+ligandCode+'_md.edr' output_md_log = pdbCode+'_'+ligandCode+'_md.log' output_md_cpt = pdbCode+'_'+ligandCode+'_md.cpt' # Create and launch bb mdrun(input_tpr_path=output_gppmd_tpr, output_trr_path=output_md_trr, output_gro_path=output_md_gro, output_edr_path=output_md_edr, output_log_path=output_md_log, output_cpt_path=output_md_cpt) |
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 | # GMXRms: Computing Root Mean Square deviation to analyse structural stability # RMSd against minimized and equilibrated snapshot (backbone atoms) from biobb_analysis.gromacs.gmx_rms import gmx_rms # Create prop dict and inputs/outputs output_rms_first = pdbCode+'_'+ligandCode+'_rms_first.xvg' prop = { 'selection': 'Backbone' } # Create and launch bb gmx_rms(input_structure_path=output_gppmd_tpr, input_traj_path=output_md_trr, output_xvg_path=output_rms_first, properties=prop) |
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 | # GMXRms: Computing Root Mean Square deviation to analyse structural stability # RMSd against experimental structure (backbone atoms) from biobb_analysis.gromacs.gmx_rms import gmx_rms # Create prop dict and inputs/outputs output_rms_exp = pdbCode+'_'+ligandCode+'_rms_exp.xvg' prop = { 'selection': 'Backbone' } # Create and launch bb gmx_rms(input_structure_path=output_gppmin_tpr, input_traj_path=output_md_trr, output_xvg_path=output_rms_exp, properties=prop) |
761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 | import plotly import plotly.graph_objs as go # 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 (nm)") ) }) plotly.offline.iplot(fig) |
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 | # GMXRgyr: Computing Radius of Gyration to measure the protein compactness during the free MD simulation from biobb_analysis.gromacs.gmx_rgyr import gmx_rgyr # Create prop dict and inputs/outputs output_rgyr = pdbCode+'_'+ligandCode+'_rgyr.xvg' prop = { 'selection': 'Backbone' } # Create and launch bb gmx_rgyr(input_structure_path=output_gppmin_tpr, input_traj_path=output_md_trr, output_xvg_path=output_rgyr, properties=prop) |
832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 | import plotly import plotly.graph_objs as go # 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 (nm)") ) }) plotly.offline.iplot(fig) |
860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 | # GMXImage: "Imaging" the resulting trajectory # Removing water molecules and ions from the resulting structure from biobb_analysis.gromacs.gmx_image import gmx_image # Create prop dict and inputs/outputs output_imaged_traj = pdbCode+'_imaged_traj.trr' prop = { 'center_selection': 'Protein_Other', 'output_selection': 'Protein_Other', 'pbc' : 'mol', 'center' : True } # Create and launch bb gmx_image(input_traj_path=output_md_trr, input_top_path=output_gppmd_tpr, input_index_path=output_complex_ndx, output_traj_path=output_imaged_traj, properties=prop) |
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 | # GMXTrjConvStr: Converting and/or manipulating a structure # Removing water molecules and ions from the resulting structure # The "dry" structure will be used as a topology to visualize # the "imaged dry" trajectory generated in the previous step. from biobb_analysis.gromacs.gmx_trjconv_str import gmx_trjconv_str # Create prop dict and inputs/outputs output_dry_gro = pdbCode+'_md_dry.gro' prop = { 'selection': 'Protein_Other' } # Create and launch bb gmx_trjconv_str(input_structure_path=output_md_gro, input_top_path=output_gppmd_tpr, input_index_path=output_complex_ndx, output_str_path=output_dry_gro, properties=prop) |
903 904 905 | # Show trajectory view = nglview.show_simpletraj(nglview.SimpletrajTrajectory(output_imaged_traj, output_dry_gro), gui=True) view |
Support
- Future updates
Related Workflows





