File: start_pymol.py

package info (click to toggle)
pymol 2.5.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 42,288 kB
  • sloc: cpp: 476,472; python: 76,538; ansic: 29,510; javascript: 6,792; sh: 47; makefile: 24
file content (53 lines) | stat: -rw-r--r-- 1,637 bytes parent folder | download | duplicates (4)
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
# ================================================================
# NOTE: THIS APPROACH IS NOT RECOMMENDED SINCE THE PyMOL LAUNCH
#       PROCESS IS SUBJECT TO CHANGE WITHOUT WARNING
#
# The recommended approach is to just use PyMOL as your python
# interpreter:
#
#     "pymol -r <script.py>" or
#     "pymol -qcr <script.py>" instead of
#     "python <script.py>"
# 
# However, If must invoke PyMOL from an external interpreter, then
# you willl need to:
#
#  (1) prepare the environment first by sourcing "pymol.csh"
#      or an equivalent shell script which defines PYMOL_PATH,
#      LD_LIBRARY_PATH, TCL_LIBRARY, etc.
#
#  (2) include the following code block at the *top* level of your
#      program script.
#
# ================================================================
# PyMOL launch code
#
# === Provide arguments to PyMOL (first one must be "pymol")
pymol_argv = [ "pymol", "-q" ]
#
# === Launch the PyMOL thread(s)
try:
    import __builtin__
except ImportError:
    import builtins as __builtin__
import os,threading,__main__
threading.Thread(target=__builtin__.execfile,
     args=(os.environ['PYMOL_PATH']+"/modules/launch_pymol.py",
           __main__.__dict__,__main__.__dict__)).start()
#
# === Wait until PyMOL is ready to receive commands
e=threading.Event()
while not hasattr(__main__,'pymol'):
   e.wait(0.01)
while not pymol._cmd.ready():
   e.wait(0.01)
#
# PyMOL is now launched, you can now import "pymol" modules.
# ===============================================================

from pymol import cmd

cmd.load("$PYMOL_PATH/test/dat/pept.pdb")
print(" The surface area is: %8.3f"%cmd.get_area())