我需要从微笑字符串(或.xyz文件)中找到所有可能的键,分子中原子之间的角度的列表。

时间:2019-10-15 08:16:24

标签: python rdkit

我正在尝试开发力场,为此,我需要从微笑字符串oe .xyz文件中列出一个分子中所有可能的键,角度和二面角的列表。

是否可以使用RDkit做到这一点?如果可以,怎么办?

1 个答案:

答案 0 :(得分:0)

要从分子中获取角度,该角度必须至少具有2D坐标,rdkit无法通过XYZ文件构造分子,但可以读取SMILES字符串。

from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit.Chem import rdMolTransforms

# Read molecule from smiles string
mol = Chem.MolFromSmiles('N1CCNCC1')

# Get all bonds in the molecule
bonds = [(x.GetBeginAtomIdx(), x.GetEndAtomIdx()) for x in mol.GetBonds()]
# [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 0)]

# Compute 2D coordinates
AllChem.Compute2DCoords(mol)
conf = mol.GetConformer()

# Get a torsion angle between atoms 0, 1 & 2
rdMolTransforms.GetAngleDeg(conf, 0, 1, 2)
# 119.99999999999999

# Get a dihedral angle between atoms 0, 1, 2 & 3
rdMolTransforms.GetDihedralDeg(c, 0, 1, 2, 3)
# -0.0  (obviously 0 as the molecule has no 3D coordinates)

如果需要,您可以generate 3D coordinates输入分子,也可以使用SDF文件或类似文件读取具有3D坐标的分子。软件openbabel可以将XYZ转换为SDF