这是我的剧本:
dopts = Draw.rdMolDraw2D.MolDrawOptions()
dopts.prepareMolsBeforeDrawing = True
k = 10
results = Draw.MolsToGridImage(
self.hits[:k + 1], molsPerRow=5, subImgSize=(250,250),
drawOptions=dopts,
legends=[x.GetProp("chembl_id")
for x in self.hits[:k]], )
results.save(f'{self.out_dir}/output.png')
但是整个图像输出文件中的分子放错了位置output is something like this.
我已将此作为一个问题发布,尚未解决https://github.com/rdkit/rdkit/issues/4097
查看有关分子制备的documentation section(
prepareMolsBeforeDrawing
),似乎表明如果2D构象已经存在,它将不会生成新构象如果你的分子来自某种类似SDF的东西,那么也许移除已经存在的构象可以解决这个问题,尽管我不能完全确定,因为我没有SDF要测试。在绘制图像之前,请尝试添加以下内容,假设您对已经存在的构象没有任何用处,否则,请事先制作一份副本
编辑:
在一些具有3D构象的化合物上进行测试,移除构象确实迫使rdkit生成新的2D坐标用于描述
或者,您也可以自己添加二维坐标,覆盖现有构象,然后如果您愿意,可以删除preparation参数,前提是您对它执行的其他清理步骤不感兴趣:
相关问题 更多 >
编程相关推荐