写在前面:安装MGLtools的目的是为了使用autodocktools中批量.pdb转.pdbqt的功能
下载好,然后放在你的目录下
然后【注意这里你下载的文件名可能为:mgltools_x86_64Linux2_1.5.6.tar_.gz,多了一个_,无所谓直接】
tar -zxvf mgltools_x86_64Linux2_1.5.6.tar_.gz
cd mgltools_x86_64Linux2_1.5.6/
bash install.sh
mgl的安装位置应该是你当时下载以后解压到的位置:/mnt/d/MGLTools/mgltools_x86_64Linux2_1.5.6/
vim ~/.bashrc
使用转.pdbqt的功能:
更改python解释器,这一步必须要做:
也就说相当于使用了他们内置的python解释器,这样你就不用单独再创建一个python2.7解释器了,并且如果你自己创建python27解释器会有很多问题
# 进入脚本文件中修改python编译器
vim $MGL_ROOT/MGLToolsPckgs/AutoDockTools/Utilities24/prepare_receptor4.py
# 更改第一行
#!/usr/bin/env python
->
#!/usr/bin/env $MGL_ROOT/bin/python
使用功能:
pythonsh [yourpath or .]/prepare_receptor4.py -r receptor_filename [options]
代码:
原文用的是ADFR进行转换,我这里用的是MGLtools将pdb转为pdbqt文件
import os
import glob
################
# Usage: prepare_ligand4.py -l filename
# Description of command...
# -l ligand_filename (.pdb or .mol2 or .pdbq format)
# Optional parameters:
# [-v] verbose output
# [-o pdbqt_filename] (default output filename is ligand_filename_stem + .pdbqt)
# [-d] dictionary to write types list and number of active torsions
# [-A] type(s) of repairs to make:
# bonds_hydrogens, bonds, hydrogens (default is to do no repairs)
# [-C] do not add charges (default is to add gasteiger charges)
# [-p] preserve input charges on atom type, eg -p Zn
# (default is not to preserve charges on any specific atom type)
# [-U] cleanup type:
# nphs_lps, nphs, lps, '' (default is 'nphs_lps')
# [-B] type(s) of bonds to allow to rotate
# (default sets 'backbone' rotatable and 'amide' + 'guanidinium' non-rotatable)
# [-R] index for root
# [-F] check for and use largest non-bonded fragment (default is not to do this)
# [-M] interactive (default is automatic output)
# [-I] string of bonds to inactivate composed of
# of zero-based atom indices eg 5_13_2_10
# will inactivate atoms[5]-atoms[13] bond
# and atoms[2]-atoms[10] bond
# (default is not to inactivate any specific bonds)
# [-Z] inactivate all active torsions
# (default is leave all rotatable active except amide and guanidinium)
# [-g] attach all nonbonded fragments
# [-s] attach all nonbonded singletons:
# NB: sets attach all nonbonded fragments too
# (default is not to do this)
################
def pdbs_to_pdbqts(pdb_dir, pdbqt_dir):
print(glob.glob(os.path.join(pdb_dir, '*.pdb')))
for file in glob.glob(os.path.join(pdb_dir, '*.pdb')):
name = os.path.splitext(os.path.basename(file))[0]
outfile = os.path.join(pdbqt_dir, name + '.pdbqt')
pdb_to_pdbqt(file, outfile)
print('Wrote converted file to {}'.format(outfile))
def pdb_to_pdbqt(pdb_file, pdbqt_file):
os.system('/mnt/d/MGLTools/mgltools_x86_64Linux2_1.5.6/MGLToolsPckgs/AutoDockTools/Utilities24/prepare_ligand4.py -l {} -o {}'.format(pdb_file, pdbqt_file))
return pdbqt_file
# prepare ligand for docking
if __name__ == '__main__':
pdb_dir, pdbqt_dir = 'output_ligand/pdb','output_ligand/pdbqt'
pdbs_to_pdbqts(pdb_dir, pdbqt_dir)