Open Babel GUI 安装:http://openbabel.org/wiki/Category:Installation
另外,下载好openbabel之后并不能直接使用pybel,我在国外的一个网站上看到一个提议,但是听说这个不是openbabel的pybel,而是另一个工具包PyBEL:
python -m pip install pybel_tools
Molecules有以下属性特征: atoms, charge, data, dim, energy, exactmass, formula, molwt, spin, sssr, title and unitcell (晶体数据)。atoms 特征提供了分子中所有Atoms的列表。data 特征返回字典对象,可用来获得和编辑与分子相关的数据 ( 是MoleculeData对象,但可当作普通的字典对象)。unitcell 特征可获得任何与分子有关的“unit cell”数据(OBUnitCell)。
Molecule类
使用ob的分子产生相应附加数据的对象(字典),其实用途不大,更常用mol.data。
>>> mol=readfile("sdf","calculatedprops.sdf").next()# (readfile is described below)
>>> print mol.molwt100.1
>>> print len(mol.atoms)
16
>>> print mol.data.keys()
{'Comment': 'Created by CDK', 'NSC': 1, 'Hydrogen Bond Donors': 3, 'Surface Area': 342.43, .... }
>>> print mol.data['Hydrogen Bond Donors']
3
>>> mol.data['Random Value']=random.randint(0,1000)# 添加一个噪音描述符
用法:Smarts(smartspattern)
Pybel 提供了一个简单的 API 用来链接 Open Babel SMARTS pattern 匹配.。A Smarts object is created, and the findall() method is then used to return a list of the matches to a given Molecule.
Here is an example of its use:
>>> mol = readstring("smi","CCN(CC)CC") # 创造一个三乙胺基团
>>> smarts = Smarts("[#6][#6]") # 匹配乙基基团
>>> print smarts.findall(mol)
[(1, 2), (4, 5), (6, 7)]