try pytraj
online:
Contents
There are two modes to run pytraj: script mode and interactive mode.
script mode: you need to write code in a file (for example: my_file.py
) and use python
to run your file:
python my_file.py
interactive mode: we suggest to use ipython
or jupyter notebook
to explore data interactively.
In [1]: import pytraj as pt
In [2]: traj = pt.load('tz2.nc', 'tz2.parm7')
In [3]: traj
Out[3]:
pytraj.Trajectory, 101 frames:
Size: 0.000503 (GB)
<Topology: 223 atoms, 13 residues, 1 mols, non-PBC>
In [4]: import pytraj as pt
In [5]: traj = pt.load('tz2.nc', 'tz2.parm7')
# get indices for backbone H atoms
In [6]: h_indices = pt.select_atoms(traj.top, '@H')
In [7]: h_indices
Out[7]: array([ 14, 38, 52, ..., 172, 196, 218])
# get indices for backbone N atoms
In [8]: n_indices = pt.select_atoms(traj.top, '@N')
In [9]: n_indices
Out[9]: array([ 0, 13, 37, ..., 171, 195, 217])
# compute distance between COM of (residue 1 to 3) and COM of (residue 5 to 8)
In [10]: pt.distance(traj, ':1-3 :5-8')
Out[10]:
array([ 12.05177307, 9.0687678 , 8.40387078, ..., 11.20758584,
8.73365734, 10.04000583])
In [11]: import pytraj as pt
In [12]: pdb = pt.load_pdb_rcsb("1l2y")
In [13]: result = pt.dssp(pdb)
In [14]: print(result)
(array(['ASN:1', 'LEU:2', 'TYR:3', ..., 'PRO:18', 'PRO:19', 'SER:20'],
dtype='<U6'), array([['0', 'H', 'H', ..., '0', '0', '0'],
['0', 'T', 'H', ..., '0', '0', '0'],
['0', '0', 'H', ..., '0', '0', '0'],
...,
['0', 'H', 'H', ..., '0', '0', '0'],
['0', '0', 'H', ..., '0', '0', '0'],
['0', 'T', 'H', ..., '0', '0', '0']],
dtype='<U1'), <pytraj.DatasetList with 8 datasets>
none_avg
[ 0.30000001 0.25 0.34999999 ..., 0.30000001 0.30000001
0.30000001]
para_avg
[ 0. 0. 0. ..., 0. 0. 0.]
anti_avg
[ 0. 0. 0. ..., 0. 0. 0.]
...
turn_avg
[ 0.1 0.15000001 0.1 ..., 0.1 0.05 0.15000001]
bend_avg
[ 0.05 0.1 0.05 ..., 0.05 0.1 0.05])
# search hbonds for all residues
In [15]: hbonds = pt.search_hbonds(pdb)
In [16]: hbonds
Out[16]:
<pytraj.hbonds.DatasetHBond
donor_acceptor pairs : 31>
# print first few hbond
In [17]: hbonds.donor_acceptor[:5]