Python调用OpenBabel的API,输出sdf文件中分子的分子量
官网手册地址:点击打开链接
第一种方式
from pybel import *
for molecule in readfile("sdf","Sofosbuvir.sdf"):
print molecule.molwt
第二种方式
from openbabel import *
obconversion = OBConversion()
obconversion.SetInFormat("sdf")
obmol = OBMol()
notatend = obconversion.ReadFile(obmol,"Sofosbuvir.sdf")
while notatend:
print obmol.GetMolWt()
obmol = OBMol()
notatend = obconversion.Read(obmol)
多分子sdf文件中分子的分子量输出
实例
from pybel import *
for molecule in readfile("sdf","NatProduct.sdf"):
print molecule.molwt