LoginSignup
3
3

More than 5 years have passed since last update.

RDKitで分子中の等価(対称な)原子を検出する

Last updated at Posted at 2019-04-14

はじめに

分子中の原子に着目して機械学習等でデータ処理を行う場合、分子中の等価な原子は冗長であるため、夫々別データとするのではなく、1つのデータとして処理をしたい。このために、分子中の等価な原子を検出する方法を調べたのでメモっておく。

環境

  • OS Windows10
  • Python 3.7
  • RDKit 2018/9/2
  • Jupyter Notebook

やり方

まずはサンプルとなる原子を読み込んで表示しよう。

from rdkit.Chem import AllChem, Draw, rdmolops
from rdkit.Chem.Draw import IPythonConsole
mols = AllChem.SDMolSupplier("../som/17.mequitazine.mol")
mol = mols[0]
Draw.MolToImage(mol)

こんな感じの分子が表示されたとする。
ここで、3つ連続した環の両サイドのベンゼン環の各原子は、完全に等価である。

image.png

この等価な原子を検出するには、CanonicalRankAtomsを以下のように用いる。そうすると、rankAtomsの中に、原子のインデックス順にランクが得られる。このランク、同じ番号は等価な原子である。

rankAtoms = list(rdkit.Chem.rdmolfiles.CanonicalRankAtoms(mol, breakTies=False))
print(rankAtoms)
[13, 20, 12, 21, 10, 8, 19, 8, 10, 22, 17, 6, 2, 0, 4, 15, 14, 15, 4, 0, 2, 6, 17]

さて、番号だけではわかりにくいため、分子の各原子上に上のランクを表示させてみよう。

for atom in mol.GetAtoms():
    atom.SetProp('molAtomMapNumber',str(rankAtoms[atom.GetIdx()]))
mol

するとこんな感じで表示される。

image.png

文字がつぶれて見ずらいが、確かに2つのベンゼン環の対応する原子は同じランク(番号)になっていることが分かる。

参考

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3