代码示例:
#导入依赖包
#!/usr/bin/python3
from rdkit.Chem import AllChem as ch
from rdkit.Chem import Draw as d
#载入分子库
suppl = ch.SDMolSupplier('drugbank.sdf')
mols = [x for x in suppl if x is not None]
print (len(mols)) #获取分子数目
#载入substructure结构
pattern = ch.MolFromSmarts('[CX3](=O)[OX2H1]')
#亚结构匹配
matching_molecules = [m for m in mols if m.HasSubstructMatch(pattern)]
print (len(matching_molecules)) #统计匹配分子数目
#输