File: loop_torsion_sampler.py

package info (click to toggle)
promod3 3.4.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 966,596 kB
  • sloc: cpp: 55,820; python: 18,058; makefile: 85; sh: 51
file content (34 lines) | stat: -rw-r--r-- 875 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from promod3 import loop
from ost import conop
# this requires matplotlib and numpy
import matplotlib
# change next line, if you wish to use a GUI-based plot-output
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import numpy as np

# load a default sampler
t_sampler = loop.LoadTorsionSampler()

# dihedral angles will be stored in here
phi = list()
psi = list()

# draw from a random distribution
for i in range(1000):
    dihedral_pair = t_sampler.Draw(conop.ALA, 
                                   conop.PRO, 
                                   conop.ALA)
    phi.append(dihedral_pair[0])
    psi.append(dihedral_pair[1])

# and plot it
plt.xlim(-np.pi, np.pi)
plt.ylim(-np.pi, np.pi)
plt.plot(phi, psi, '.')
plt.xlabel("phi", fontsize='large')
plt.ylabel("psi", fontsize='large')
plt.title("ALA-PRO-ALA")

# store plot as png file
plt.savefig("torsion_plot.png")