In [1]:
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning) 
# try it your self
# make sure to click 'Cell', then 'Run All' to initilize pytraj.
# enter the command or modify below code and then Shift-Enter to run.

import pytraj as pt

In [2]:
%matplotlib inline

In [3]:
!ls ./data


lysozyme.mdcrd  tz2.nc          tz2.ortho.parm7
lysozyme.prmtop tz2.ortho.nc    tz2.parm7

In [4]:
traj = pt.iterload('lysozyme.mdcrd', 'lysozyme.prmtop')

In [5]:
print(traj)


pytraj.TrajectoryIterator, 200 frames: 
Size: 0.008762 (GB)
<Topology: 1960 atoms, 129 residues, 1 mols, non-PBC>
           

In [6]:
pt.radgyr(traj)


Out[6]:
array([ 14.21385988,  14.29338811,  14.36196037, ...,  14.17920482,
        14.22669114,  14.21764279])

In [7]:
# supported limited progress bar

data = pt.compute('''
molsurf @CA
multidihedral resrange 3-10
vector :2 :9
distance :3 :7
''', traj)

In [8]:
# calulate lysozyme S2 order paramter


# select H (backbone) indices. Need to provide corresponding Topology and mask
h = pt.select_atoms(traj.top, '@H')
n = h - 1
# create atom pairs
nh = list(zip(n, h))
print(nh[:10])

# calulate S2
S2 = pt.NH_order_parameters(traj, nh)


[(24, 25), (40, 41), (60, 61), (67, 68), (91, 92), (101, 102), (116, 117), (135, 136), (145, 146), (155, 156)]

In [9]:
# plot
from matplotlib import pyplot as plt
plt.plot(S2)


Out[9]:
[<matplotlib.lines.Line2D at 0x10a0910f0>]

Visualize


In [11]:
import pytraj as pt
import nglview as nv

traj = pt.load(nv.datafiles.TRR, top=nv.datafiles.PDB)
view = nv.show_pytraj(traj)
view