File: chempy_model03.py

package info (click to toggle)
pymol 2.4.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 43,312 kB
  • sloc: cpp: 480,106; python: 79,860; ansic: 28,343; javascript: 6,792; sh: 47; makefile: 30; csh: 8
file content (44 lines) | stat: -rw-r--r-- 986 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
35
36
37
38
39
40
41
42
43
44
from pymol import cmd
from random import random
import time

# this shows how you can efficiently update the coordinates
# of an existing model for viewing as a PyMOL trajectory (from RAM)

# first we need a model

cmd.load("$PYMOL_PATH/test/dat/pept.pdb","demo")

# let's dress it up a little bit 

cmd.show("sticks","demo")

cmd.show("spheres","resi 10")

cmd.color("yellow","resi 5 and element C")

# now loop, updating the coordinates and appending the model
# onto 99 subsequent frames...

m = cmd.get_model()
for a in range(1,100):
   for a in m.atom:
      a.coord[0]+=(random()-0.5)*0.1
      a.coord[1]+=(random()-0.5)*0.1
      a.coord[2]+=(random()-0.5)*0.1
   cmd.load_model(m,"demo") # NOTE: no state number provided -> appends

# now define the movie with short pauses at beginning and and

cmd.mset("1 x15 1 -100 100 x15")

# now play the movie...

cmd.mplay()

# by default, PyMOL plays ~30 fps.
# "set movie_delay=0" to see maximum speed...

time.sleep(3)

cmd.mstop()