用PyMOL制作分子结构图像及所用脚本

信息来源

  1. Cool PyMOL-generated Images and their Scripts.
  2. Making animations and images with PyMOL

PyMol is one of the best open source software for visualizing the bio-molecules. Still many computational chemists, don’t use it for day -to-day modelling or for generating a high quality images and animations, partly because other software (such as Molden, Gaussview) can generate figures very easily although with not such a good quality and with limited number of representations. I was one among them, so I thought of exploring it and infact stunned by the abilities of Pymol. In this post I will be presenting a code to generate an animated gif and a high quality ray-traced png file.

The best way I found to deal with not so friendly Pymol is through its command line interface. All the commands should be placed in commands.pml file and then it should be run using the following command.

pymol -c commands.pml

原博客作者似乎是错的?或者使用的不是我所用的依赖于python运行的版本;PyMOL的独立于Python的版本似乎功能更强,但是要收费。

对于依赖于Python运行的PyMOL包而言,则需要在PyMOL的命令行中用 @commands.pml " 才能运行。

安装下载

用Linux和McOS的都是高手,不需解释。windows下面操作繁琐,但也有现成的可以借用。

PyMOL,显然是基于Python开源的一个工具。但PyMOL本身据说又不是免费的(这应该是因为PyMOL有不同的版本,开源的基于Python的版本功能应该有所限制;面向商业化和学术的专门用途的应该根据功能会产生费用。下面转帖的博主使用的命令行中的命令在Python版本的PyMOL中无法使用,可能跟原博主所用的可能是不依赖于python的功能更加完整的版本有关)

PyMOL(win32,python27, x64 win,python27)以及使用它所需要的编译好的whl文件都可以在这里下载

很多时候,一些简单的包,只要电脑上有编译器,都可以用当前最新pip自动从源文件build并安装;少数对windows要求较高的,则不妨下载其预先编译好的whl文件之后再用pip安装。

实现部分

# first load lipid model
load lipids.pdb; 
# hide the initially loaded representation
hide all; 
# set background color to white
bg_color white; 
# show lipid model as sticks
show sticks, lipids; 
# color the lipids model by element CHNOS #2 (carbon green)
util.cbag lipids; 

# select all hydrogens and remove them from the model
select hideme, hydro; 
hide everything, hideme; 
delete hideme;

# create phosphate spheres
create phos, elem p; 
hide everything, phos;
show spheres, phos;

# load helix model
load helix.pdb; 
# hide the initially loaded representation
hide everything, helix;
# make the helical struct into a cartoon form
show cartoon, helix; 
# style the cartoon form
cartoon putty; 

# reposition the helix among the lipids using
# the 3-Button Editing Mouse Mode
# basically
# Shift+Left Mouse to rotate the helix
# Shift+Middle Mouse to move the helix
# also, you may want to make liberal use of the
# get_view and set_view commands.
#
# When you have the scene set like you want,
# continue with...

# move the model to find the view you want, 
# and use get_view to get the coordinate description
get_view;

# set ray_trace_mode to black and white outline
set ray_trace_mode, 2;

这里写图片描述

显示分子

PyMol is one of the most used molecular visualization software in both Chemistry and Biology. One of the bets qualities of PyMol is the ability to incorporate different capabilities such as visualizing hydrogen bonds. In this post, a small script is presented to visualize all possible H-bonds in a molecule.

All the commands should be placed in hbonds.pml file and then it should be run using the following command.

pymol -c hbonds.pml

原博客作者似乎是错的?或者使用的不是我所用的依赖于python运行的版本;PyMOL的独立于Python的版本似乎功能更强,但是要收费。

要在PyMOL的命令行中用@hbonds.pml " <script id="MathJax-Element-42" type="math/tex">"</script>才能运行。

load peptides.pdb
hide all
set orthoscopic,on
orient
show sticks
show spheres
set sphere_scale, 0.3
set stick_radius,0.2
distance hbonds,all,all,3.2,mode=2
hide labels,hbonds
bg_color white
center hbonds
set dash_color, yellow
zoom all,0.7
set antialias,2
set depth_cue, 0
set ray_trace_mode,1
set ray_shadows,0
ray 720,576
png hbond.png

这里写图片描述

load $TUT/1hpv.pdb
set_color oxygen, [1.0,0.4,0.4]
set_color nitrogen, [0.5,0.5,1.0]
remove solvent
as spheres
util.cbaw
bg white
set light_count,8
set spec_count,1
set shininess, 10
set specular, 0.25
set ambient,0
set direct,0
set reflect,1.5
set ray_shadow_decay_factor, 0.1
set ray_shadow_decay_range, 2
unset depth_cue
# for added coolness
# set field_of_view, 60
ray

这里写图片描述

视频文件

生成动画

Pymol code

The next step is to see how to write the code. Most of the commands are similar to python programming language and its surprisingly as shown below.

load test.pdb
hide all
reset
select qplex, resid 4-6+10-12+16-18+22-24
select ligand, resname 1-3+7-9+13-15+19-21+25+26
show sticks, qplex
show spheres, qplex
rotate y,90
set sphere_scale, 0.2
set stick_radius,0.15
bg_color white
set antialias,1
set depth_cue, 0
mset 1 x360
util.mroll(1,360,2)
set ray_trace_frames=1
set cache_frames=0
mclear
mpng mov

Have a close look, the commands look like a conversation with the PyMol. When you run the code it generates a lot of png files. Now convert these png files to either animated gif file (using convert *.png animated.gif command)or a .mp4 or .mov (using ffmpeg or avconv command) files. You will get a gif similar to the one above. I used the pymol command examples from the PyMol wiki to make this command file, so explore it and share if you make something new . Hope it’s useful for you.

*Most important thing to know is the structure of .pdb file format and the more you know about it, easier it will be to handle PyMol.

结果欣赏

这里写图片描述
结果太大无法上传

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值