我正在try 使用rdkit python库将inchi转换为sdf格式.我正在运行以下一行python代码.
#convert inchi to sdf
def MolFromInchi(id,inchi):
mol = Chem.MolFromInchi(inchi)
mol_block = Chem.MolToMolBlock(mol)
print (id, mol_block)
print ('$$$$')
with open (r'C:/Users/inchi_canonize') as f:
for line in f:
lst=line.split(' ')
elements = [x for x in lst if x] #remove empty elements and get id (elements[0]) and inchis (elements[1])
elements[1] = ('\''+elements[1].strip()+'\'')
id = elements[0]
inchi = elements[1].rstrip("\n")
print (inchi)
MolFromInchi(id,inchi)
输入文件(inchi_canonize)有以下字段.
D08520 InChI=1S/C10H18O2/c1-7-4-5-8(6-9(7)11)10(2,3)12/h4,8-9,11-12H,5-6H2,1-3H3
D07548 InChI=1S/C17H25NO4.ClH/c1-20-13-11-15(21-2)17(16(12-13)22-3)14(19)7-6-10-18-8-4-5-9-18;/h11-12H,4-10H2,1-3H3;1H
D10000 (null)
以下是错误:
ArgumentError: Python argument types in
rdkit.Chem.rdmolfiles.MolToMolBlock(NoneType)
did not match C++ signature:
MolToMolBlock(class RDKit::ROMol mol, bool includeStereo=True, int confId=-1, bool kekulize=True, bool forceV3000=False)
非常感谢您的帮助