PyMOL 的安装、球棍模型设置与图片输出
XiaO / 2020-05-13
用 Homebrew 在 MacOS Catalina 下 安装开源版 PyMol
为安装 PyMol 添加一些依赖程序
brew install Caskroom/cask/xquartz
brew install tcl-tk
brew install python3
安装 PyMol (Homebrew version 2.3)
brew install brewsci/bio/pymol
安装 PyMol (源码本地编译 version 2.4)
# 如果您使用的是较旧版本的 pymol,请先使用 brew uninstall pymol 卸载它
brew uninstall
brew install wget
brew tap brewsci/bio
cd ~/Desktop
#下载 pymol 2.4 配方
wget https://raw.githubusercontent.com/YoshitakaMo/homebrew-bio/develop/Formula/pymol.rb
brew install --build-from-source ~/Desktop/pymol.rb
启动 pymol
pymol
添加图形界面
* Step 1: Open the `Automator` app. Create a new document and select "Application";
* Step 2: Left under "Actions Library" select "Utilities" and "Run Shell Script";
* Step 3: Choose "/bin/bash" as a shell;
* Step 4: Paste the following: `/usr/local/bin/pymol -M`. Change the path to pymol (`which pymol`) if necessary;
* Step 5: Save the application ("File > Save") to the Desktop and name it "pymol".
更加方便的是,直接创建 右键快捷动作
打开分子
-
步骤 1:打开
Automator
软件,⌘ + N
新建文件,选择Quick Action
; -
步骤 2:左侧动作库中选择
Run Shell Script
,拖拽到右侧工作流中; -
步骤 3:设置动作:
- 接收来自文件夹的数据,并作为 shell 的传入数据;
- Shell 中填入:
/usr/local/bin/pymol "$@"
-
步骤 4:保存为 pymol;
-
使用:右键点击需要打开的分子文件,选择
服务
,选择pymol
; -
快捷动作在系统里的存储位置为
~/Library/Services/
。 -
PyMol 中文版入门教程
-
PyMol 官方使用说明
PyMol 透明背景设置以及球棍模型
设置透明背景
set ray_opaque_background, off
是否显示球棍模型
set stick_radius,0.15
set sphere_scale,0.2
是否显示双键
set valence, 0 # off
set valence, 1 # on
双键显示模式
set valence_mode, 0 # centered
set valence_mode, 1 # inside
设置双键的间距
set valence_size, 0.1 # default: 0.06 # range 0 - ~0.5
最终统一设置如下
set ray_opaque_background, off
set valence, 1
set valence_mode, 0
set valence_size, 0.1
set stick_radius,0.15
set sphere_scale,0.2
高分辨率图片输出
png filename[, width[, height[, dpi[, ray[, quiet]]]]]
例如,保存图片为 test.png
到 ~/Library/Mobile Documents/com~apple~CloudDocs/Science/DSDS/Molecular 3D Structures/
文件夹,设置宽度为 10 in
,分辨率为 600 dpi
。
png ~/Library/Mobile Documents/com~apple~CloudDocs/Science/DSDS/Molecular 3D Structures/test.png, width=10 in, dpi=600, ray=1
ray 576,576 # 8inch * 72 dpi;
ray 800,800 # 8inch * 100 dpi;
ray 2400,2400 # 8inch * 300 dpi;
Mac 下,用 Pymol 创建质量或者几何中心:
-
下载 Center of Mass 脚本;
-
把
center_of_mass.py
脚本拖拽到pymol
安装文件夹下的Lib
子文件夹中:- For Mac users,in your
Applicaiton
folder,findMacPyMOL.app
; - Show Content;
- Put the
center_of_mass.py
file under the following path:
/pymol/modules/pymol/center_of_mass.py
; - For Mac users,in your
-
Input
import center_of_mass
and return; -
select the relevant atoms, and input
com sele,state=1
; -
Change the color, name of the object.
图片中 label 的设置:
- 设置 label 字体大小:set label_size, n (n 为任一数字)
- 设置 label 字体:set label_font, n (n 为任一数字)
set label_font, 8
set label_shadow_mode, 0
set label_size, 20
set label_color, color-name, selection
set label_color, black
制作动画:
mset 1, 180
util.mroll 1, 180, 1
set ray_trace_frames, 1
set cache_frames, 0