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



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

是否有可能用RDkit做到这一点?如果是这样,如何?

要从分子中获得角度,它必须至少具有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)

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

最新更新