In [1]:
from xmlrpclib import ServerProxy
In [2]:
import __main__
__main__.pymol_argv = [ 'pymol', '-x' ]
In [3]:
import pymol
pymol.finish_launching()
from pymol import cmd,stored
In [4]:
cmd.fetch('1lmp')
Out[4]:
'1lmp'
In [5]:
cmd.do('''
fetch 1cll, async=0
as lines, n. C+O+N+CA
zoom i. 4+5
mset 1 x1000
mview store''')
In [6]:
for i in range(100):
    cmd.frame((10*i)+1)
    cmd.zoom( 'n. CA and i. %d+%d' % (i,i+7))
    cmd.mview('store')    
In [7]:
v = cmd.get_view()
cmd.set_view(v)
In [8]:
stored.r = [] 
cmd.iterate('1cll and n. CA','stored.r.append(int(resi))')
Out[8]:
152
In [9]:
import numpy as np
length = len(stored.r)
colors = np.linspace(1,0.5, length)
for k,i in enumerate(stored.r):
    cmd.set_color('col%d' %k, [colors[k],0.5,0.75])
    print [1,1,colors[k]]
    cmd.set('cartoon_color','col%d' % k ,'resi %d' % i)
cmd.show_as('cartoon','all')
In [11]:
cmd.png(filename='pymol.png',width='10cm',dpi=300,ray=1)
In [13]:
from IPython.display import Image
Image(filename='pymol.png')
Out[13]:
In [ ]:
#ddd