I've got this script which I want to run in a loop as part as another program. I am therefore calling it from the shell as such:
pymol -c /program.py
It doesnt work. This, however, works:
pymol /program.py
But it brings up the pymol gui of course. I'm thinking I might need to load some library to use the file in -c mode. Can you help me? Here is the script:
from pymol.cgo import *
from pymol import cmd
cmd.load ("/Users/olivier/Travail/Output/EST.pdb")
cmd.ray (1024,768)
#cmd.do ("run ./Travail/grid.py")
#cmd.grid ("/Users/olivier/Travail/Grid.txt", grid)
lines=open('/Users/olivier/Travail/Grid.txt', 'r').readlines()
obj = []
for line in lines:
x1=float(line[0:6].strip())
y1=float(line[8:14].strip())
z1=float(line[16:22].strip())
x2=float(line[24:30].strip())
y2=float(line[32:38].strip())
z2=float(line[40:46].strip())
print "%7.3f\n" % (x1)
obj += [
LINEWIDTH, 0.1,
BEGIN, LINES,
COLOR, 0.5, 0.5, 0.5,
VERTEX, x1, y1, z1,
VERTEX, x2, y2, z2,
END]
cmd.load_cgo(obj,"grid")
# Add to PyMOL APi
cmd.do ("zoom EST")
cmd.png ("/Users/olivier/Travail/Figures/EST.png")
The only way to get graphics output in command-line mode '-c' option is to call the ray tracer before saving the PNG file. Modify your script as shown below:
...
cmd.do ("zoom EST")
cmd.ray()
cmd.png ("/Users/olivier/Travail/Figures/EST.png")
...