Вернуться в репозиторий Tikhonova Polina. Homework 9.

In [1]:
import os
import urllib2
from bs4 import BeautifulSoup
import requests

import IPython.display
import ipywidgets
from IPython.display import display,display_svg,SVG,Image, HTML,IFrame
import re

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
import __main__
__main__.pymol_argv = ['pymol','-qc'] # Pymol: quiet and no GUI
from time import sleep
import pymol
pymol.finish_launching()

Download files from kodomo

In [5]:
path = 'http://kodomo.cmm.msu.ru/~golovin/bilayer/'
response = urllib2.urlopen(path)
html = response.read()

soup = BeautifulSoup(html, "html5lib")
for link in soup.find_all('a'):
    if '.' in link.get('href'):
        file_response = urllib2.urlopen(path+link.get('href'))
        html = file_response.read()
        with open(link.get('href'), 'w') as f:
            f.write(html)

Modelling

In [6]:
!genconf -f dppc.gro -o b_64.gro -nbox 4 4 4
                         :-)  G  R  O  M  A  C  S  (-:

                              S  C  A  M  O  R  G

                            :-)  VERSION 4.5.5  (-:

        Written by Emile Apol, Rossen Apostolov, Herman J.C. Berendsen,
      Aldert van Buuren, Pär Bjelkmar, Rudi van Drunen, Anton Feenstra, 
        Gerrit Groenhof, Peter Kasson, Per Larsson, Pieter Meulenhoff, 
           Teemu Murtola, Szilard Pall, Sander Pronk, Roland Schulz, 
                Michael Shirts, Alfons Sijbers, Peter Tieleman,

               Berk Hess, David van der Spoel, and Erik Lindahl.

       Copyright (c) 1991-2000, University of Groningen, The Netherlands.
            Copyright (c) 2001-2010, The GROMACS development team at
        Uppsala University & The Royal Institute of Technology, Sweden.
            check out http://www.gromacs.org for more information.

         This program is free software; you can redistribute it and/or
          modify it under the terms of the GNU General Public License
         as published by the Free Software Foundation; either version 2
             of the License, or (at your option) any later version.

                               :-)  genconf  (-:

Option     Filename  Type         Description
------------------------------------------------------------
  -f       dppc.gro  Input        Structure file: gro g96 pdb tpr etc.
  -o       b_64.gro  Output       Structure file: gro g96 pdb etc.
-trj       traj.xtc  Input, Opt.  Trajectory: xtc trr trj gro g96 pdb cpt

Option       Type   Value   Description
------------------------------------------------------
-[no]h       bool   no      Print help info and quit
-[no]version bool   no      Print version info and quit
-nice        int    0       Set the nicelevel
-nbox        vector 4 4 4   Number of boxes
-dist        vector 0 0 0   Distance between boxes
-seed        int    0       Random generator seed, if 0 generated from the
                            time
-[no]rot     bool   no      Randomly rotate conformations
-[no]shuffle bool   no      Random shuffling of molecules
-[no]sort    bool   no      Sort molecules on X coord
-block       int    1       Divide the box in blocks on this number of cpus
-nmolat      int    3       Number of atoms per molecule, assumed to start
                            from 0. If you set this wrong, it will screw up
                            your system!
-maxrot      vector 180 180 180  Maximum random rotation
-[no]renumber  bool yes     Renumber residues


gcq#169: "The Poodle Bites" (F. Zappa)

Convert to pdb

In [8]:
!editconf -f dppc.gro -o dppc.pdb
!editconf -f b_64.gro -o b_64.pdb
                         :-)  G  R  O  M  A  C  S  (-:

                              S  C  A  M  O  R  G

                            :-)  VERSION 4.5.5  (-:

        Written by Emile Apol, Rossen Apostolov, Herman J.C. Berendsen,
      Aldert van Buuren, Pär Bjelkmar, Rudi van Drunen, Anton Feenstra, 
        Gerrit Groenhof, Peter Kasson, Per Larsson, Pieter Meulenhoff, 
           Teemu Murtola, Szilard Pall, Sander Pronk, Roland Schulz, 
                Michael Shirts, Alfons Sijbers, Peter Tieleman,

               Berk Hess, David van der Spoel, and Erik Lindahl.

       Copyright (c) 1991-2000, University of Groningen, The Netherlands.
            Copyright (c) 2001-2010, The GROMACS development team at
        Uppsala University & The Royal Institute of Technology, Sweden.
            check out http://www.gromacs.org for more information.

         This program is free software; you can redistribute it and/or
          modify it under the terms of the GNU General Public License
         as published by the Free Software Foundation; either version 2
             of the License, or (at your option) any later version.

                               :-)  editconf  (-:

Option     Filename  Type         Description
------------------------------------------------------------
  -f       dppc.gro  Input        Structure file: gro g96 pdb tpr etc.
  -n      index.ndx  Input, Opt.  Index file
  -o       dppc.pdb  Output, Opt! Structure file: gro g96 pdb etc.
-mead      mead.pqr  Output, Opt. Coordinate file for MEAD
 -bf      bfact.dat  Input, Opt.  Generic data file

Option       Type   Value   Description
------------------------------------------------------
-[no]h       bool   no      Print help info and quit
-[no]version bool   no      Print version info and quit
-nice        int    0       Set the nicelevel
-[no]w       bool   no      View output .xvg, .xpm, .eps and .pdb files
-[no]ndef    bool   no      Choose output from default index groups
-bt          enum   triclinic  Box type for -box and -d: triclinic, cubic,
                            dodecahedron or octahedron
-box         vector 0 0 0   Box vector lengths (a,b,c)
-angles      vector 90 90 90  Angles between the box vectors (bc,ac,ab)
-d           real   0       Distance between the solute and the box
-[no]c       bool   no      Center molecule in box (implied by -box and -d)
-center      vector 0 0 0   Coordinates of geometrical center
-aligncenter vector 0 0 0   Center of rotation for alignment
-align       vector 0 0 0   Align to target vector
-translate   vector 0 0 0   Translation
-rotate      vector 0 0 0   Rotation around the X, Y and Z axes in degrees
-[no]princ   bool   no      Orient molecule(s) along their principal axes
-scale       vector 1 1 1   Scaling factor
-density     real   1000    Density (g/L) of the output box achieved by
                            scaling
-[no]pbc     bool   no      Remove the periodicity (make molecule whole again)
-resnr       int    -1       Renumber residues starting from resnr
-[no]grasp   bool   no      Store the charge of the atom in the B-factor
                            field and the radius of the atom in the occupancy
                            field
-rvdw        real   0.12    Default Van der Waals radius (in nm) if one can
                            not be found in the database or if no parameters
                            are present in the topology file
-sig56       real   0       Use rmin/2 (minimum in the Van der Waals
                            potential) rather than sigma/2 
-[no]vdwread bool   no      Read the Van der Waals radii from the file
                            vdwradii.dat rather than computing the radii
                            based on the force field
-[no]atom    bool   no      Force B-factor attachment per atom
-[no]legend  bool   no      Make B-factor legend
-label       string A       Add chain label for all residues
-[no]conect  bool   no      Add CONECT records to a .pdb file when written.
                            Can only be done when a topology is present

Read 50 atoms
Volume: 1.5477 nm^3, corresponds to roughly 600 electrons
No velocities found

gcq#175: "That Was Really Cool" (Butthead)

                         :-)  G  R  O  M  A  C  S  (-:

                              S  C  A  M  O  R  G

                            :-)  VERSION 4.5.5  (-:

        Written by Emile Apol, Rossen Apostolov, Herman J.C. Berendsen,
      Aldert van Buuren, Pär Bjelkmar, Rudi van Drunen, Anton Feenstra, 
        Gerrit Groenhof, Peter Kasson, Per Larsson, Pieter Meulenhoff, 
           Teemu Murtola, Szilard Pall, Sander Pronk, Roland Schulz, 
                Michael Shirts, Alfons Sijbers, Peter Tieleman,

               Berk Hess, David van der Spoel, and Erik Lindahl.

       Copyright (c) 1991-2000, University of Groningen, The Netherlands.
            Copyright (c) 2001-2010, The GROMACS development team at
        Uppsala University & The Royal Institute of Technology, Sweden.
            check out http://www.gromacs.org for more information.

         This program is free software; you can redistribute it and/or
          modify it under the terms of the GNU General Public License
         as published by the Free Software Foundation; either version 2
             of the License, or (at your option) any later version.

                               :-)  editconf  (-:

Option     Filename  Type         Description
------------------------------------------------------------
  -f       b_64.gro  Input        Structure file: gro g96 pdb tpr etc.
  -n      index.ndx  Input, Opt.  Index file
  -o       b_64.pdb  Output, Opt! Structure file: gro g96 pdb etc.
-mead      mead.pqr  Output, Opt. Coordinate file for MEAD
 -bf      bfact.dat  Input, Opt.  Generic data file

Option       Type   Value   Description
------------------------------------------------------
-[no]h       bool   no      Print help info and quit
-[no]version bool   no      Print version info and quit
-nice        int    0       Set the nicelevel
-[no]w       bool   no      View output .xvg, .xpm, .eps and .pdb files
-[no]ndef    bool   no      Choose output from default index groups
-bt          enum   triclinic  Box type for -box and -d: triclinic, cubic,
                            dodecahedron or octahedron
-box         vector 0 0 0   Box vector lengths (a,b,c)
-angles      vector 90 90 90  Angles between the box vectors (bc,ac,ab)
-d           real   0       Distance between the solute and the box
-[no]c       bool   no      Center molecule in box (implied by -box and -d)
-center      vector 0 0 0   Coordinates of geometrical center
-aligncenter vector 0 0 0   Center of rotation for alignment
-align       vector 0 0 0   Align to target vector
-translate   vector 0 0 0   Translation
-rotate      vector 0 0 0   Rotation around the X, Y and Z axes in degrees
-[no]princ   bool   no      Orient molecule(s) along their principal axes
-scale       vector 1 1 1   Scaling factor
-density     real   1000    Density (g/L) of the output box achieved by
                            scaling
-[no]pbc     bool   no      Remove the periodicity (make molecule whole again)
-resnr       int    -1       Renumber residues starting from resnr
-[no]grasp   bool   no      Store the charge of the atom in the B-factor
                            field and the radius of the atom in the occupancy
                            field
-rvdw        real   0.12    Default Van der Waals radius (in nm) if one can
                            not be found in the database or if no parameters
                            are present in the topology file
-sig56       real   0       Use rmin/2 (minimum in the Van der Waals
                            potential) rather than sigma/2 
-[no]vdwread bool   no      Read the Van der Waals radii from the file
                            vdwradii.dat rather than computing the radii
                            based on the force field
-[no]atom    bool   no      Force B-factor attachment per atom
-[no]legend  bool   no      Make B-factor legend
-label       string A       Add chain label for all residues
-[no]conect  bool   no      Add CONECT records to a .pdb file when written.
                            Can only be done when a topology is present

Read 3200 atoms
Volume: 99.0529 nm^3, corresponds to roughly 44500 electrons
No velocities found

gcq#175: "That Was Really Cool" (Butthead)

View dppc

In [12]:
pymol.cmd.reinitialize()
pymol.cmd.do('''
    load dppc.pdb   
    png dppc.png
''')
    # Desired pymol commands here to produce and save figures
sleep(2.5) # (in seconds)
Image(filename='dppc.png')
Out[12]:

View b_64

In [16]:
pymol.cmd.reinitialize()
pymol.cmd.do('''
    load b_64.pdb   
    png b_64.png
''')
    # Desired pymol commands here to produce and save figures
sleep(2.5) # (in seconds)
Image(filename='b_64.png')
Out[16]:

Edit b.top

In [25]:
with open('b.top') as f:
    b_top = f.read()
b_top_lines = b_top.split('\n')
b_top_lines[-2] = 'DPPC    64'
with open('b.top','w') as f:
    f.write('\n'.join(b_top_lines))

Make an indent

In [27]:
%%bash
editconf -f b_64.gro -o b_ec -d 0.5

System geometry optimization

In [36]:
%%bash
grompp -f em -c b_ec -p b -o b_em -maxwarn 2 -v
mdrun -deffnm b_em -v > force.log

Вообще, по какой-то причине информацию о изменении силы я могу найти только если запущу последнюю команду в терминале. И в force.log эта инофрмация почему-то не сохраняется. Поэтому я просто руками сохранила нужные строчки в force.log.

In [45]:
forces = []
with open('force.log') as f:
    for line in f:
        if 'Dmax' in line:
  #          print(line)
            forces.append((re.split(pattern='Step=   |, Dmax= | nm, Epot= | Fmax= |, atom= |\n', string=line)[1:-1]))
forces_log = pd.DataFrame(forces,columns=['Step', 'Dmax', 'Epot', 'Fmax', 'atom'])      
print('''Таким образом, начальное значение силы = %.2f\nКонечное значение = %.2f
Видим, что сила существенно уменьшилась.
Ниже полная таблица изменений силы.'''%
      (float(forces_log['Fmax'][0]), float(list(forces_log['Fmax'])[-1])))
forces_log
Таким образом, начальное значение силы = 437970.00
Конечное значение = 616.89
Видим, что сила существенно уменьшилась.
Ниже полная таблица изменений силы.
Out[45]:
Step Dmax Epot Fmax atom
0 0 2.0e-02 4.74007e+05 4.37970e+05 1842
1 1 2.0e-02 7.19293e+04 3.57933e+04 2588
2 2 2.4e-02 3.56795e+04 9.52568e+03 2993
3 3 2.9e-02 3.46459e+04 1.50508e+04 2992
4 4 3.5e-02 2.99879e+04 1.37059e+04 2592
5 6 2.1e-02 1.30782e+04 4.02791e+03 1342
6 9 6.2e-03 1.04672e+04 1.87751e+03 2392
7 10 7.5e-03 1.02199e+04 3.76147e+03 1792
8 11 9.0e-03 1.01147e+04 4.34365e+03 2392
9 13 5.4e-03 7.19423e+03 1.91912e+03 2765
10 15 3.2e-03 6.81202e+03 2.03533e+03 2765
11 16 3.9e-03 6.37647e+03 3.00818e+03 2765
12 17 4.6e-03 6.07244e+03 2.75324e+03 2765
13 19 2.8e-03 5.60145e+03 8.43337e+02 2765
14 20 3.3e-03 5.49136e+03 3.08327e+03 2765
15 21 4.0e-03 5.09456e+03 2.09083e+03 2765
16 23 2.4e-03 4.83141e+03 8.78173e+02 2765
17 25 1.4e-03 4.78063e+03 1.07042e+03 2765
18 26 1.7e-03 4.51750e+03 1.00741e+03 2765
19 27 2.1e-03 4.46707e+03 1.77657e+03 2765
20 28 2.5e-03 4.35788e+03 1.28547e+03 915
21 30 1.5e-03 4.20725e+03 6.94208e+02 915
22 31 1.8e-03 3.97280e+03 1.39504e+03 915
23 32 2.2e-03 3.97165e+03 1.44422e+03 915
24 33 2.6e-03 3.85030e+03 1.70904e+03 915
25 35 1.6e-03 3.71519e+03 3.29197e+02 472
26 36 1.9e-03 3.32876e+03 1.57250e+03 915
27 39 5.6e-04 3.23180e+03 8.45033e+02 2765
28 42 1.7e-04 3.20617e+03 6.21543e+02 9153
29 50 1.6e-06 3.20591e+03 6.19379e+02 9155
30 51 1.9e-06 3.20911e+03 6.16887e+02 2765

Add water

In [46]:
!genbox -cp b_em -p b -cs spc216 -o b_s
                         :-)  G  R  O  M  A  C  S  (-:

               Giant Rising Ordinary Mutants for A Clerical Setup

                            :-)  VERSION 4.5.5  (-:

        Written by Emile Apol, Rossen Apostolov, Herman J.C. Berendsen,
      Aldert van Buuren, Pär Bjelkmar, Rudi van Drunen, Anton Feenstra, 
        Gerrit Groenhof, Peter Kasson, Per Larsson, Pieter Meulenhoff, 
           Teemu Murtola, Szilard Pall, Sander Pronk, Roland Schulz, 
                Michael Shirts, Alfons Sijbers, Peter Tieleman,

               Berk Hess, David van der Spoel, and Erik Lindahl.

       Copyright (c) 1991-2000, University of Groningen, The Netherlands.
            Copyright (c) 2001-2010, The GROMACS development team at
        Uppsala University & The Royal Institute of Technology, Sweden.
            check out http://www.gromacs.org for more information.

         This program is free software; you can redistribute it and/or
          modify it under the terms of the GNU General Public License
         as published by the Free Software Foundation; either version 2
             of the License, or (at your option) any later version.

                                :-)  genbox  (-:

Option     Filename  Type         Description
------------------------------------------------------------
 -cp       b_em.gro  Input, Opt!  Structure file: gro g96 pdb tpr etc.
 -cs     spc216.gro  Input, Opt!, Lib. Structure file: gro g96 pdb tpr etc.
 -ci     insert.gro  Input, Opt.  Structure file: gro g96 pdb tpr etc.
  -o        b_s.gro  Output       Structure file: gro g96 pdb etc.
  -p          b.top  In/Out, Opt! Topology file

Option       Type   Value   Description
------------------------------------------------------
-[no]h       bool   no      Print help info and quit
-[no]version bool   no      Print version info and quit
-nice        int    19      Set the nicelevel
-box         vector 0 0 0   box size
-nmol        int    0       no of extra molecules to insert
-try         int    10      try inserting -nmol times -try times
-seed        int    1997    random generator seed
-vdwd        real   0.105   default vdwaals distance
-shell       real   0       thickness of optional water layer around solute
-maxsol      int    0       maximum number of solvent molecules to add if
                            they fit in the box. If zero (default) this is
                            ignored
-[no]vel     bool   no      keep velocities from input solute and solvent

Reading solute configuration
bilayer in water
Containing 3200 atoms in 64 residues
Initialising van der waals distances...

WARNING: masses and atomic (Van der Waals) radii will be determined
         based on residue and atom names. These numbers can deviate
         from the correct mass and radius of the atom type.

Reading solvent configuration
"216H2O,WATJP01,SPC216,SPC-MODEL,300K,BOX(M)=1.86206NM,WFVG,MAR. 1984"
solvent configuration contains 648 atoms in 216 residues

Initialising van der waals distances...
Will generate new solvent configuration of 4x3x4 boxes
Generating configuration
Sorting configuration
Found 1 molecule type:
    SOL (   3 atoms): 10368 residues
Calculating Overlap...
box_margin = 0.315
Removed 12462 atoms that were outside the box
Neighborsearching with a cut-off of 0.45
Table routines are used for coulomb: FALSE
Table routines are used for vdw:     FALSE
Cut-off's:   NS: 0.45   Coulomb: 0.45   LJ: 0.45
System total charge: 0.000
Grid: 17 x 12 x 16 cells
Successfully made neighbourlist
nri = 49430, nrj = 1740315
Checking Protein-Solvent overlap: tested 58585 pairs, removed 7842 atoms.
Checking Solvent-Solvent overlap: tested 124347 pairs, removed 2946 atoms.
Added 2618 molecules
Generated solvent containing 7854 atoms in 2618 residues
Writing generated configuration to b_s.gro
bilayer in water

Output configuration contains 11054 atoms in 2682 residues
Volume                 :     160.705 (nm^3)
Density                :     920.108 (g/l)
Number of SOL molecules:   2618   

Processing topology
Adding line for 2618 solvent molecules to topology file (b.top)

Back Off! I just backed up b.top to ./#b.top.1#

gcq#189: "Been There, Done It" (Beavis and Butthead)

In [47]:
%%bash
grompp -f pr -c b_s -p b -o b_pr -maxwarn 1
mdrun -deffnm b_pr -v
                         :-)  G  R  O  M  A  C  S  (-:

                   Great Red Oystrich Makes All Chemists Sane

                            :-)  VERSION 4.5.5  (-:

        Written by Emile Apol, Rossen Apostolov, Herman J.C. Berendsen,
      Aldert van Buuren, Pär Bjelkmar, Rudi van Drunen, Anton Feenstra, 
        Gerrit Groenhof, Peter Kasson, Per Larsson, Pieter Meulenhoff, 
           Teemu Murtola, Szilard Pall, Sander Pronk, Roland Schulz, 
                Michael Shirts, Alfons Sijbers, Peter Tieleman,

               Berk Hess, David van der Spoel, and Erik Lindahl.

       Copyright (c) 1991-2000, University of Groningen, The Netherlands.
            Copyright (c) 2001-2010, The GROMACS development team at
        Uppsala University & The Royal Institute of Technology, Sweden.
            check out http://www.gromacs.org for more information.

         This program is free software; you can redistribute it and/or
          modify it under the terms of the GNU General Public License
         as published by the Free Software Foundation; either version 2
             of the License, or (at your option) any later version.

                                :-)  grompp  (-:

turning all bonds into constraints...
turning all bonds into constraints...
Analysing residue names:
There are:    64      Other residues
There are:  2618      Water residues
Analysing residues not classified as Protein/DNA/RNA/Water and splitting into groups...
Largest charge group radii for Van der Waals: 0.232, 0.232 nm
Largest charge group radii for Coulomb:       0.232, 0.232 nm
Calculating fourier grid dimensions for X Y Z
Using a fourier grid of 54x40x50, spacing 0.116 0.111 0.116
This run will generate roughly 2 Mb of data
Option     Filename  Type         Description
------------------------------------------------------------
  -f         pr.mdp  Input        grompp input file with MD parameters
 -po      mdout.mdp  Output       grompp input file with MD parameters
  -c        b_s.gro  Input        Structure file: gro g96 pdb tpr etc.
  -r       conf.gro  Input, Opt.  Structure file: gro g96 pdb tpr etc.
 -rb       conf.gro  Input, Opt.  Structure file: gro g96 pdb tpr etc.
  -n      index.ndx  Input, Opt.  Index file
  -p          b.top  Input        Topology file
 -pp  processed.top  Output, Opt. Topology file
  -o       b_pr.tpr  Output       Run input file: tpr tpb tpa
  -t       traj.trr  Input, Opt.  Full precision trajectory: trr trj cpt
  -e       ener.edr  Input, Opt.  Energy file

Option       Type   Value   Description
------------------------------------------------------
-[no]h       bool   no      Print help info and quit
-[no]version bool   no      Print version info and quit
-nice        int    0       Set the nicelevel
-[no]v       bool   no      Be loud and noisy
-time        real   -1      Take frame at or first after this time.
-[no]rmvsbds bool   yes     Remove constant bonded interactions with virtual
                            sites
-maxwarn     int    1       Number of allowed warnings during input
                            processing. Not for normal use and may generate
                            unstable systems
-[no]zero    bool   no      Set parameters for bonded interactions without
                            defaults to zero instead of generating an error
-[no]renum   bool   yes     Renumber atomtypes and minimize number of
                            atomtypes

Ignoring obsolete mdp entry 'title'
Ignoring obsolete mdp entry 'cpp'

Back Off! I just backed up mdout.mdp to ./#mdout.mdp.1#

NOTE 1 [file pr.mdp]:
  nstcomm < nstcalcenergy defeats the purpose of nstcalcenergy, setting
  nstcomm to nstcalcenergy

Generated 1369 of the 2211 non-bonded parameter combinations
Excluding 3 bonded neighbours molecule type 'DPPC'
Excluding 2 bonded neighbours molecule type 'SOL'
Velocities were taken from a Maxwell distribution at 300 K
Number of degrees of freedom in T-Coupling group DPPC is 6463.13
Number of degrees of freedom in T-Coupling group SOL is 15705.88
Estimate for the relative computational load of the PME mesh part: 0.42

There was 1 note

gcq#136: "Catholic School Girls Rule" (Red Hot Chili Peppers)

                         :-)  G  R  O  M  A  C  S  (-:

                   Great Red Oystrich Makes All Chemists Sane

                            :-)  VERSION 4.5.5  (-:

        Written by Emile Apol, Rossen Apostolov, Herman J.C. Berendsen,
      Aldert van Buuren, Pär Bjelkmar, Rudi van Drunen, Anton Feenstra, 
        Gerrit Groenhof, Peter Kasson, Per Larsson, Pieter Meulenhoff, 
           Teemu Murtola, Szilard Pall, Sander Pronk, Roland Schulz, 
                Michael Shirts, Alfons Sijbers, Peter Tieleman,

               Berk Hess, David van der Spoel, and Erik Lindahl.

       Copyright (c) 1991-2000, University of Groningen, The Netherlands.
            Copyright (c) 2001-2010, The GROMACS development team at
        Uppsala University & The Royal Institute of Technology, Sweden.
            check out http://www.gromacs.org for more information.

         This program is free software; you can redistribute it and/or
          modify it under the terms of the GNU General Public License
         as published by the Free Software Foundation; either version 2
             of the License, or (at your option) any later version.

                                :-)  mdrun  (-:

Option     Filename  Type         Description
------------------------------------------------------------
  -s       b_pr.tpr  Input        Run input file: tpr tpb tpa
  -o       b_pr.trr  Output       Full precision trajectory: trr trj cpt
  -x       b_pr.xtc  Output, Opt. Compressed trajectory (portable xdr format)
-cpi       b_pr.cpt  Input, Opt.  Checkpoint file
-cpo       b_pr.cpt  Output, Opt. Checkpoint file
  -c       b_pr.gro  Output       Structure file: gro g96 pdb etc.
  -e       b_pr.edr  Output       Energy file
  -g       b_pr.log  Output       Log file
-dhdl      b_pr.xvg  Output, Opt. xvgr/xmgr file
-field     b_pr.xvg  Output, Opt. xvgr/xmgr file
-table     b_pr.xvg  Input, Opt.  xvgr/xmgr file
-tablep    b_pr.xvg  Input, Opt.  xvgr/xmgr file
-tableb    b_pr.xvg  Input, Opt.  xvgr/xmgr file
-rerun     b_pr.xtc  Input, Opt.  Trajectory: xtc trr trj gro g96 pdb cpt
-tpi       b_pr.xvg  Output, Opt. xvgr/xmgr file
-tpid      b_pr.xvg  Output, Opt. xvgr/xmgr file
 -ei       b_pr.edi  Input, Opt.  ED sampling input
 -eo       b_pr.edo  Output, Opt. ED sampling output
  -j       b_pr.gct  Input, Opt.  General coupling stuff
 -jo       b_pr.gct  Output, Opt. General coupling stuff
-ffout     b_pr.xvg  Output, Opt. xvgr/xmgr file
-devout    b_pr.xvg  Output, Opt. xvgr/xmgr file
-runav     b_pr.xvg  Output, Opt. xvgr/xmgr file
 -px       b_pr.xvg  Output, Opt. xvgr/xmgr file
 -pf       b_pr.xvg  Output, Opt. xvgr/xmgr file
-mtx       b_pr.mtx  Output, Opt. Hessian matrix
 -dn       b_pr.ndx  Output, Opt. Index file
-multidir      b_pr  Input, Opt., Mult. Run directory

Option       Type   Value   Description
------------------------------------------------------
-[no]h       bool   no      Print help info and quit
-[no]version bool   no      Print version info and quit
-nice        int    0       Set the nicelevel
-deffnm      string b_pr    Set the default filename for all file options
-xvg         enum   xmgrace  xvg plot formatting: xmgrace, xmgr or none
-[no]pd      bool   no      Use particle decompostion
-dd          vector 0 0 0   Domain decomposition grid, 0 is optimize
-nt          int    0       Number of threads to start (0 is guess)
-npme        int    -1      Number of separate nodes to be used for PME, -1
                            is guess
-ddorder     enum   interleave  DD node order: interleave, pp_pme or cartesian
-[no]ddcheck bool   yes     Check for all bonded interactions with DD
-rdd         real   0       The maximum distance for bonded interactions with
                            DD (nm), 0 is determine from initial coordinates
-rcon        real   0       Maximum distance for P-LINCS (nm), 0 is estimate
-dlb         enum   auto    Dynamic load balancing (with DD): auto, no or yes
-dds         real   0.8     Minimum allowed dlb scaling of the DD cell size
-gcom        int    -1      Global communication frequency
-[no]v       bool   yes     Be loud and noisy
-[no]compact bool   yes     Write a compact log file
-[no]seppot  bool   no      Write separate V and dVdl terms for each
                            interaction type and node to the log file(s)
-pforce      real   -1      Print all forces larger than this (kJ/mol nm)
-[no]reprod  bool   no      Try to avoid optimizations that affect binary
                            reproducibility
-cpt         real   15      Checkpoint interval (minutes)
-[no]cpnum   bool   no      Keep and number checkpoint files
-[no]append  bool   yes     Append to previous output files when continuing
                            from checkpoint instead of adding the simulation
                            part number to all file names
-maxh        real   -1      Terminate after 0.99 times this time (hours)
-multi       int    0       Do multiple simulations in parallel
-replex      int    0       Attempt replica exchange every # steps
-reseed      int    -1      Seed for replica exchange, -1 is generate a seed
-[no]ionize  bool   no      Do a simulation including the effect of an X-Ray
                            bombardment on your system

Getting Loaded...
Reading file b_pr.tpr, VERSION 4.5.5 (single precision)
Starting 8 threads
Loaded with Money

Making 2D domain decomposition 4 x 1 x 2
starting mdrun 'bilayer in water'
1000 steps,      0.2 ps.
step 900, remaining runtime:     0 s          imb F 21% 
NOTE: Turning on dynamic load balancing


Writing final coordinates.
step 1000, remaining runtime:     0 s          
 Average load imbalance: 30.8 %
 Part of the total run time spent waiting due to load imbalance: 9.7 %
 Steps where the load balancing was limited by -rdd, -rcon and/or -dds: X 0 % Z 0 %

NOTE: 9.7 % performance was lost due to load imbalance
      in the domain decomposition.


	Parallel run - timing based on wallclock.

               NODE (s)   Real (s)      (%)
       Time:      6.234      6.234    100.0
               (Mnbf/s)   (GFlops)   (ns/day)  (hour/ns)
Performance:    227.667     16.741      2.775      8.650

gcq#209: "I Was Born to Have Adventure" (F. Zappa)

In [56]:
%%bash
editconf -f b_pr.gro -o b_pr.pdb
editconf -f b_s.gro -o b_s.pdb

View in Pymol

Объекты b_pr и b_s различаются как по своей структуре, так и по расположению воды.

In [76]:
pymol.cmd.reinitialize()
pymol.cmd.do('''
    load b_pr.pdb   
    load b_s.pdb  
    color yellow, b_s
    color magenta, b_pr
    png general.png
''')
    # Desired pymol commands here to produce and save figures
sleep(2.5) # (in seconds)
Image(filename='general.png')
Out[76]:

Ниже они показаны отдельно.

In [73]:
pymol.cmd.reinitialize()
pymol.cmd.do('''
    load b_pr.pdb   
    png b_pr.png
''')
    # Desired pymol commands here to produce and save figures
sleep(2.5) # (in seconds)
Image(filename='b_pr.png')
Out[73]:
In [74]:
pymol.cmd.reinitialize()
pymol.cmd.do('''
    load b_s.pdb   
    png b_s.png
''')
    # Desired pymol commands here to produce and save figures
sleep(2.5) # (in seconds)
Image(filename='b_s.png')
Out[74]:

Lomonosov

В консоли...

In [ ]:
scp -r . lom:_scratch/hse/tikhonova/hw9
ssh lom
cd _scratch/hse/tikhonova/hw9
cp /home/users/golovin/progs/share/gromacs/top/residuetypes.dat .
grompp -f md -c b_pr -p b -o b_md -maxwarn 1
sbatch -n 4 -e error.log -o output.log -t 5 -p test impi /opt/ccoe/gromacs-5.0.4/build/bin/gmx_mpi mdrun -testverlet -deffnm b_md -v

Submitted batch job 1646360

In [ ]:
sbatch -N1 --ntasks-per-node=2 -e error-gpu.log -o output.log -t 350 -p gpu impi /opt/ccoe/gromacs-5.0.4/build/bin/gmx_mpi mdrun -testverlet -deffnm  b_md -v

Submitted batch job 1646365

Analysis

In [ ]:
# куча каких-то лишних непонятных связей
trjconv -f b_md.xtc -s b_md.tpr -o b_pbc_1.pdb -skip 20  #DPPC
In [3]:
IFrame(src="trajectories1.html", width=900, height=700)
Out[3]:
In [ ]:
trjconv -f b_md.xtc -s b_md.tpr -o b_pbc_1.pdb -skip 20 -pbc mol

К сожалению положение камеры и приближение на js я настроить не смогла. Так что обзор придется каждый раз устанавливать помощью мышки.

In [5]:
IFrame(src="trajectories.html", width=900, height=700)
Out[5]:

Структура рушится сразу, примерно к 50 фрейму (t = 24500) она становится уже более менее похожей на бислой. И к 65 фрейму (t = 32000) она уже довольно четко разделена на 2 слоя.

Сводная картинка из Pymol

In [32]:
Image('Frames.png')
Out[32]:
Определите площадь занимаемую одним липидом.
In [ ]:
g_traj -f b_md.xtc -s b_md.tpr -ob box_1.xvg
In [101]:
sizes = pd.read_csv(path+'box_1.xvg', header = None, skiprows = 24, sep='\t')
sizes = sizes[[1,2,3,4]]
sizes.columns = ['time', 'X', 'Y', 'Z']
sizes.head()
Out[101]:
time X Y Z
0 0 6.26000 4.44300 5.77800
1 25 6.24560 4.43278 5.82278
2 50 6.20660 4.40510 5.87096
3 75 6.19381 4.39602 5.90044
4 100 6.18117 4.38705 5.92904
In [129]:
plt.figure(figsize=(10,6))
lip_sizes = np.array(sizes['Y'])*np.array(sizes['Z'])/32.
plt.plot(np.array(sizes['time']), lip_sizes, color='goldenrod');
plt.text(39000, 0.74, 'Max = %.2f\nMin = %.2f\nMean = %.2f\nMediana = %.2f'%(max(lip_sizes), min(lip_sizes),
                                                              np.mean(lip_sizes), np.median(lip_sizes)), fontsize=15);

Липиды становятся очень компактными.

Определите изменение гидрофобной и гидрофильной поверхности в ходе самосборки
In [ ]:
g_sas -f b_md.xtc -s b_md.tpr -o sas_b.xvg -dt 100
In [89]:
sizes = pd.read_csv(path+'sas_b.xvg', header = None, skiprows = 22, sep='\s+')
sizes = sizes[[0,1,2]]
sizes.columns = ['time', 'Hydrophobic', 'Hydrophilic']
sizes.head()
Out[89]:
time Hydrophobic Hydrophilic
0 0 206.710 135.376
1 100 190.593 150.694
2 200 167.211 155.765
3 300 154.562 159.593
4 400 152.911 162.379
In [90]:
plt.figure(figsize=(10,6))
plt.plot(np.array(sizes['time']), sizes['Hydrophobic'], label='Hydrophobic', color='darkblue');
plt.plot(np.array(sizes['time']), sizes['Hydrophilic'], label='Hydrophilic', color='goldenrod');
plt.legend();

Резко снижается площадь гидрофобной поверхности, доступной растворителю, что в общем-то логично. И в целом площади поверхностей убывают с течением времени, что свидетельствует о снижении энергии структуры -> происходит самосборка липидного слоя.

Оценка фазового состояния бифильных молекул
In [ ]:
g_order -s b_md -f b_md.xtc -o ord_end.xvg -n sn1.ndx -b 45000 -d X
g_order -s b_md -f b_md.xtc -o ord_start.xvg -n sn1.ndx -e 5000 -d X
In [104]:
start = pd.read_csv(path+'ord_start.xvg', header = None, skiprows = 12, sep='\s+')
end = pd.read_csv(path+'ord_end.xvg', header = None, skiprows = 12, sep='\s+')
In [105]:
plt.figure(figsize=(10,6))
plt.plot(np.array(start[0]), start[3], label='Start', color='darkblue');
plt.plot(np.array(end[0]), end[3], label='End', color='goldenrod');
plt.legend();

Видно, что в конце сборки атомы намного более упорядочены.

Save to Html

In [29]:
import subprocess
converted = subprocess.call(["jupyter-nbconvert", '--to', 'html',"Tikhonova. HW9.ipynb"], shell=False)
if converted==0:
    print 'Your ipynb-file was sucessfully converted!'
else:
    print 'Smth went wrong. for instance, check the filename...'
show_link = '<a href="%s" target="_blank">You can download it here!</a>'%('Tikhonova. HW9.html')
display(HTML(show_link))
Your ipynb-file was sucessfully converted!