Run via Terminal </br>
/Applications/MacPyMOL.app/Contents/MacOS/MacPyMOL -R
import time
from IPython.display import Image
from xmlrpc.client import ServerProxy
№1. Sculpting
Загрузила, посмотрела, оценила.
№2. Hydrogen bond detection
cmd = ServerProxy(uri="http://localhost:9123/RPC2")
defaultImage = '/tmp/pymolimg.png'
def focus(x):
cmd.center(x)
cmd.zoom(x)
def prepareImage(width=300, height=300, sleep=2, filename=defaultImage):
## To save the rendered image
cmd.ray(width, height)
cmd.png('/tmp/pymolimg.png')
time.sleep(sleep)
#download 1LMP and print the image
cmd.fetch('1lmp')
prepareImage()
Image(defaultImage)
#ligand detection
cmd.remove('sol')
cmd.select('ligand', 'het')
cmd.disable('ligand')
cmd.show('cartoon','1lmp')
cmd.hide('lines','1lmp')
cmd.show('sticks', 'ligand')
prepareImage()
Image(defaultImage)
#hydrogen bonds detection
cmd.do('h_add')
cmd.distance('HB', 'ligand','all', 3.5, 2)
focus('ligand')
cmd.zoom('ligand',0.0,1,0)
prepareImage()
Image(defaultImage)
№3. Mutagenesis
Проведем мутацию аспарата в валин
mut = 'resi 52'
cmd.show('lines','1lmp')
focus(mut)
cmd.select(mut)
prepareImage()
Image(defaultImage)
cmd.wizard('mutagenesis')
cmd.do('refresh_wizard')
cmd.do('cmd.get_wizard().do_select("%s")' % mut)
cmd.do('cmd.get_wizard().set_mode("VAL")')
cmd.do('refresh_wizard')
cmd.do('cmd.get_wizard().apply()')
cmd.do('cmd.set_wizard()')
cmd.save('1lmp_m.pdb')
focus(mut)
cmd.select(mut)
prepareImage()
Image(defaultImage)
№4. Animation
cmd.reinitialize()
cmd.do('''
load 1lmp.pdb
load 1lmp_m.pdb
set_view (\
1.000000000, 0.000000000, 0.000000000,\
0.000000000, 1.000000000, 0.000000000,\
0.000000000, 0.000000000, 1.000000000,\
0.000000000, 0.000000000, -234.967529297,\
-0.234825134, 50.978401184, 20.691335678,\
185.250183105, 284.684875488, -20.000000000 )
hide nonbonded
show cartoon
hide lines
color red, 1lmp
color white, /1lmp//A/ASP`52
show sticks, /1lmp//A/ASP`52
translate [-40, 0, 0], object=1lmp
super 1lmp,1lmp_m
color yellow, 1lmp_m
color purple, /1lmp_m//A/VAl`52
mset 1 x150
frame 1
zoom complete 1
mview store
mview store, object = 1lmp
mview store, object = 1lmp_m
frame 75
translate [40,0,0], object=1lmp
mview store, object=1lmp
frame 150
show lines,/1lmp//A/ASP`52
show lines,/1lmp_m//A/VAl`52
zoom /1lmp//A/ASP`52
mview store
mview store, object = 1lmp
mview store, object = 1lmp_m
mplay
''')
Сохранила картинки вручную и собрала через ffmpeg видео. Видео прикладываю отдельно, потому что не понимаю, почему не воспроизводится здесь.
import io
from base64 import b64encode
from IPython.core.display import HTML, display
video = open('movie.mp4', 'rb').read()
video_encoded = b64encode(video)
html_code = '<video controls alt="PyMol Movie" src="data:video/mp4;base64,{}" type="video/mp4">'.format(video_encoded)
HTML(html_code)
№5. TAMRA
cmd.reinitialize()
cmd.load('/Users/ElenTevanyan/Documents/Study/Структурная биоинформатика/tamra.sdf')
cmd.show('sticks','tamra')
prepareImage()
Image(defaultImage)
cmd.fetch('1lmp')
cmd.hide('nonbonded')
cmd.remove('sol')
cmd.select('ser','/1lmp//A/SER`32')
cmd.show ('sticks','ser')
cmd.color('purple','ser')
cmd.select('OG','/1lmp//A/SER`32/OG')
cmd.color ('purple','OG')
cmd.fuse ('OG', '/tamra///UNK`/O')
focus('/tamra///UNK`/O')
cmd.disable('1lmp')
prepareImage()
Image(defaultImage)
№6. PolyAlanin alpha-chain
phi = -50
psi = -40
cmd.reinitialize()
cmd.fragment('ala')
al = 'ala'
for i in range (2,101):
cmd.edit("i. %i & n. C" % i)
cmd.do('editor.attach_amino_acid("pk1", "%s")' % al)
cmd.set_dihedral("i. %i & n. N" % i, "i. %i & n. CA" % i,
"i. %i & n. C" % i, "i. %i & n. N" % (i+1),
phi)
cmd.set_dihedral("i. %i & n. C" % i, "i. %i & n. N" % (i+1),
"i. %i & n. CA" % (i+1), "i. %i & n. C" % (i+1),
psi)
cmd.reset()
prepareImage()
Image(defaultImage)