In [1]:
from xmlrpc.client import ServerProxy
from IPython.display import Image
In [2]:
cmd = ServerProxy(uri="http://localhost:9123/RPC2")
In [3]:
cmd.fetch('1lmp')
Out[3]:
'1lmp'
In [4]:
import time
cmd.hide("everything")
In [5]:
for i in range (1,50):
     cmd.show_as("cartoon",str(i-1)+"+"+str(i)+"+"+str(i+1)+'/CA')
     time.sleep(.1)
     cmd.show_as("ribbon",str(i-1)+"+"+str(i)+"+"+str(i+1)+'/CA')
In [6]:
cmd.do('''
hide everything
show cartoon
''')
In [47]:
cmd.set("opaque_background", 'off')
cmd.set("ray_trace_mode", '4')
cmd.bg_color('white')
cmd.zoom('i. 100-103')
cmd.png("D:\HW_pymol\pic1.png")  
In [48]:
 Image("D:\HW_pymol\pic1.png")
Out[48]:
In [70]:
cmd.reinitialize()
cmd.fetch('1lmp')
Out[70]:
'1lmp'

Водородные связи из пресета

In [71]:
cmd.do("remove solvent")
cmd.h_add("1lmp")
cmd.do("preset.ligands()")
cmd.png("D:\HW_pymol\pic2.png") 
In [72]:
Image("D:\HW_pymol\pic2.png")
Out[72]:
In [112]:
cmd.reinitialize()
cmd.fetch('1lmp')
cmd.h_add("all")
cmd.do("remove solvent")
cmd.extract('ligand','het')
In [87]:
cmd.png("D:\HW_pymol\pic3.png") 
In [88]:
Image("D:\HW_pymol\pic3.png")
Out[88]:

Код для выделения связей селектом взят из вики https://pymolwiki.org/index.php/Displaying_Biochemical_Properties#Hydrogen_bonds_between_specific_atoms

In [113]:
cmd.do('''
select don, (elem n,o and (neighbor hydro))
select acc, (elem o or (elem n and not (neighbor hydro)))

dist HBA, (ligand and acc),(1lmp and don), 3.2
dist HBD, (ligand and don),(1lmp and acc), 3.2

delete don
delete acc
hide (hydro)

hide labels,HBA
hide labels,HBD
''')
cmd.png("D:\HW_pymol\pic4.png") 
In [115]:
Image("D:\HW_pymol\pic4.png")
Out[115]:
In [149]:
cmd.reinitialize()
cmd.fetch('1lmp','1lmp_mut')
cmd.do("remove solvent")
cmd.wizard("mutagenesis")
cmd.do('''
refresh_wizard
cmd.get_wizard().set_mode("TRP")
cmd.get_wizard().do_select("59/")
cmd.get_wizard().apply()
cmd.wizard(None)
''')
In [150]:
cmd.fetch('1lmp')
cmd.do("remove solvent")
cmd.extract('ligand','het')
In [151]:
cmd.do('''
set matrix_mode, 1
set movie_auto_interpolate, 1
set movie_auto_store, 
orient

as cartoon, 1lmp
as cartoon, 1lmp_mut
color green, 1lmp
color green, 1lmp_mut
color red, 1lmp_mut and resi 59
as sticks, resi 59
as sticks, ligand
mset 1 x120

frame 1
mview store
mview store, object=1lmp
mview store, object=1lmp_mut

frame 60
center resi 59
origin resi 59
zoom resi 59
super 1lmp, 1lmp_mut

frame 120
orient ligand or resi 59
zoom ligand or resi 59
mview store
mview store, object=1lmp
mview store, object=1lmp_mut

frame 1
mplay
''')

Ролик загружен на http://vsb.fbb.msu.ru/dmsf/files/1362/download

In [169]:
cmd.reinitialize()
cmd.fetch('1lmp')
cmd.do("remove solvent")
In [164]:
cmd.do("select resn ser")
cmd.png("D:\HW_pymol\pic5.png") 
In [165]:
Image("D:\HW_pymol\pic5.png")
Out[165]:

Можно выбрать все серины и посмотреть, куда ставить метку. Нижний левый - 15 по номеру аминокислота

In [172]:
cmd.reinitialize()
cmd.fetch('1lmp')
cmd.do("remove solvent")
cmd.do("fetch 2762604,name=TAMRA, type=cid")
cmd.do('''
select  tamra_fuse_spot, n. O and neighbor n. H and TAMRA
fuse tamra_fuse_spot, 15/CB
torsion 15
select /1lmp///UNK
orient sele
''')
cmd.png("D:\HW_pymol\pic6.png")
In [173]:
Image("D:\HW_pymol\pic6.png")
Out[173]:
In [181]:
cmd.reinitialize()
cmd.fragment('ala')
cmd.edit("ala/c")
for i in range(1,15): 
    cmd.do('''cmd.editor.attach_amino_acid("pk1","ala")''')
cmd.do("orient")
cmd.png("D:\HW_pymol\pic7.png")
In [183]:
Image("D:\HW_pymol\pic7.png")
Out[183]:
In [ ]: