Drkcore

29 03 2012 Python openbabel Tweet

pybelでanilineをnitrenium ionに変換する

なぜnitrenium ionにする必要があるのかはここではふれないので、ココらへんを見てください。

import pybel
smarts = pybel.Smarts("c[#7]([#1])[#1]")

mol = pybel.readstring('smi', 'c1ccccc1N')
mol.make3D()
matches = smarts.findall(mol)
mol.OBMol.DeleteAtom(mol.atoms[matches[0][2]-1].OBAtom)
mol.OBMol.SetTotalCharge(1)
print mol.write('mol')

分子に修飾をしたい時はpybelにメソッドがないので、OpenBabelのオブジェクトを直接触る必要があるのであまりスマートではない気がする。

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021