XiaO

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".

更加方便的是,直接创建 右键快捷动作 打开分子

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 创建质量或者几何中心:

图片中 label 的设置

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