PyMOL是一个开源基础上的用户赞助的分子可视化系统,由薛定谔维护和分发。
1. conda 安装
# 安装conda
# 安装conda环境并激活
conda install -c schrodinger pymol-bundle
pip3 install PyQt5
##注意:远程服务器上不能启动,本地安装可以启动。
## 永久试用
# 安装路径下的 /path/to/lib/site-packages/pymol下找到licensing.py,把里面跟授权相关的代码注释掉,或者修改licensing.py文件
cp $con_env/lib/python3.8/site-packages/pymol/licensing.py $con_env/lib/python3.8/site-packages/pymol/licensing.py.bak
vim $con_env/lib/python3.8/site-packages/pymol/licensing.py
##
## Incentive PyMOL licensing helpers
##
import sys
import os
import threading
USE_DIRECTORIES = False
USE_FILENAMES = True
LICENCE_DIRECTORY = u'$PYMOL_PATH/licenses'
LICENCE_DIRECTORY_USER = u'~/.pymol/licenses'
LICENCE_FILENAME = u'$PYMOL_PATH/license.lic'
LICENCE_FILENAME_USER = u'~/.pymol/license.lic'
post_ns = {}
from os.path import expanduser
def post_license_check(msg):
try:
print("CRACKED", post_ns, msg)
post_ns['callback'](msg)
except KeyError:
post_ns['message'] = msg
def set_post_license_check_handler(callback):
post_ns['callback'] = callback
try:
callback(post_ns.pop('message'))
except KeyError:
pass
def get_license_search_path():
'''Get the search path for license files'''
path = []
if USE_DIRECTORIES:
path += [
expanduser(LICENCE_DIRECTORY_USER),
os.path.expandvars(LICENCE_DIRECTORY),
]
if USE_FILENAMES:
path += [filename for filename in [
get_license_filename_user(),
os.path.expandvars(LICENCE_FILENAME),
] if os.path.exists(filename)]
# fallback on macOS: Schrodinger licenses directory (putting a license
# file inside the app bundle is a Gatekeeper violation)
if sys.platform == 'darwin':
path.append(u'/Library/Application Support/Schrodinger/licenses')
return os.pathsep.join(path)
def get_license_filenames():
'''List of all license files which might get checked. Only for
diagnostics feedback.
'''
import glob
filenames = []
for n in get_license_search_path().split(os.pathsep):
if os.path.isfile(n):
filenames.append(n)
else:
filenames.extend(glob.glob(n + os.sep + '*.lic'))
return filenames
def get_license_filename_user():
'''The user's license file location (existing or not)'''
filename = os.path.expandvars(LICENCE_FILENAME_USER)
filename = expanduser(filename)
return filename
def install_license_key(key):
'''Copy the given key to the user's license file and check the license'''
licfile = get_license_filename_user()
try:
os.makedirs(os.path.dirname(licfile), 0o750)
except OSError:
pass
try:
os.unlink(licfile)
except OSError:
pass
try:
handle = open(licfile, 'wb')
except IOError:
print(' Warning: cannot write to "%s", using temporary file instead.' %
licfile)
import tempfile
licfile = tempfile.mktemp('.lic')
handle = open(licfile, 'wb')
if not isinstance(key, bytes):
key = key.encode("utf-8")
# Unicode/UTF-8 BOM
if key.startswith(b"\xEF\xBB\xBF"):
key = key[3:]
with handle:
handle.write(key)
return check_license_file(licfile)
def install_license_file(filename):
'''Copy the given file to the user's home and check the license'''
return install_license_key(open(filename, 'rb').read())
def get_site_license_key():
'''Download and return the license key of an IP-based site license, or
an empty string if IP not recognized or an error occured.'''
return 'MYKEY-SKY'
try:
import requests
response = requests.get('https://pymol.org/getlicfile.php')
response.raise_for_status()
except Exception as e:
print('internet request failed: ' + str(e))
return ''
return response.json().get('key', '')
def print_info(info=None, withnotice=True):
'''Print various license info.
@param withnotice: Show the notice, which may contain the invoice number
'''
if info is None:
info = get_info()
if 'date' in info:
print(' License Expiry date: %s' % (info['date']))
if withnotice and 'notice' in info:
print(' License Notice: %s' % (info['notice']))
if 'days' in info:
print(' Warning: License will expire in %s days' % (info['days']))
if 'msg' in info:
print(info['msg'])
def get_info():
'''Get a dictionary with license metadata'''
return {
'notice' : 'Cracked By SKY',
'date' : '2045-01-23 12:00:00',
'msg' : 'Crackeds',
'days' : '12311'
}
import pymol
return pymol._cmd.check_license_file('')
def check_license_file(licfile=''):
'''Return an empty string on successful license check, or an error message
on failure.'''
return ''
if not licfile:
licfile = get_license_search_path()
# Workaround for FlexLM limitation (PYMOL-3507)
if '@' in licfile and os.path.exists(licfile):
with open(licfile) as handle:
licfile = ("START_LICENSE\n" + handle.read().rstrip() +
"\nEND_LICENSE\n")
import pymol
print(pymol._cmd)
msg = pymol._cmd.check_license_file(licfile)
post_license_check(msg)
# for rigimol
os.environ['PYMOL_LICENSE_FILE'] = licfile
# check license in background
_t = threading.Thread(target=check_license_file)
_t.setDaemon(1)
_t.start()
#修改时间戳,例如 1906545600
vim /users/zhengxueming/.pymoltimestamp
# 时间戳计算
###### python3 代码#########
import time
dt = "2035-06-01 20:00:00"
timeArray = time.strptime(dt, "%Y-%m-%d %H:%M:%S")
timestamp = time.mktime(timeArray)
print(timestamp)
###### python3 代码#########
2. pymol源码安装
2.1.安装依赖
# CentOS
yum install gcc gcc-c++ kernel-devel python-devel tkinter python-pmw glew-devel freeglut-devel libpng-devel freetype-devel libxml2-devel glm-devel msgpack-devel netcdf-devel
# 错误:没有任何匹配: python-devel tkinter python-pmw
修改yum源
yum install python38-devel python38-tkinter
yum install gcc gcc-c++ kernel-devel glew-devel freeglut-devel libpng-devel freetype-devel libxml2-devel glm-devel msgpack-devel netcdf-devel python38-devel python38-tkinter
# 安装Pmw (Python Megawidgets, 可选, 用于 GUI/插件)
git clone https://github.com/schrodinger/pmw-patched.git
cd pmw-patched
python setup.py install
#yum install python3-pyqt5 python38-pmw
#没有可用软件包 python3-pyqt5。
#没有可用软件包 python38-pmw。
# 考虑换Base
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
vim /etc/yum.repos.d/CentOS-Base.repo
2.2 下载软件
git clone https://github.com/schrodinger/pymol-open-source.git
git clone https://github.com/rcsb/mmtf-cpp.git
mv mmtf-cpp/include/mmtf* pymol-open-source/include/
cd pymol-open-source
2. 3. 编译安装
prefix=$HOME/pymol-open-source-build
prefix=/home/zheng/pymol-open-source-build
python3 setup.py build install --home=$prefix --glut
# python3 setup.py build install --home=$prefix
#注意参考,按照官方的源码安装方法,编译成功,服务器上远程启动不了,可能是图形界面的问题。
参考: