科学网

 找回密码
  注册

tag 标签: pymol

相关帖子

版块 作者 回复/查看 最后发表

没有相关内容

相关日志

永久免费的Pymol最新版来了!
caixin5120 2019-3-2 12:24
最新版Pymol2.3的效果 你是否发现Pymol新的版本已经下载不到安装版了? 你还在担心Pymol是商业软件不敢使用? 以下是Pymol官方网站对版权的描述。 “Open-Source Philosophy PyMOL is a commercial product, but we make most of its source code freely available under a permissive license. The open source project is maintained by Schrödinger and ultimately funded by everyone who purchases a PyMOL license. Open source enables open science. This was the vision of the original PyMOL author Warren L. DeLano.” 从此描述来看,Pymol是一个开源项目,这是其创始者Warren Lyford DeLano老先生一直坚持的。 你大可以放心的免费使用源码编译后的Pymol用于学术研究。 当然,不要忘记了 致谢 ! 生物分子模拟论坛BioMS.org自2012年创办以来一直为大家分享Pymol的相关教程,并有专门的版面讨论Pymol的使用技巧, 这里将持续更新最新编译的Pymol 。 接下来我们将分享如何 永久免费 的使用 最新版 的Pymol了! 该方法支持三大操作系统Windows、Linux、Mac, 这里我们仅以Windows10操作系统为例,其它系统类似。 第一步:下载Anaconda 新手建议选择Python 3.6 Version (如果你电脑中还有需使用Pyhon 2.7的软件,建议选用Python 2.7 Version,后续设置环境变量。) https://www.anaconda.com/download/ 第二步:安装Anaconda 建议新手在选项页面打钩。 (熟悉环境变量设置的朋友可以不用勾选,安装完后手动设置会更好。) 安装过程需要较长时间,请耐心等待。 第三步:下载Pymol 从BioMS.org论坛帖子的附件中下载最新的Pymol 2.3( pymol-2.3.0a0-cp36-cp36m-win_amd64.whl ) 下载地址:http://bioms.org/forum.php?mod=viewthreadtid=42337 第四步:安装Pymol 首先在下载了pymol ‑ 2.3.0a0 ‑ cp36 ‑ cp36m ‑ win_amd64.whl的文件夹中,按住Shift键点击鼠标右键,点选“在此处打开Powershell窗口(S)”。 其次,在命令行输入“pip installpmw”。 然后在命令行输入“pip install pymol ‑ 2.3.0a0 ‑ cp36 ‑ cp36m ‑ win_amd64.whl”。 最后,进入Anaconda的安装目录,找到Anaconda3\\Scripts文件夹,里面有pymol.exe执行文件,做一个快捷方式放桌面吧! 第五步:运行pymol显示一个例子 双击pymol.exe打开程序,可以看到最新的2.3版本正常运行了。 下面是一个例子,PDB ID:2RGU,可以看到新版的pymol在使用ray命令后,背景自动透明,且无水印! 保存为png格式,如下图。 好了!现在你可以永久免费的使用最新版的Pymol了。 如果还有什么问题,欢迎留言讨论,或访问生物分子模拟论坛http:// bioms.org 研讨。 BioMS.org物分子模拟论坛 【分迪科技 PROTAC践行者】 期待与您合作! 028-85160035 sales@moldesinger.com www.moldesigner.com PROTAC蛋白降解药物【前世今生】系列 1、 蛋白降解靶向嵌合体(PROTAC)新药开发系列【一】 2、 【PROTAC】新药开发系列(二)降解MetAP2 3、 【PROTAC】新药开发系列(三) 降解雌、雄激素受体 4、 【PROTAC】新药开发系列(四) 透膜降解AR和FKBP12 5、 【PROTAC】新药开发系列(五) ——降解AR的“整体小分子”设计 欢迎阅读成功案例 1、 千里姻缘一线牵:设计PROTAC治疗纤维化疾病 2、 “解密”纳米材料包载药物的机制:分子模拟研究嵌段共聚物包载多西他赛 3、 食品加工工艺机制研究: 高密度CO2诱导肌球蛋白自组装(上) 本文版权属于分迪科技,转载请注明出处,商业使用需取得分迪科技书面同意! 扫描二维码关注分迪科技 微信公众号 ,更多前沿资讯!
个人分类: Pymol|65370 次阅读|0 个评论
pymol
richor 2018-11-27 11:38
pymol使用: \0入门: http://www.sci.ccny.cuny.edu/%7Egunner/Pages-422/PDF/IntroPyMOL.pdf
个人分类: 分子模拟|2 次阅读|0 个评论
统计水分子间氢键个数的 Pymol 脚本
jasonmumu 2017-11-21 19:58
笔者编写了一个统计水分子间氢键个数的小脚本,与大家分享一下。该脚本基于 python 3 编写而成, 可以直接应用于 pymol 软件。脚本的使用方法与在 pymol 中使用其他脚本的方法一样,即把 *.py 文件放到与 PyMOL.exe 相同的目录下,接着 run *.py ,此时 *.py 文件中扩展的命令生效,最后执行该命令。这里,小脚本的使用方法是:1) run sum_hb.py; 2) sum_hb 。需要注意的是,该脚本仅能计算水分子之间的氢键,事实上它能很方便地扩展到含S,N等原子的体系的计算。 sum_hb.py 文件在附件中( sum_hb.py ),这里也把代码贴出来供大家参考: # -*- coding: utf-8 -*- Created on Tue Nov 21 14:54:28 2017 Usage: 1) run sum_hb.py; 2) sum_hb Author: Mu Liu-Hua, 2017 #声明函数包 import numpy as np import math from pymol import cmd, stored def sum_hb(): #点乘函数 def dot_product(xyz_1,xyz_2): return xyz_1 * xyz_2 + xyz_1 *xyz_2 + xyz_1 * xyz_2 def distant(xyz_O_1,xyz_O_2): return math.sqrt(math.pow(xyz_O_1 - xyz_O_2 ,2) + math.pow(xyz_O_1 \\ - xyz_O_2 ,2) + math.pow(xyz_O_1 - xyz_O_2 ,2)) #计算长度的函数 def length(xyz_O_1): return math.sqrt(math.pow(xyz_O_1 ,2) + math.pow(xyz_O_1 ,2) + math.pow(xyz_O_1 ,2)) n_frames = 2 arguments = ( )#氢键的判别标准 N_O= stored.list= == O: N_O.append(index_0+1) if element_name ==H: N_H.append(index_0+1) #统计氢键的个数 hydrogen_number = np.zeros( ) frames_index = np.zeros( ) for n in range(n_frames-1): frames_index = n+1 N_xyz = cmd.get_coords('all', 1) possible_bonds = ) O_1 = N_O xyz_O_1 = N_xyz for index_2 in range(index_1 + 1, len(N_O)): xyz_O_2 = np.zeros( ) O_2 = N_O xyz_O_2 = N_xyz dist = distant(xyz_O_1,xyz_O_2) if dist arguments : possible_bonds.append((O_1, O_2)) #利用氢原子与氧原子的距离作进一步判断 possible_bonds_refined = O2_index = possible_bond O1_xyz = N_xyz O2_xyz = N_xyz for H_index_1 in range(len(N_H)): H_index = N_H H_xyz = N_xyz dist1 = distant(O1_xyz,H_xyz) if dist1 arguments : dist2 = distant(O2_xyz,H_xyz) if dist2 arguments : if dist1 1.3 or dist2 1.3: if dist1 1.3: possible_bonds_refined.append((H_index, O1_index, O2_index)) else: possible_bonds_refined.append((H_index, O2_index, O1_index)) #利用角度作最终判断 hydrogen_bonds = bond_donor_index = possible_bond_refined bond_acceptor_index = possible_bond_refined bond_donor = N_xyz hydrogen = N_xyz bond_acceptor = N_xyz vector1 = ( - bond_donor , hydrogen - \\ bond_donor , hydrogen - bond_donor ]) vector2 = ( - bond_donor , bond_acceptor \\ - bond_donor , bond_acceptor - bond_donor ]) angle = math.acos((dot_product(vector1,vector2))/(length(vector1) * \\ length(vector2))) * 180 / math.pi # at most 180 if angle = arguments : hydrogen_bonds.append(possible_bond_refined) hydrogen_number =len(hydrogen_bonds) print (hydrogen_bonds are:,hydrogen_bonds) print (hydrogen_number is:,int(hydrogen_number)) cmd.extend(sum_hb, sum_hb) sum_hb.py 参考网址: HBonanza: a computer algorithm for molecular-dynamics-trajectory hydrogen-bond analysis. http://rocce-vm0.ucsd.edu/data/sw/hosted/hbonanza/ . 2017.11.21 PyMOL Command Reference. http://pymol.org/pymol-command-ref.html 2017.11.21
个人分类: 程序的编写|6798 次阅读|0 个评论
如何用 PyMol 画 Molecule of the Month 风格的图
arapallas 2014-6-27 18:57
纯属娱乐 呃这些都太麻烦了还是画个简单的吧 打开文件、调整好颜色和角度、以sphere显示并打光: 完全不是一个世界的。一步一步来 1. set ray_trace_mode, 1 显示边缘黑线 2. set ambient, 1 环境光开到最大。只剩下每个圆球上的小点点了 3. set light_count, 1 对比原图 边缘黑线过多、过深 4. set ray_trace_disco_factor, 1 终于比较形似了 仔细比较可以看出,原图的颜色选用讲究得多... 就不在这里花时间了。 顺带附背景空白的方法: set ray_opaque_background, 0 参考: http://www-cryst.bioc.cam.ac.uk/members/zbyszek/figures_pymol http://www.pymolwiki.org/index.php/Ray_trace_mode#Modes http://www.pymolwiki.org/index.php/Ray_opaque_background
个人分类: 软件使用|5575 次阅读|0 个评论
pymol 怎么显示距离 为两位有效数字
autodataming 2014-3-10 10:32
在量化中测量2个原子的距离,要用两位有效数字,而pymol中默认是显示为1位有效数字。 具体操作,有图教程在附件中。 pymol 怎么显示距离.docx 我就不在这里排版了。
个人分类: DrugDesign|17083 次阅读|0 个评论
Pymol 命令整理 V1.0
张世成 2013-11-25 14:19
初步整理的一些较常用的命令,时间有限,未能注释。后续会进一步注释。 http://pymolwiki.org/index.php/Main_Page Pymol log_open log-file-name.pml Pymol log_close Creat a file to record the commands Pymol load 2vlo.pdb Pymol load 2vlo.pdb, test Pymol show representation Pymol hide representation Representation: cartoon, ribbon, dots,spheres, surface, mesh Pymol label all, chains Pymol hide ribbon, chain f+g+h+i+j Or Pymol select test, chain f+g+h+i+j Pymol hide ribbon, test Pymol select selection-name,selection-expression Pymol color color-name Pymol color color-name, selection-expression Pymol color red, ss h Pymol color yellow, ss s Pymol color green, ss l+ selection-expression selector + identifier symbol: chemical-symbol-list, e. Pymol select polar, symbol o+n name: atom-name-list, n. Pymol select carbons, name ca+cb+cg+cd resn: residue-name-list, r. Pymol select aas, resn asp+glu+asn+gln resi: residue-identifier-list, l. Pymol select mults10, resi 1+10+100 residue-identifier-range Pymol select nterm, resi 1-10 alt: alternate-conformation-identifier-list,alt Pymol select altconf, alt a+b chain: chain-identifier-list, c. Pymol select firstch, chain a segi: segment-identifier-lis, s. Pymol select ligand, segi lig flag: flag-nummer, f. Pymol select f1, flag 0 numeric_type: type-nummer, nt. Pymol select type1, nt. 5 text_type: type-string, tt. Pymol select subset, tt. HA+HC id: external-index-number, id Pymol select idno, id 23 index: internal-index-number, idx. Pymol select intid, index 23 ss: secondary-structure-type, ss Pymol select allstrs, ssh+s+l+ Pymol select chain a and resi 100 andca Pymol select a/100/ca /objectname/segiidentifier/chainidentifier/resiidentifier/nameidentifier /objectname/segiidentifier/chainidentifier/resiidentifier /objectname/segiidentifier/chainidentifier /objectname/segiidentifier resiidentifier/nameidentifier chainidentifier/resiidentifier/nameidentifier segiidentifier/chainidentifier/resiidentifier/nameidentifier objectname/segiidentifier/chainidentifier/resiidentifier/nameidentifier Cartoon: Pymol cartoon type, (selection) automatic, loop, tube, oval, rectangle,arrow, dumbbell, skip Pymol set cartoon_flat_sheets, 1 Pymol set cartoon_flat_sheets, 0 Pymol set cartoon_smooth_loops, 1 Pymol set cartoon_smooth_loops, 0 Pymol set cartoon_oval_width, 0.2 Pymol set cartoon_oval_length, 1.5 Pymol set cartoon_rect_width, 0.5 Pymol set cartoon_rect_length, 1.5 Pymol set cartoon_loop_radius, 0.2 Pymol set cartoon_fancy_helices, 1 Pymol set cartoon_fancy_sheets, 1 Pymol set cartoon_dumbbell_width, 0.1 Pymol set cartoon_dumbbell_length, 2 Pymol set cartoon_dumbbell, 0.2 Pymol set cartoon_transparency, 0.5 Pymol set cartoon_refine, 20 Pymol set cartoon_color, green fft HKLIN protein.mtz XYZIN protein.pdbMAPOUT 2fofc.ccp4 LABIN F1=FWT PHI=PHWT GRID SAMPLE 5 END Pymol load glucosyltransferase.pdb, pro Pymol load 2fofc.ccp4 Wizard -- Density Pymol remove resn HOH Pymol select upg, chain b Pymol as cartoon, pro Pymol as stick, upg Pymol orient, upg Pymol isomesh upg-d, 2fofc, 2.0, upg, carve=1.5 Pymol set stick_radius, 0.2 Pymol set mesh_radius, 0.01 Pymol isomesh name, map, level ]]] load pdb file:pdb1lza # Load in a PDB file (lysozyme) util.cbaw #Set normal CPK colours and render as sticks so we cansee the coordinates through the mesh show sticks, pdb1lza setnormalize_ccp4_maps, 1 # Load in the electrondensity map (CCP4 format) load 1lza.ccp4 #This was obtained fromthe Uppsala Electron Density serverhttp://fsrv1.bmc.uu.se/eds/ #First we make sure that map normalisation is turned on- this means that we can contour at sigma levels (ratherthan absolute values) isomesh mesh,1lza.ccp4, 2.0 # Contour the map at 2.0 sigma across the wholecell color green, mesh select res,////87 # Select one residue -ASP 87 isosurface surf,1lza, 1, res, carve=2 # Createan isosurface at 1.0 sigma, just in the vicinity ofthis residue #(onlyin a region with 2 angstrom of the selected residue) set transparency,0.5 #Make the isosurface semitransparent move z, -20 #Zoom out a bit so we can see it better Movie: Load the file 1L0T_sidechains mset 1 x120 #Reserve space for 120 frames setray_trace_frames, 0 # Make sure thatray-tracing is turned off for movie generation-otherwise, this would take a LONG time util.mroll(1,120,1) #Use a built in utility function to generate a full 360-degree rotation roundthe y-axis, over 120 frames mplay #Play the movie
个人分类: 科研笔记|11397 次阅读|0 个评论
借助于pymol计算NMR中蛋白的rmsd
autodataming 2013-10-8 21:33
背景: NMR中有蛋白的多个状态,找出其中差异较大的蛋白。 有两种方法; 方法一:NMRCLUST 聚类 方法二: 首先求一个平均结构,然后计算20个构象与这个平均结构的RMSD 再取最接近平均结构的一个构象a 1wym_right_Number_0009 2.509 同时取与平均结构的rmsd最大的构象b 1wym_right_Number_0013 6.205 最后取与b的rmsd差异最大的c 1wym_right_Number_0005 9.535 我现在通过meanNMR.pl得到了平均结构 现在我借助于pymol中的fit命令来计算RMSD值 NMRrmsd.py =============================== #!/usr/bin/python #author: Chen Zhaoqiang #email: 744891290@qq.com import sys import os import re print please change the dir to the dir storing NMR pdbs\n; from pymol import cmd parameter= lenofpara= len(parameter) if(lenofpara != 5): print '''usage: NMRrmsd.py -out e:/result.txt''' path='e:/yyq/receptor/20pdbs'; #sys.exit() #outfile=sys.argv cmd.delete('all') nmrfile= #cmdline2='rms mean, '+fil #cmdline3='rms_cur mean, '+fil # print cmdline cmd.do(cmdline) #cmd.do(cmdline2) #cmd.do(cmdline3) cmd.delete('all') #notice :the result of rms and fit is the same, #rms_cur:in the nmr,maybe the result is same, #if translation a position of a protein,the rms_cur will change #Rms_Cur computes the RMS difference between two atom selections without performing any fitting =================== rmsd进行排序pymolrmsd.pl ==== #!/usr/bin/perl -w use strict; open FH,E:/yyq/selecrmsd.txt; my %hash; my ($name,$rmsd); while(FH) { if($_=~/PyMOLfit \S+, (\S+)/) { $name=$1; print $name } elsif($_=~/ Executive: RMS = (\S+)/) { $rmsd=$1; print $rmsd\n; {no strict; no warnings; # print $name, $rmsd \n; $hash{$name}=$rmsd; } } } foreach my $key (sort { $hash{$a} = $hash{$b} } keys %hash) { printf(%s\t%s\n,$key, $hash{$key}); } ============
个人分类: DrugDesign|5364 次阅读|0 个评论
Pymol 选择指定范围内的氨基酸
autodataming 2013-9-25 15:14
背景:有些蛋白没有解析出小分子(辅酶),而我们知道小分子在大分子中的位置是保守的。 这时候,我们可以通过叠合(align)操作,来添加小分子辅酶; 这时候通常会出现一些问题,辅酶和一些氨基酸发生碰撞。 你可以通过人眼观察,伤眼。 通过 选择3A 或者 2A 范围内的 氨基酸来确定哪些氨基酸发生碰撞或者距离不合理。 图形化的pymol是不能自由选择指定范围的氨基酸的。 #### 在解析的晶体结构中,我发现3A以内是有氨基酸原子的,确定最小距离2.6A 我就选择3A范围,以及2.5A范围内的氨基酸 操作: 我的辅酶是NAP select 起名字,指定要选的范围(对象) --------------------------------------------------- select NAP3A, resn NAP around 2.6 #选择离NAP2.6A范围内的原子 select NAP3Aress,byres NAP3A #选择离NAP2.6A范围内的氨基酸残基 ------------------------------------------- 要想熟练掌握命令行的pymol,我们要理解命令的意思 by====beyond 补充: Pymol 图形化操作只能选择配体4A,5A,6A等范围内的氨基酸,操作简单,但灵活性差。 around 4A 和expand 4A 的区别 around 原子的中心到目标中原子的中心的最短距离4A即可 expand考虑的原子的半径,原子表面到目标中原子的中心的最短距离4A即可 差别不是很大
个人分类: DrugDesign|28392 次阅读|0 个评论
利用PyMOL制作反应势能面示意动画
热度 1 Jerkwin 2013-4-18 23:50
2013-04-18 10:43:35 发布图片 2013-11-14 21:18:18 增加教程 2016-09-07 20:17:18 颜色映射 利用PyMOL内置的OpenGL制作了势能面反应的示意图, 具体制作过程容后再讲. PyMOL是基于Python的分子可视化软件, 在结构生物学中使用十分广泛. 它的主要特色是对生物大分子显示效果好, 并自带一个高效的光线追踪渲染器, 能渲染出逼真的效果. 此外, PyMOL还支持脚本, 可用于精确控制显示, 并提供了一个基本的OpenGL的接口, 以便用户进行一些简单的三维动画设计. 三维建模软件有很多, 不同的软件适用于不同的领域. 最基础的如OpenGL之类, 需要你利用最基本的图元和场景选项一点一点地构建出整个场景. POV-Ray之类则侧重于光线追踪渲染, 并集成了许多可用的模型与场景, 更高级一些. Blender之类则是更通用更专业的三维建模软件, 并非专用于分子建模与可视化. 这样看起来, PyMOL算是处于OpenGL和Blender中间, 集成了POV-Ray的部分功能, 专门用于分子可视化的. 建模时它可以实时可视化, 调试很分方便, 因此对于一些简单的应用很合适. PyMOL中, 三维模型被称作CGO(Compiled Graphics Objects), 可在其中引用一些OpenGL基本图元. 使用方法和OpenGL很类似, 但由于调用是基于Python的, 所以比直接使用OpenGL简单一些. 下面说说上面两个动画的制作方法. 首先我们需要一个二维势能面的模型. 这个模型最好能够具有一般势能面的特点, 并且包含各类驻点, 如极大点, 极小点, 鞍点. 这就要求势能面上至少有两个极大点. 经过比较, 我发现二元函数 F ( x , y ) = sin x x + sin y y F(x,y)=sinxx+sinyy 满足要求. 但此函数为周期函数, 所以最好加上一个线性项去掉周期性, 并适当调整大小. 最终我用的函数是 span class="MathJax" id="MathJax-Element-2-Frame" tabindex="0" data-mathml="math xmlns=http://www.w3.org/1998/Math/MathMLFmo stretchy=false(x,ymo stretchy=false)=4mo stretchy=false(mrow class=MJX-TeXAtom-ORDsin#x2061;xx+mrow class=MJX-TeXAtom-ORDsin#x2061;yymo stretchy=false)+0.1x" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;" F ( x , y ) = 4 ( sin x x + sin y y ) + 0.1 x F(x,y)=4(sinxx+sinyy)+0.1x . 确定了势能函数的解析式就可以创建势能曲面了. 方法是最基本的剖分, 用三角面片对整个区间进行剖分, 再将剖分所得的三角面片组合起来. 值得注意的是剖分的方向和三角面片的法向. 至于曲面上球体运动的模拟, 可利用简单的线性步长方法. 若需要更加真实的效果, 则可利用分子动力学中的Verlet积分方法进行计算. 使用方法 运行代码: run PESdemo.py 背景设为白色: bg white 设定光线追踪: set ray_trace_frames=1 输出png图片: mpng PESdemo 渲染好的图片将输出为PESdemoXXXX.png, XXXX为编号. 利用这些图片就可以制作成动画. 支持动画的图片格式目前主要两种: gif 最常用的, 大家也最熟悉. 各种软件支持最好, 算是通用格式. 可惜只有256色, 失真有时很严重, 特别是对光线追踪渲染过的图片. apng 基于png的动画图片, 效果等同于png. 可惜目前浏览器支持不广, 尚未得到png官方承认. 下面两个图就是这两种格式的对比 更具体的信息可参考下面的网文: 小牛犊APNG力挫老古董MNG APNG编辑制作工具 如果你要使用其他颜色映射方案的话, 可参考我的另一篇博文 几种颜色映射方案的解析式 . 代码 PESdemo.py 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 # coding: utf-8 # ############################################################################## # 2013-11-14 10:25:11 简单示例 # 2016-09-07 20:23:18 注释, 颜色映射 # ############################################################################## import math from pymol import cmd from pymol.cgo import * # 势能面函数 def Fxy (x,y): if x ==0 : Fx = 4 else : Fx = 4* math . sin(x) / x +.1* x if y ==0 : Fy = 4 else : Fy = 4* math . sin(y) / y return Fx + Fy # 势能面函数法向 def dFxy (x,y): if x ==0 : dFx = 0 else : dFx = 4* (x * math . cos(x) - math . sin(x)) / x **2+0.1 if y ==0 : dFy = 0 else : dFy = 4* (y * math . cos(y) - math . sin(y)) / y **2 Rtmp = 1/ math . sqrt(dFx * dFx + dFy * dFy +1 ) return - dFx * Rtmp, - dFy * Rtmp, Rtmp def RGB (V, Vmin, Vmax): dV = Vmax - Vmin; x = (V - Vmin) / dV r =1 ; g =1 ; b =1 if x 0.25 : r = 0 ; g = 4* x elif x 0.50 : r = 0 ; b = 2-4* x elif x 0.75 : r = 4* x -2 ; b = 0 else : g = 4-4* x; b = 0 r = min ( max (r, 0 ), 1 ) g = min ( max (g, 0 ) , 1 ) b = min ( max (b, 0 ) , 1 ) return r, g, b # 是否使用法向, 显示网格, 颜色映射, 使用Verlet方法计算轨迹 YesNorm =1 ; YesGrid =1 ; YesMap =0 ; YesTrj =1 Xini = 4.5 # 小球初始位置 Xmin = -7 ; Xmax = 5.5 ; dX = .5 ; Nx = int ((Xmax - Xmin) / dX) Ymin = -7 ; Ymax = 7 ; dY = .5 ; Ny = int ((Ymax - Ymin) / dY) X = Y = Z = * Ny for i in range (Nx) ] Zx = * Ny for i in range (Nx) ] Zy = * Ny for i in range (Nx) ] Zz = * Ny for i in range (Nx) ] for i in range (Nx): X = Xmin + dX * i for j in range (Ny): Y = Ymin + dY * j for i in range (Nx): x = X for j in range (Ny): y = Y Z = Fxy(x,y) if YesNorm: Zx , Zy , Zz = dFxy(x,y) # 获取极值, 用于颜色映射 Zmin = min ( min (Z)); Zmax = max ( max (Z)) PES = ) for i in range (Nx): PES . extend( ) for j in range ( 0 ,Ny): PES . extend( , Zy , Zz ] ) PES . extend( , Y , Z ] ) PES . append( END ) for j in range (Ny): PES . extend( ) for i in range (Nx): PES . extend( , Zy , Zz ] ) PES . extend( , Y , Z ] ) PES . append( END ) # 绘制表面 PES . extend( ) for j in range (Ny -1 ): PES . extend( ) for i in range (Nx): if YesMap: r, g, b = RGB(Z , Zmin, Zmax) PES . extend( ) PES . extend( , Zy , Zz ] ) PES . extend( , Y , Z ] ) if YesMap: r, g, b = RGB(Z , Zmin, Zmax) PES . extend( ) PES . extend( , Zy , Zz ] ) PES . extend( , Y , Z ] ) PES . append( END ) # 绘制路径 PES . extend( ) PES . extend( ) PES . extend( ) x = - Xini; y = - Xini while y = Xini: z = Fxy(x,y) dFx, dFy, dFz = dFxy(x,y) PES . extend( ) PES . extend( ) y = y +0.1 PES . append( END ) PES . extend( ) PES . extend( ) x = - Xini; y = - Xini while x = Xini: z = Fxy(x,y) dFx, dFy, dFz = dFxy(x,y) PES . extend( ) PES . extend( ) x = x +0.1 PES . append( END ) # 绘制小球 x = - Xini; y = - Xini; z = Fxy(x,y) PES . extend ( ) PES . extend ( ) x = - Xini; y = Xini; z = Fxy(x,y) PES . extend ( ) PES . extend ( ) x = Xini; y = - Xini; z = Fxy(x,y) PES . extend ( ) PES . extend ( ) cmd . load_cgo(PES, ' PES ' ) # 模拟小球运行 Rsph = 0.5 if not YesTrj: x = - Xini for Ifrm in range ( 30 ): y = - Xini + Ifrm *0.3 ; z = Fxy(x,y) dFx, dFy, dFz = dFxy(x,y) SYS = SYS . extend( ) cmd . load_cgo(SYS, ' SYS ' , Ifrm) y = - Xini for Ifrm in range ( 30 ): x = - Xini + Ifrm *0.3 ; z = Fxy(x,y) dFx, dFy, dFz = dFxy(x,y) SYS = SYS . extend( ) cmd . load_cgo(SYS, ' SYS ' , Ifrm +30 ) else : # 初始位置和速度 x = - Xini; y =- Xini vx = 3.28 ; vy = 0 ; Nfrm =130 vx = 0 ; vy = 3.15 ; Nfrm =120 dt = 0.05 ; E0 = 0.5* (vx * vx + vy * vy) + Fxy(x,y) dFx0, dFy0, dFz0 = dFxy(x,y) for Ifrm in range (Nfrm): SYS = x = x + (vx + 0.5* dFx0 * dt) * dt; y = y + (vy + 0.5* dFy0 * dt) * dt; z = Fxy(x,y) dFx, dFy, dFz = dFxy(x,y) SYS . extend( ) cmd . load_cgo(SYS, ' SYS ' , Ifrm) vx = vx +0.5* (dFx0 + dFx) * dt vy = vy +0.5* (dFy0 + dFy) * dt E = 0.5* (vx * vx + vy * vy) Rtmp = math . sqrt( 2.* abs (E0 - z) / (vx * vx + vy * vy)) vx = vx * Rtmp; vy = vy * Rtmp dFx0, dFy0 = dFx, dFy cmd . reset() cmd . zoom( ' PES ' , 1.0 ) cmd . clip( ' far ' , -10.0 ) cmd . turn( ' z ' , 30 ) cmd . turn( ' x ' , -60 ) cmd . mplay() ◆本文地址: http://jerkwin.github.io/2013/04/18/利用PyMOL制作反应势能面示意动画/ , 转载请注明◆
个人分类: 数学轮子|11892 次阅读|2 个评论
分子可视化软件之我见
xiaoshijun 2012-9-23 23:18
做了几年的分子模拟,自学了一些分子可视化软件,不能说各个精通,但是比较之后有一点自己的认识。在网上逛的时候,特别是分子模拟论坛上很多初学者很纠结改学那个。其实任何一个想掌握的很精通都是不容易的,但是当你对每个软件有了一些认识以后,每个软件都差不多,不过就是达到一个目的所付出的工作量不同罢了。我把自己使用过的可视化软件简单介绍一下,希望对准备入手学习的童鞋一个参考。我主要考虑现在大家讨论比较多的pymol,vmd,chimera,rasmal和Jmol。 我用的比较多的是pymol和 vmd,我想经常使用可视化软件的人的选 择都差不多。 rosetta分子模拟博客上的一个对常用的可视化软件的投票,全世界的科学家最常使用的前三名软件 是 :PyMOL (37%),VMD (19%),Chimera (12%)。可见世界范围来讲,pymol确实是最受欢迎的,一个是因为它能非常容易的做出很炫的蛋白质图片,二个是它是python based。如果你对python比较熟悉,使用pymol会是你的不二选择,在pymol wiki中还有众多的 由世界上的科学家们贡献的 scripts,也大大方便了做图。 相对于pymol, vmd最大的优势就是简单和灵活。如果你没有任何分子建模的经验,建议从vmd入手,至少可视化的操作和友好的界面不会打击你建模的耐心。想vmd中导入轨迹和显示不同的结构也是相当的方便,但是相对于pymol,vmd的一个致命伤是输出。虽然vmd的主页上有很多超炫的图,但是想要做到那样的图光靠技术就不行了,还必需要有点艺术细胞了。哈哈,还好vmd可以用provay渲染输出,可以弥补一下vmd的缺陷。如果你学过tcl,可能用vmd会更舒服一些,至少很多强大的可视化目标都可以在vmd的tcl console中实现。vmd里面也可以装一下轨迹分析的插件,特别是跟NAMD的衔接,使得很多童鞋会更倾向于VMD。 再说说chimera,必须说明我用的不多。每次想到要快速而简单的加氢原子和优化模型的时候,我马上想到的就是chimera了,比起gromacs中的EM要快速了很多。chimera里面有实现预定好的图片模式,所以有时只需拖拖点点就可以得到一个不错的视觉效果。我周围做的分子对接和药物设计的人使用的较多。 最后是rasmal和Jmol了。rasmal刚开始学模拟的时候用过,这个软件的优点就是简单,功能相对简单,操作也简单。我多用来快速观察分子的构想,比vmd和pymol可以节省大概20秒的等待时间,哈哈。Jmol多用在网络上显示分子模型的结构,想必大家都用过,RCSB PDB数据库就有View in Jmol的选项。最近在做一个关于无机物矿石的模拟,网上的一些矿石的数据库里面的结构都是用Jmol来显示的,所以也有用过。这个就技术上讲要容易许多。 说了这么多,不是想告诉你应该用哪个,不应该用哪个。关键看自己的课题和目的,一般初学建议VMD,报告和文章用图用PYMOL,基本上就满足需要了。但是想把二个都学的很精通,就不是那么容易了。网上牛人巨多,希望大家能相互学习!! 中科院数据处理与统计
个人分类: 分子可视化|15137 次阅读|0 个评论
Autodock Vina Pymol windows插件发布!
caixin5120 2012-7-17 14:08
Autodock Vina Pymol windows插件发布!
Pymol 的Windows Autodock Vina 插件发布! 作者-Goetz Parsiegla “We useAutodock Vinawith theAutodock Vina plugin for PyMOL written by Daniel Seeligerto perform docking of various lipids and inhibitors to crystal structures of Lipases. Docking results are compared with experimental biochemical in vitro activity measurements of the enzymes using automatic titration techniques in our Laboratory (Results will be published soon). We use Autodock Vina instead of Autodock because of its faster search algorithm and the parallel execution of the code on multi core processors (for a comparison seeOlegs Trotts page at Scripps). ThePyMOLplugin permits to easily setup and execute an Autodock Vina run, and display the results in the Pymol graphical windows for their interpretation. We adapted the original code of the plugin, which was developed to be used in a Linux environment to function flawlessly under Windows XP,Vistaor Windows 7 (32 and 64 bits).” Autodock Vina Pymol Windows插件下载地址 : http://eipl.cnrs-mrs.fr/bioinformatic.php Autodock Vina Pymol Linux插件下载地址 : http://wwwuser.gwdg.de/~dseelig/adplugin 欢迎对分子模拟和药物设计有兴趣的朋友加入 Autodock QQ群:68093966
个人分类: Pymol|9970 次阅读|0 个评论
Windows用户在Pymol里面利用一个字母标记氨基酸残基
热度 1 daishx08 2012-3-25 20:55
windows下不能建立.pymolrc文件,认可的文件名是:'pymolrc', 'pymolrc.py' or 'pymolrc.pym' 从本博文下载附件( pymolrc )后拷贝到安装目录即可,无需后缀名。 pymolrc文件里起作用的是这一段 # start $HOME/.pymolrc modification single ={'VAL':'V', 'ILE':'I', 'LEU':'L', 'GLU':'E', 'GLN':'Q', \ 'ASP':'D', 'ASN':'N', 'HIS':'H', 'TRP':'W', 'PHE':'F', 'TYR':'Y', \ 'ARG':'R', 'LYS':'K', 'SER':'S', 'THR':'T', 'MET':'M', 'ALA':'A', \ 'GLY':'G', 'PRO':'P', 'CYS':'C'} # end modification 使用时用single 代替resn即可,例如 1.标记第77号残基,标出残基号和残基名: PyMOLlabel resi 77 and name ca, ("%s/%s") % (resn, resi) ##("%s/%s"): 设定显示格式。 三字母格式 PyMOLlabel resi 77 and name ca, ("%s/%s") % (single , resi) ##("%s/%s"): 设定显示格式。 单字母格式 参考: http://www.mdbbs.org/viewthread.php?tid=34379 推荐关于pymol使用的很好的网站 http://www.donkeyhome.org/protein/
个人分类: 生活点滴|15647 次阅读|3 个评论
[转载]PyMOL 基本使用
aaa0 2011-1-11 11:41
上午听叶博讲课,主要是讲PyMOL软件的使用,以前也用过该软件看一些蛋白的结构,却只是当作一个viewer来用。正好趁此机会恶补一下。 http://pymol.sourceforge.net/ Pymol=python+molecule,据说python是一个比较牛的计算机语言,由作者喜欢的一个马戏团的名字而来,所以用这种语言来编辑处理分子构相,就是PyMOL了。据实验室作结构的人说,真正搞结构的是不会用PyMOL的,呵呵,反正我的要求也很低,能够了解一点相关的功能就很知足了。 基本命令(也可使用鼠标操作,但个人认为太繁琐,不如命令来得简单) pwd# show current directory dir# list file in the current directory cd directory #change directory load xxx#注意要打上扩展名,例如1LMK.pdb,否则会error creat name, (selection) #name=object to creat, selection=atom to include in the new object, 非常实用的功能 Manipulating object: show representation, (selection) hide representation, (selection) #the available representations are: (前面是个人比较常用的) lines, spheres, ribbon, cartoon, sticks, surface, /// mesh, dots, labels, extent Turn an object on and off:(这个直接用鼠标就ok了) enable/disable, object-name #turn on/off all representation Basic atom selections: name atom names缩写 n. 例子:show cartoon, (n. 1LDK/) resnresidue typesr. resiresidue numberi. chainchain ID c. elemelement symbole. Selection algebra: 就是怎么选择 交集是and、,例如 1LDK and chain A and i. 1-103 并集是or/|,补集是not/! Change your point of view: zoom, (selection)#fit the selection to screen orient, (selection)#align molecular axis center, (selection) # size not changed turn axis, angle #rotate camera move axis, distance#translate camera Align (个人认为最重要的功能): align (source), (target) #the source object will be moved and rotated to fit the target object 例如: align (prot1 and chain A), (prot2 and chain B) 在align的过程中会产生一个root mean square deviation (RMSD),这个值可在一定程度上衡量alignment的效果。 Set control (可以通过这个命令来调整所有参数的值,可惜没有什么详细的介绍) 例如 set sphere_scale, 0.5, (n. Fe) #decrease Fe atom size to 0.5 set bg_rgb, #set background as white set ribbon_sampling, 1 Measurement (又一个十分重要的功能,可以真正挖掘结构的意义) dist #测量两个原子之间的距离,ctrl+右键选择第一个原子,ctrl+中键选择第二个原子,然后测量dist。 angel # 测三个原子之间的夹角,ctrl+中键选择第三个原子,然后测量angle dihedral #测量四个原子之间的二面角 还有制作Movie的一些技巧,不过对于我来说暂时还没什么用。
个人分类: 生活点滴|5126 次阅读|0 个评论
pymol 知道多少?pymol技巧汇总(内附PDF手册)
albumns 2009-12-17 03:12
pymol官方PDF手册 基本命令 (也可使用鼠标操作,但不如命令来得简单) pwd # show current directory dir # list file in the current directory cd directory #change directory load xxx # 注意要打上扩展名,例如 1LMK.pdb ,否则会 errorc reat name, (selection) #name=object to creat, selection=atom to include in the new object, 非常实用的功能 Manipulating object: show representation, (selection) hide representation, (selection) #the available representations are: ( 前面是个人比较常用的 )lines, spheres, ribbon, cartoon, sticks, surface, /// mesh, dots, labels, extent 例如: stick mol1 resi 100 # mol1 为显示在 pymol 右边的分子名称 Turn an object on and off:( 这个直接用鼠标就 ok 了 ) enable/disable, object-name #turn on/off all representation Basic atom selections: name atom names 缩写 n. 例子: show cartoon, (n. 1LDK/) resnresidue types r. resiresidue number i. chainchain ID c. elemelement symbol e. Selection algebra: 就是怎么选择 交集是 and 、 ,例如 1LDK and chain A and i. 1-103 并集是 or/| ,补集是 not/! Change your point of view: zoom, (selection) #fit the selection to screen orient, (selection) #align molecular axisc enter, (selection) # size not changed turn axis, angle #rotate camera move axis, distance #translate camera Align ( 个人认为最重要的功能 ) : align (source), (target) #the source object will be moved and rotated to fit the target object 例如: align (prot1 and chain A), (prot2 and chain B) 按整条链叠合 align mol1 resi N1, mol2 resi N2 按某一个残基叠合 align mol1 resi N1-N2 name n+ca+c+o , mol2 resi N3-N4 name n+ca+c+o 按某段残基的主链进行叠合 在 align 的过程中会产生一个 root mean square deviation (RMSD), 这个值可在一定程度上衡量 alignment 的效果。 Set control ( 可以通过这个命令来调整所有参数的值,可惜没有什么详细的介绍 ) 例如 set sphere_scale, 0.5, (n. Fe) #decrease Fe atom size to 0.5 set bg_rgb, #set background as white set ribbon_sampling, 1 Measurement ( 又一个十分重要的功能,可以真正挖掘结构的意义 ) dist # 测量两个原子之间的距离, ctrl+ 右键选择第一个原子, ctrl+ 中键选择第二个原子,然后测量 dist 。 angel # 测三个原子之间的夹角, ctrl +中键选择第三个原子,然后测量 angle dihedral # 测量四个原子之间的二面角 Launching PyMOL File for startup commands Launching PyMOL from an external program Running PyMOL in batch mode Suppressing PyMOL output Launching Python programs File for startup commands Linux: Whenever PyMol starts, a '.pymolrc' file containing commands is run. All you need to do is create ".pymolrc" and place it in your home directory. Alternatively, you can instead create ".pymolrc.py" which contains actual Python code instead of just PyMOL commands. Windows: On Windows, use 'pymolrc', 'pymolrc.py' or 'pymolrc.pym'. Warren DeLano Launching PyMOL from an external program If PYMOL_PATH, LD_LIBRARY_PATH, and TCL_LIBRARY are correctly defined, then you can launch PyMOL from an external Python program as shown in examples/devel/start_pymol.py . NOTE: This approach is not recommended, since the PyMOL launching process is subject to change without warning. The recommended approach is to just use PyMOL as your python interpreter: pymol -r script.py pymol -qcr script.py Warren DeLano Running PyMOL in batch mode To perform PyMOL commands from stdin (file, pipe) without opening an OpenGL window, try: pymol -qc Suppressing PyMOL output Just type: feedback disable,all,actions feedback disable,all,results -From Python: cmd.feedback("disable","all","actions") cmd.feedback("disable","all","results") Will suppress most of PyMOL's normal chatter. Launching Python programs Running a Python script from PyMOL, usually the command: run script.py Is enough. Of course, the file script.py needs to be in the working directory. For more detailed examples, see the commands to launch Python scripts when starting PyMOL. Asynchronous means, that a new Python thread is started: pymol example.py # synchronous, in PyMOL module pymol -r example.py # synchronous in __main__ module pymol -l example.py # asychronous in a new module You can also launch python programs from within PyMOL with the commands: run example.py # synchronous in pymol module run example.py,main # synchronous in __main__ module spawn example.py # asychronous in a new module spawn example.py,global # asychronous in the PyMOL module spawn example.py,main # asychronous in the __main__ module Displaying biochemical Properties Selecting secondary structures Color by atom type from a script Displaying double bonds Calculating dihedral angles Adding hydrogen bonds Color by B-factor Polar surface area Displaying solvent accessible surface Display C-Alpha trace of proteins Display Phosphate trace of nucleic acids Align proteins with CA fit Selecting secondary structures Examples: select helix, (ss h) select sheet, (ss s) select loop, (ss l+'') Color by atom type from a script The "util" module contains a number of functions that color the atoms according to type, with different colors for the C atoms. For instance, util.cbay three in a .pml script will color object "three" by atom type, with the carbon atoms in yellow ("color by atom yellow"). Other functions from ../modules/pymol/util.py are cbag, cbac, cbas, cbap, cbak, cbaw and cbab (grey (carbon), cyan, salmon, purple, pink, white (hydrogen) and slate). Lieven Buts Displaying double bonds You can try going into lines mode and turning on the valence display: hide show lines set valence, 0.1 a higher value for valence spreads things out more. I don't know of a way to get the dotted notation. Michael George Lerner Calculating dihedral angles The get_dihedral function requires four single-atom selections to work: get_dihedral prot1///9/C, prot1///10/N, prot1///10/CA, prot1///10/C Adding hydrogen bonds Regarding H-bonds. There isn't a built-in function yet, but you can show H-bonds between two objects using atom selections so long as hydrogens are present in both molecules. If you don't have hydrogens, you can use h_add on the proteins or provide ligands with valence information and then use h_add. Two examples are below. For clarity, they draw dashes between the heavy atoms and hide the hydrogens. EXAMPLE 1: Show hydrogen bonds between protein and docked ligands EXAMPLE 2: Show hydrogen bonds between two proteins There is also a script drawing nice hydrogen bonds from Gareth Stockwell Warren DeLano Assign color by B-factor Robert Campbell has a color_b.py python script on his PyMOL web page that you can use. it has a number of options including the selection and two types of colouring schemes (rainbow versus a blue-magenta-red gradient) and two types of binning of the colours (equal number of atoms in each colour or equal spacing of colours along the B-factor range). See http://biophysics.med.jhmi.edu/rlc/work/pymol to download. There is a script 'data2bfacor' to display arbitrary data assigned to atoms as well. Robert L. Campbell Polar surface area For a solvent accessible PSA approximation: set dot_density, 3 remove hydro remove solvent show dots set dot_solvent, on get_area elem N+O get_area elem C+S get_area all For molecular PSA approximation set dot_density, 3 remove hydro remove solvent set dot_solvent, off get_area elem N+O get_area elem C+S get_area all Showing dots isn't mandatory, but it's a good idea to confirm that you're getting the value for the atom dot surface you think you're using. Please realize that the resulting numbers are only approximate, reflecting the sum of partial surface areas for all the dots you see. To increase accuracy, set dot_density to 4, but be prepared to wait... Warren DeLano Display solvent accessible surface Using the surface display mode, PyMOL doesn't show the solvent accessible surface, rather it shows the solvent/protein contact surface. The solvent accessible surface area is usually defined as the surface traced out by the center of a water sphere, having a radius of about 1.4 angstroms, rolled over the protein atoms. The contact surface is the surface traced out by the vdw surfaces of the water atoms when in contact with the protein. PyMOL can only show solvent accessible surfaces using the dot or sphere representations: for dots: show dots set dot_mode,1 set dot_density,3 for spheres: alter all,vdw=vdw+1.4 show spheres Kaushik Raha Displaying the C-Alpha trace of proteins hide show ribbon set ribbon_sampling,1 And if your model only contains CA atoms, you'll also need to issue: set ribbon_trace,1 Warren DeLano Displaying the Phosphate backbone of nucleic acids Should you ever want to show the phosphate trace of a nucleic acid molecule: def p_trace(selection="(all)"): s = str(selection) cmd.hide('lines',"("+s+")") cmd.hide('spheres',"("+s+")") cmd.hide('sticks',"("+s+")") cmd.hide('ribbon',"("+s+")") cmd.show('cartoon',"("+s+")") cmd.set('cartoon_sampling',1,"("+s+")") cmd.set('cartoon_tube_radius',0.5,"("+s+")") cmd.extend('p_trace',p_trace) and then: p_trace (selection) Luca Jovine Align proteins with CA fit If the proteins have significant homology, then you can use the align command: align prot1////ca,prot2 which will perform a sequence alignment of prot1 against prot2, and then an optimizing fit using the CA positions. I'm not sure if the help text for align got into 0.82, but the next version will definitely have it. Coloring molecules Coloring secondary structures Color by atom type from a script CMYK-safe Colors Color by B-factor Creating a Color bar Coloring insides and outsides of helices differently Coloring all objects differently List the color of atoms Coloring secondary structures Examples: color red, ss h color yellow, ss s color green, ss l+'' When "the colour bleeds from the ends of helices and sheets into loops," try setting cartoon_discrete_colors to 'on' (or 1). set cartoon_discrete_colors, 1 or from the the "Cartoon" menu of the external GUI find "Discrete Colors" as the last item in the menu. Robert Campbell Color by atom type from a script The "util" module contains a number of functions that color the atoms according to type, with different colors for the C atoms. For instance, util.cbay three in a .pml script will color object "three" by atom type, with the carbon atoms in yellow ("color by atom yellow"). Other functions from ../modules/pymol/util.py are cbag, cbac, cbas, cbap, cbak, cbaw and cbab (grey (carbon), cyan, salmon, purple, pink, white (hydrogen) and slate). Lieven Buts Use CMYK-safe Colors Some RGB triplets do have equivalents in CMYK space, and as a result, a figure that looks great on a screen can come out with unpredictable colors when printed. Most applications do a good job with RGB-to-CMYK conversions for photos, but do not do such a good job with graphics that use pure primary colors. For example, reds are generally OK, but pure blues and greens do not translate very well. Here are some RGB values that are within the CMYK gamut (i.e. are "CMYK-safe"). In general, colors in PyMOL can be assigned manually: set_color green= Note that there are default atom colors such as "carbon", "nitrogen", "oxygen", "hydrogen", "sulfur", etc. which should also be redefined: set_color carbon= Here's still another URL. Although the list of colors is not extensive, you can see colors: CMYK-safe RGB colors Gil Prive, Dave Fahrney and Warren DeLano Assign color by B-factor Robert Campbell has a color_b.py python script on his PyMOL web page that you can use. it has a number of options including the selection and two types of colouring schemes (rainbow versus a blue-magenta-red gradient) and two types of binning of the colours (equal number of atoms in each colour or equal spacing of colours along the B-factor range). See http://biophysics.med.jhmi.edu/rlc/work/pymol to download. There are other scripts there as well. Robert L. Campbell Creating a Color bar To show a vertical/horizontal color bar indiacting the b-factor variation, use the script pseudobar.pml on the structure pseudobar.pdb , or do the following: 1. Create a pdb-file which contains CA positions only, whereas the numbers correspond to your wanted increments of colors. Be sure that CA's are separated by a contant value, say 5 Angstroem. 2. Load this new pseudobar-pdb file into PyMOL, make bonds between increment 1 and increment 2 , define/assign a smooth color for each increment (copy colors definition from automatically created colors made by b-factor script) and show the b-factor bar as lines (or sticks). Bartholomeus Kuettner Coloring insides and outsides of helices differently Q: does anyone know how to color the inside of helices a different color than the outsides? A: set cartoon_highlight_color, red Warren L. DeLano Coloring all objects differently Q: Is there a simple way to colour each object currently loaded, with a different colour? A: There is a script color_obj.py that does the job. The script is also available at http://www.ebi.ac.uk/~gareth/misc USAGE color_obj(rainbow=0) This function colours each object currently in the PyMOL heirarchy with a different colour. Colours used are either the 22 named colours used by PyMOL (in which case the 23rd object, if it exists, gets the same colour as the first), or are the colours of the rainbow Gareth Stockwell List the color of atoms To retrieve the color for a residue as identified in an expression, you can either iterate over a selection from the PyMOL command line iterate all, print color Alternatively, this can be done from a Python script . Rendering molecules Displaying in ball-and-stick mode Adjusting width of cartoons Calculating a partial surface Displaying surface inside a molecule Displaying all states of a multiple model/NMR structure Displaying dashed lines Adjusting size of selection indicators Adjusting ray traced picture size Ray tracing maps Nice PovRay settings Making stereo pairs Meaning of get_view parameters Viewing direction vectors (axes) Ray-traceable text labels CGO label orientation Displaying in ball-and-stick mode Q: I've tried several settings and commands but cannot figure out how to make a simple ball-and-stick representation of a molecule. Can it be done in Pymol? A: Yes, but it is non-obvious: hide lines show sticks show spheres set stick_radius=0.1 set sphere_scale=0.25 You can change the two numbers above to fit preferences. Warren DeLano Adjusting width of cartoon Try varying the following. For strands: cartoon_rect_length cartoon_rect_width For helices: cartoon_oval_length cartoon_oval_width or for "fancy" helices: cartoon_dumbell_length cartoon_dumbell_width cartoon_dumbell_radius (radius of cylinder at edge of helix ribbon) In each case "length" refers to what some might call the width and "width" refers to what some might call the thickness. Robert Campbell Calculating a partial surface There is a, until now, undocumented way to calculate a surface for only a part of an object without creating a new one: flag ignore, not A/49-63/, set delete indicate show surface If the surface was already computed, then you'll also need to issue the command: rebuild Warren DeLano Displaying surface inside a molecule As far as I can tell, setting ambient to zero alone doesn't quite do the job, since some triangles still get lit by the light source. The best combination I can find is: set ambient=0 set direct=0.7 set reflect=0.0 set backface_cull=0 Which gives no shadows and only a few artifacts. As an alternative, you might just consider showing the inside of the surface directly...that will create less visual artifacts, and so long as ambient and direct are sufficiently low, it will look reasonable in "ray". util.ray_shadows("heavy") set two_sided_lighting=1 set backface_cull=0 Warren DeLano Displaying all states of a multiple model/NMR structure Just go to the movies menue and click 'show all states'. Jules Jacobsen Displaying dashed lines between two atoms I think the following commands will do what you want: select a, ///A/501/02 select b, ///B/229/N distance d, a, b This will give you a dashed line object d which is labelled with the distance between the two atoms 'a' and 'b' - you can get rid of the label using hide labels, d btw, if you want to ray-trace the image, I find the dashes come out a bit fat - so I tend to use set dash_gap, 0.5 set dash_radius, 0.1 before the 'ray' command. Gareth Stockwell · Adjusting size of selection indicators Adjusting size of selection indicators Try: set selection_width, 6 set selection_width, 7 Warren L. DeLano Adjusting ray trace-image size The pymol ray tracer can generate an image of any size. ray height,width Example: ray 3000,2400 png filename.png For more options, try 'help ray' Evan Stein and Ben Cornett Ray tracing maps For better quality maps with a white background. set ray_trace_fog,0 set ray_shadows,0 set antialias,1 ray 1600,1200 png img.png (it will take quite a while...) Then open img.png using an external image viewer. It should be high enough resolution to print nicely. Warren DeLano Nive PovRay settings I typically use the make_pov.py script and "run" it from pymol once to load the function, and then I do "make_pov('povray.inp')" to create the povray.inp file. Then I edit that file to insert some lines like: fog { distance 10 fog_type 2 fog_alt 10. fog_offset -160. up 0.,1.,.4 colour rgbt1.0, 1.0, 1.0, 0.1 turbulence 0.8 } In this case I'm not really doing depth-cueing but adding fog at the lower background edge (there were two planes defining the background and a surface below the molecule) rising up towards the front upper edge of the scene. "fog_type 2" means a "rising fog" along the "up" vector. fog_type 1 is a constant fog. To get pure depth cueing, you would want "up" to be along the 0., 0., 1. vector (I think!). You'll need to play around with the distance and fog_offset parameters. You wouldn't necessarily want the "turbulence" parameter in there either. Check out "Atmospheric Effects" in the povray documentation for many more details: http://www.povray.org/documentation/view/201/ Robert Campbell Making stereo pairs Try: ray angle=-3 png image1.png ray angle=3 png image2.png This is superior to using the "turn" command because it also rotates the light source. That way shadows will look right. To make even more beautiful stereo images, use a program like Illustrator or Canvas to add the stereo/depth cued labels. This is a little tricky to describe, but I'll give it my best shot. Place the two images side by side with their centers separated by 6.0 - 6.5 cm, and aligned horizontally. Now add all your labels on the LEFT figure. select all of your labels and duplicate them. Move the duplicated labels to the RIGHT side. For clarity sake let's assume we have 3 labels on the LEFT side (a,b, and c -- we will call then aL and aR for the left and right labels, respectively). Place aL near a recognizable feature of the LEFT figure that you are trying to label. Now horizontilly align aR with aL. Now using only the L/R arrow keys move the aR label until the identical portion of the actual label (let's say the lower right hand tip of the 'a') is vertically aligned with the identical portion of your model (let's say where the C alpha-C beta bond leaves the ribbon backbone) on both the LEFT and RIGHT images. Repeat these steps for each pair of labels. This is a nice method for adding stereo labels because it does not require looking at your computer screen in wall-eyed stereo for 2 hours in order to get proper placement of labels. By assuring that the labels are positioned in the LEFT and RIGHT images at positions that are identical with respect to the part of the model that is being labeled you automatically are also placing them so they are at the proper depth when the figure is finally viewed in stereo. Scott Classen and Warren DeLano Meaning of the get_view output Of the 18 numbers in the output array, 0-8 is the 3x3 rotation matrix, 9-11 is the camera location, 12-14 is the origin of rotation, 15-16 are the clipping distances, and 17 is the orthoscopic flag. Robert Campbell, Paolo Martel and Warren Viewing direction vectors Create a python script (I call it axes.py ): # axes.py from pymol.cgo import * from pymol import cmd from pymol.vfont import plain # create the axes object, draw axes with cylinders coloured red, green, #blue for X, Y and Z obj = # add labels to axes object (requires pymol version 0.8 or greater, I # believe cyl_text(obj,plain, ,'Origin',0.20,axes= , , ]) cyl_text(obj,plain, ,'X',0.20,axes= , , ]) cyl_text(obj,plain, ,'Y',0.20,axes= , , ]) cyl_text(obj,plain, ,'Z',0.20,axes= , , ]) # then we load it into PyMOL cmd.load_cgo(obj,'axes') Then you just need to do "run axes.py" from the pymol command line. You can modify the "3" in the above description of the text labels to change the size of the labels. If you are running a version of pymol older the 0.8, then you cannot add the text (that's why I included colour coding of the axes). You can also use just lines instead of cylinders if you wish: obj = would work as well to define the axes object. Ray-traceable labels You can use the cgo text (line or cylinder versions) as I mentioned in my reply about drawing the xyz axes, but be warned that the labels rotate with your molecule, so getting them oriented perpendicular to the view may be a pain (unless there is something I've missed). Warren's example from a previous reply of his ( cgotext.py ): # draw text using cgo from pymol import cmd from pymol.cgo import * from pymol.vfont import plain cgo = , , ] pos = wire_text(cgo,plain,pos,'Hello World',axes) pos = cyl_text(cgo,plain,pos,'Hello Universe',0.10,axes=axes) cmd.set("cgo_line_radius",0.03) cmd.load_cgo(cgo,'txt') cmd.zoom("all",2.0) Robert Campbell CGO label orientation You could use the cmd.rotate and cmd.translate to position the labels, but it is likely to be somewhat painful. If I'm not mistaken, the rotation will always be about and axis through the origin and so you may need to translate the label into the correct position. Thus if you have your label in an object called 'text', you could do, cmd.rotate(axis='x',angle=20.,object='text') and repeat this with different angles, until you get the orientation correct. Then use: cmd.translate(vector=' ',object='text') (using the appropriate vector, of course!) to position the label. Not ideal, but if it is sufficiently important, it can be done! Modeling with PyMOL Saving transformed coordinates Translate/Rotate objects Moving one segment relative to the rest Split states to objects Altering secondary structures Altering van der Waals radii Altering atom coordinates Deleting bonds Converting D- to L- amino acids Adding disulfide bonds Adding hydrogen bonds Protonating ligands Superposition of two molecules Saving with transformed coordinates Here is a simple script that saves the molecule with coordinates from the current orientation. (invoke it with 'run save_transformed.py' and type the new save_transformed.py command thereafter). Paulo Martel Translate or rotate individual objects There is a "translate" function similar to "rotate", the docs for these don't exist yet, because the implementation isn't finished. However, feel free to use them in the following forms: translate vector,object-name,state (vector needs to be something like ) translate ,pept rotate axis,angle,object-name,state (axis can be either the letter x,y,z or a 3D vector ) rotate x,90,pept rotate ,10,pept Warren DeLano Moving one segment relative to the rest This means moving two parts of one object into different directions. The easiest way to do this is to split the objects and then use the rotate command. EXAMPLE: split.pml Warren DeLano Split states to objects There is also a new command in the 0.95 series: split_states object-name which will spread a PDB "biological unit" (or any multi-state object -- including SD files) over a series of independent objects. This makes it possible to interact with such objects more naturally than with "all_states = 1". Warren DeLano Altering secondary structures: Examples: alter A/10:34/, ss='H' alter A/35:40/, ss='L' alter A/41:60/, ss='S' Altering van der Waals radii Example: alter (elem Fe),vdw=1.8 rebuild (The value for Fe is wrecked in PyMOL at the moment, so running the above line might be a good idea). Warren DeLano Altering atom coordinates Example: alter_state 1,(pdb1cse),x=x-10.0 The latter section can contain formulae involving at least the xyz coordinates, lots of constants and the (+-*/) operators. Deleting bonds Select the bond using Ctrl-right-click, then either unbond pk1,pk2 or hit Ctrl-D. Warren DeLano Converting D- to L- amino acids The inversion function was changed in version 0.95 to take advantage of multiple picked atoms. To invert a center, Ctrl-middle-click to pick the center atom as pk1 and two stationary atoms as pk2 and pk3. Then type Ctrl-E to invert. Warren DeLano Adding disulfide bonds You can use the "bond" command to attach them: bond 24/sg,26/sg bond 56/sg,99/sg unpick (unpick will hide the bond baton which gets displayed.) Additionally, the residue names can be changed for bonded cysteines: alter cys/,name='CYX' or for specific residues alter 24+26+56+99/,name='CYX' Warren DeLano Adding hydrogen bonds Regarding H-bonds. There isn't a built-in function yet, but you can show H-bonds between two objects using atom selections so long as hydrogens are present in both molecules. If you don't have hydrogens, you can use h_add on the proteins or provide ligands with valence information and then use h_add. Two examples are below. For clarity, they draw dashes between the heavy atoms and hide the hydrogens. EXAMPLE 1: Show hydrogen bonds between protein and docked ligands EXAMPLE 2: Show hydrogen bonds between two proteins There is also a script drawing nice hydrogen bonds from Gareth Stockwell Warren DeLano Protonating ligands If your ligands come in with valid valencies and formal charges, PyMOL's h_add command can protonate ligands. (NOTE that there is a minor technical hiccup with SD-files which are loaded by default as immutable "discrete" objects.) Suffice it to say that in order to make changes to the chemical structure, an object must be loaded with the "discrete" flag set to zero. Unfortunately, much of the molecular editing stuff remains to be documented. Here's an example sequence, but I'm not sure it will help to much...as indicated in the manual, this is immature functionality with some major gaps. Attach in particular is very limited... # show valences set valence=0.05 # load cysteine fragment fragment cys # remove hydrogens remove (hydro) # edit gamma S edit cys////sg # add hydrogen attach H,1,1 # add planer, trivalent nitrogen onto C terminus edit cys////C attach N,3,3 # edit that nitrogen edit (elem N and neighbor cys////C) # attach a tetrahedral methyl (note random position) attach C,4,4 # here's an example of adding a whole residue from the library edit cys////N editor.attach_amino_acid("pk1","ace") # now restore missing hydrogens (note that the names are off...) h_add Warren DeLano Superposition of two molecules Using pair_fit requires that you specify a set of paired atoms in each structure. Fortunately, you no longer have to specify each pair separately, so long as the ordering is the same in each selection (almost always true). pair_fit ( trna10 and resid 10:15 and name P ), ( ref4 and resid 10:15 and name P ) Another example: pair_fit prot1///11-26/CA, prot2///34-49/CA would superimpose prot1 on prot2 using C-alphas from residues 11-26 in prot1 and 34-49 in prot2. Movies with PyMOL Encoding video files Encoding video files Assuming you have created a lot of .png files and would like to encode a .mpeg, .avi or other video format, a number of solutions are known: The DiVX encoder using mplayer/mencoder ? There's binaries for Unix and Windows. It makes rather nice compression on a 800x600 (probably higher). It doesn't take too long to produce the nicer quailty movies, but much longer than simply · mencoder "mf://*.png" -mf type=png:fps=18 -ovc lavc -o output.avi · · Another good program for converting images into movies of different formats is VideoMach : http://gromada.com/VideoMach.html · · · · TMPGEnc from http://www.tmpgenc.net/ is very fast, easy to use, and produces very nice ouput (MPEG-2). Unfortunately, it does not handle images larger than 720 x 576 pixels. · · · · The latest Adobe Premiere recipe: · Microsoft's MPEG4 V2, 960x720 @ 30 fps, which PowerPoint automatically · treats as full-screen (due it's wacky metrics). · · Using this codec, a recent 24-second movie consumed only 4.5 MB of space, · but looks much better than a 640x480 Cinepak-based movie with a file size of · around ~40 MB. It definitely pays to use the latest technology · · · · A freeware jiffy to convert png files to an animation is imgcon , · which proved to be very useful: http://www.fmrib.ox.ac.uk/~yongyue/imgcondl.html · · Advanced PyMOL features Meaning of get_view parameters Altering atom coordinates Translate/Rotate objects Moving one segment relative to the rest What is in a selection How does the density wizard work What is molecular sculpting? Align proteins with CA fit Meaning of the get_view output Of the 18 numbers in the output array, 0-8 is the 3x3 rotation matrix, 9-11 is the camera location, 12-14 is the origin of rotation, 15-16 are the clipping distances, and 17 is the orthoscopic flag. Robert Campbell, Paolo Martel and Warren Altering atom coordinates Example: alter_state 1,(pdb1cse),x=x-10.0 The latter section can contain formulae involving at least the xyz coordinates, lots of constants and the (+-*/) operators. Translate or rotate individual objects There is a "translate" function similar to "rotate", the docs for these don't exist yet, because the implementation isn't finished. However, feel free to use them in the following forms: translate vector,object-name,state vector needs to be something like translate ,pept rotate axis,angle,object-name,state axis can be either the letter x,y,z or a 3D vector rotate x,90,pept rotate ,10,pept Warren DeLano Moving one segment relative to the rest This means moving two parts of one object into different directions. The easiest way to do this is to split the objects and then use the rotate command. EXAMPLE: split.pml Warren DeLano What is in a selection? Atom selections aren't directly exposed to Python, but you can have PyMOL build a Python list containing whatever information you need: Using PyMOL commands: list= or using a Python script (in PyMOL): from pymol import cmd,stored stored.list= Warren DeLano How does the Density Wizard work? The answer: · Load a map · Load a model structure · Activate the Density Wizard · Control-middle click to pick any atom in the model to get the map drawn about it. Each of the blue rows in the Wizard is a pop-up menu. You can select multiple or different maps to be displayed at different levels as you traverse the model. Warren DeLano What the heck is molecular sculpting? Molecular sculpting works like a real-time energy minimizer, except that it isn't minimizing the energy. Instead, its just trying to return local atomic geometries (bonds, angles, chirality, planarity) to the configuration the molecules possess when they were first loaded into PyMOL. To actually use this feature: Load a PDB file. Configure the mouse for editing (Mouse menu) or click in the mouse/key matrix box. Select "auto-sculpting" from the Sculpting menu. Select Sculpting from the Wizard menu. Ctrl-middle-click on any atom in your protein to activate sculpting the green part will be free to move the cyan part will be a fixed cushion to provide context the grey part will be excluded. Now perform any conformational editing operation in the green region such as: ctrl-left-click-and-drag on an atom ctrl-right-click on a bond, then ctrl-left-click-and-drag about that bond. You can adjust the radius and cushion using the blue pop-up menus. Right now I'm not sure the sculpting feature is more than entertainment, but my expectation is that it will become part of PyMOL's crystallographic model building system in the future. Warren DeLano Align proteins with CA fit If the proteins have significant homology, then you can use the align command: align prot1////ca,prot2 which will perform a sequence alignment of prot1 against prot2, and then an optimizing fit using the CA positions. I'm not sure if the help text for align got into 0.82, but the next version will definitely have it. Python scripting Launching Python programs Using the PyMOL commandline What is in a selection Does a selection exist Get Coordinates from python Create objects from PDB strings Measure distances from python Coloring all objects differently List the color of atoms List secondary structures Process key events from shell Alter key bindings Viewing direction vectors (axes) Ray-traceable text labels CGO label orientation 3D marks on atoms Save and load objects (pickle) Building ChemPy models Launching Python programs 1. Running a Python script from PyMOL , usually the command: run script.py Is enough. Of course, the file script.py needs to be in the working directory. You can also launch Python scripts when starting PyMOL. Asynchronous means, that a new Python thread is started: pymol example.py # synchronous, in PyMOL module pymol -r example.py # synchronous in __main__ module pymol -l example.py # asychronous in a new module You can also launch python programs from within PyMOL with the commands: run example.py # synchronous in pymol module run example.py,main # synchronous in __main__ module spawn example.py # asychronous in a new module spawn example.py,global # asychronous in the PyMOL module spawn example.py,main # asychronous in the __main__ module 2. Running PyMOL from a Python script requires two commands: import pymol pymol.finish_launching() Using the PyMOL commandline Are you aware that the PyMOL command line is also a Python command line? You can just use PyMOL interactively in that fashion. PyMOLprint 1+1 2 PyMOLfrom random import random PyMOLprint random() 0.739460642143 The only major difference is that the default namespace for PyMOL is "pymol" not "__main__" PyMOLprint __name__ pymol Warren DeLano What is in a selection? Atom selections aren't directly exposed to Python, but you can have PyMOL build a Python list containing whatever information you need: Using PyMOL commands: list= or using a Python script (in PyMOL): from pymol import cmd,stored stored.list= Warren DeLano Does a selection exist? The function below will return true if the selection is defined. from pymol import cmd from types import * def sele_exists(sele): sess = cmd.get_session() for i in sess : if type(i) is ListType: if sele==i : return 1 return 0 Igor Pechersky Get coordinates from Python The actual C-langauge arrays aren't exposed, but there are at least three different ways you can modify coordinates from within Python: · You can get a python object which contains the molecular information, modify the coordinates in that object, load the modified molecule into PyMOL, update the modified coordinates to the original model, and then delete the modified object. ( Example in a python script ) · Another approach is the "alter_state" function, which can perform the same transformation in a single PyMOL command statement: alter_state 1,pept,(x,y)=(-y,x) Likewise sub-selections can be transformed as well: alter_state 1,(pept and name ca),(x,y,z)=(x+5,y,z) · A third approach is to use alter_state with the global "stored" object: Example in a Python script ) Approaches 2 gives the best performance, approach 3 gives more flexibility, and approach 1 gives you a reusable and fully modifiable Python object. Warren DeLano Create objects from PDB strings I thought I'd post this example, just in case anyone else cares about this: delete all cmd.read_pdbstr("""HEADER CREATED BY CONVERTPROSPECT 27-JAN-02 2tnf \ REMARK 1 \ ATOM 1 N PRO A 9 1.895 67.213 -38.182 1.00 0.00 N \ ATOM 2 CA PRO A 9 1.703 68.680 -38.402 1.00 0.00 C \ .... ATOM 1153 C GLY A 157 6.927 59.108 -38.901 1.00 6.00 C \ ATOM 1154 O GLY A 157 6.700 59.292 -37.676 1.00 6.00 O \ TER 1155 GLY A 157 \ MASTER \ END \ ""","2tnfa") hide all show cartoon color grey .... Reece Hart Measure distances from Python Use Python (and the run command with .py files). from pymol import cmd f=open('dist.txt','w') dst=cmd.distance('tmp','mol1///25/ha','mol1///26/ha') f.write("%8.3f\n"%dst) f.close() You could measure the whole protein this way by putting a loop around the distance command: from pymol import cmd f=open('dist.txt','w') atom = cmd.get_model("mol1////ha").atom for i in range(len(atom)-1): sele1 = 'mol1///%s/HA'%atom .resi sele2 = 'mol1///%s/HA'%atom .resi dst=cmd.distance('tmp',sele1,sele2) f.write("%14s %14s %8.3f\n"%(sele1,sele2,dst)) f.close() The output "dist.txt" would then look like: mol1///4/HA mol1///5/HA 4.748 mol1///5/HA mol1///6/HA 4.828 mol1///6/HA mol1///7/HA 4.861 mol1///7/HA mol1///8/HA 4.784 mol1///8/HA mol1///9/HA 4.936 mol1///9/HA mol1///10/HA 4.833 mol1///10/HA mol1///11/HA 4.933 mol1///11/HA mol1///12/HA 4.813 Warren DeLano Coloring all objects differently Q: Is there a simple way to colour each object currently loaded, with a different colour (in the same way that you can colour each chain in a molecule differently)? This would be really useful in visualising a set of superposed structures. A: There is a script color_obj.py that does the job. The script is also available at http://www.ebi.ac.uk/~gareth/misc USAGE color_obj(rainbow=0) This function colours each object currently in the PyMOL heirarchy with a different colour. Colours used are either the 22 named colours used by PyMOL (in which case the 23rd object, if it exists, gets the same colour as the first), or are the colours of the rainbow Gareth Stockwell List the color of atoms To retrieve the color for a residue as identified in an expression, you can either iterate over a selection from the PyMOL command line iterate all, print color Alternatively, this can be done from a Python script . import pymol pymol.color_list = cmd.iterate('all', 'pymol.stored_ss.append(string.ljust(ss,1))') print string.join(pymol.stored_ss) Warren DeLano Process key events from shell The following scripts turns the view 30 deg around the y-axis, each time you press the enter key in the python shell (the original shell you started pymol from), just as an example: #use "spawn spawn_demo.py, local" to invoke this python script from within pymol wait="" i=0 while i 12 and wait!="x": cmd.turn("y", 30) print "Press enter key to continue or x + enter to terminate" wait=raw_input() i=i+1 print "Done" Markus Meier Alter key bindings It's not GUI, but you could simply bind a function key such as F1 to a command: cmd.set_key('F1',lambda :cmd.show('sticks')) Warren DeLano Viewing direction vectors Create a python script (I call it axes.py ): # axes.py from pymol.cgo import * from pymol import cmd from pymol.vfont import plain # create the axes object, draw axes with cylinders coloured red, green, #blue for X, Y and Z obj = # add labels to axes object (requires pymol version 0.8 or greater, I # believe cyl_text(obj,plain, ,'Origin',0.20,axes= , , ]) cyl_text(obj,plain, ,'X',0.20,axes= , , ]) cyl_text(obj,plain, ,'Y',0.20,axes= , , ]) cyl_text(obj,plain, ,'Z',0.20,axes= , , ]) # then we load it into PyMOL cmd.load_cgo(obj,'axes') Then you just need to do "run axes.py" from the pymol command line. You can modify the "3" in the above description of the text labels to change the size of the labels. If you are running a version of pymol older the 0.8, then you cannot add the text (that's why I included colour coding of the axes). You can also use just lines instead of cylinders if you wish: obj = would work as well to define the axes object. Ray-traceable labels You can use the cgo text (line or cylinder versions) as I mentioned in my reply about drawing the xyz axes, but be warned that the labels rotate with your molecule, so getting them oriented perpendicular to the view may be a pain (unless there is something I've missed). Warren's example from a previous reply of his ( cgotext.py ): # draw text using cgo from pymol import cmd from pymol.cgo import * from pymol.vfont import plain cgo = , , ] pos = wire_text(cgo,plain,pos,'Hello World',axes) pos = cyl_text(cgo,plain,pos,'Hello Universe',0.10,axes=axes) cmd.set("cgo_line_radius",0.03) cmd.load_cgo(cgo,'txt') cmd.zoom("all",2.0) Robert Campbell CGO label orientation You could use the cmd.rotate and cmd.translate to position the labels, but it is likely to be somewhat painful. If I'm not mistaken, the rotation will always be about and axis through the origin and so you may need to translate the label into the correct position. Thus if you have your label in an object called 'text', you could do, cmd.rotate(axis='x',angle=20.,object='text') and repeat this with different angles, until you get the orientation correct. Then use: cmd.translate(vector=' ',object='text') (using the appropriate vector, of course!) to position the label. Not ideal, but if it is sufficiently important, it can be done! Robert Campbell 3D marks on atoms Here's a script graph.py which can be used to put marks on the positions of every atom in a selection. There are several types of marks included now, e.g. cube, rhombic dodecahedron, tetrahedron, plus and star. Using a matrix operator these can be extended a bit, to 2D counterparts for example, or to elongated or rotated shapes. I should still include some documentation but in brief the usage is as follows: graph selection = '(all)', shape = 'plus' | 'sphere' | 'star' | 'tetrahedron' | 'dodecahedron', size = 1, r = 0.10, rgb1 = , rgb2 = , mtx = , , ], name = "graph" Selection should be obvious, as is shape. Size is a relative indicator for the size, though at present I haven't fixed things such that a size 1 tetrahedron matches a size 1 dodecahedron. r is the radius of the lines. rgb1 and rgb2 are the start and end color for each line. mtx is the matrix operator, which works on the original shape centered around the origin (before translation to the point of the atom from the selection). Tserk Wassenaar Save and load objects There is a convenient format: ".pkl", that works like PDB, but is a Pickled copy of the PyMOL Model Class. The main advantage this has over .pdb is that it saves and restores extra properties such as secondary structure code, atom types, van der waals radii, formal and partial charges, etc. load myprot.pdb dss show cartoon alter 100-110/, ss='H' alter 65-67,ss='L' save myprot.pkl ... quit program, complete your PhD, take a vacation, and come back... load myprot.pkl show cartoon will work. ".pkl" has the additional advantage of being a simple molecular object useful in straight Python, outside of PyMOL. All you need to do is have a copy of PyMOL's "chempy" module available in your PYTHONPATH from chempy import io model = io.pkl.fromFile("myprot.pkl") for atom in model.atom: print atom.name Warren DeLano Building ChemPy models This is a snap. Just "run" the following Python program from within PyMOL. from chempy.models import Indexed from chempy import Bond, Atom from whrandom import random from pymol import cmd model = Indexed() # create some atoms for a in range(1,11): at = Atom() at.name = "X%02d"%a at.coord = model.atom.append(at) # now create some bonds for a in range(1,10): bd = Bond() bd.index = # zero-based indices! model.bond.append(bd) # now load and label cmd.load_model(model,"example") cmd.label("example","name")
个人分类: 好文转载|25286 次阅读|1 个评论

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-26 01:07

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部