File: importing.py

package info (click to toggle)
pymol 1.8.4.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 42,248 kB
  • ctags: 24,095
  • sloc: cpp: 474,635; python: 75,034; ansic: 22,888; sh: 236; makefile: 78; csh: 21
file content (81 lines) | stat: -rw-r--r-- 1,994 bytes parent folder | download | duplicates (7)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# This is an example of firing up PyMOL inside of a subordinate
# process via an "import pymol"
# 
# NOTE: for this to work, PyMOL must be installed in a
# Python-dependent fashion (e.g. pymol-0_98-bin-win32-py23) etc.
#
# WARNING: stability issues have been known to occur with this
# approach, so anticipate problems...take-down is messy.
#
# WARNING: Right now, there is no way for the main process to know
# when PyMOL is actually initialized and ready to go, so we simply
# sleep a second after importing.


import string
import __main__

# note that passing in a "-z" option would keep the window hidden
# until you called pymol.cmd.window("show").

__main__.pymol_argv= string.split("pymol -qxiF  -X 300 -Y 100 -H 400 -W 400")
import pymol

# give PyMOL enough time to initialize (we need to find a safe and
# robust alternative to this stupid delay especially since the
# pymol.finish_launching() method now seems to be broken)

import time
time.sleep(1)


# put up some content

if 1:
   pymol.cmd.set("sweep_mode",3)
   pymol.cmd.rock()
   pymol.cmd.turn("x",180)
   pymol.cmd.load("$TUT/1hpv.pdb")
   pymol.preset.pretty("1hpv")
   pymol.cmd.orient()
   pymol.cmd.turn("y",85)
   pymol.cmd.zoom("all",20)
   pymol.cmd.orient("organic & e. N+O",animate=10)
   pymol.cmd.show("sticks","organic")

# play peek-a-boo with the window

if 1:
   time.sleep(5)
   pymol.cmd.window("hide")
   print "Peek-a-boo!"
   time.sleep(1)
   pymol.cmd.window("show")
   time.sleep(5)
   pymol.cmd.window("hide")
   print "Peek-a-boo!"
   time.sleep(1)
   pymol.cmd.window("show")
   time.sleep(5)
   pymol.cmd.window("hide")
   print "Peek-a-boo!"
   time.sleep(1)
   pymol.cmd.window("show")

# now quit 

   print "Quitting..."
   time.sleep(1)
   print "3..."
   time.sleep(1)
   print "2..."
   time.sleep(1)
   print "1..."
   time.sleep(1)
   print "Die!"

# note, we cannot let the main thread terminate without first calling
# pymol.cmd.quit() which will take-down PyMOL

   pymol.cmd.quit()