Re: [Rdkit-discuss] Get Bond order
Open-Source Cheminformatics and Machine Learning
Brought to you by:
glandrum
From: Taka S. <ser...@gm...> - 2013-06-10 21:02:25
|
Dear Greg. Thank you for your advice. I think your idea is nice! Thank you for your time and consideration. Takayuki 2013/6/9 Greg Landrum <gre...@gm...> > Dear Takayuki, > > On Sat, Jun 8, 2013 at 10:05 AM, Taka Seri <ser...@gm...> wrote: > >> >> I want to know how to get bond order of molecules. >> >> GetBondType method can get bond-type "SINGLE, DOUBLE, TRIPLE,,,," , but >> can't get bond order. >> >> Are there any idea to solve it ? >> > > Unfortunately, from python it's not that easy at the moment. There is a > C++ function getBondTypeAsDouble() but it's not usable from python in > current releases. I will add it for the next release. In the meantime, you > would need to use something like: > > In [3]: bos={Chem.BondType.SINGLE:1.0, > ...: Chem.BondType.DOUBLE:2.0, > ...: Chem.BondType.TRIPLE:3.0, > ...: Chem.BondType.AROMATIC:1.5, > ...: Chem.BondType.UNSPECIFIED:0.0} > > In [4]: m = Chem.MolFromSmiles('Cc1ccccc1') > > In [5]: bos[m.GetBondWithIdx(0).GetBondType()] > Out[5]: 1.0 > > In [6]: bos[m.GetBondWithIdx(1).GetBondType()] > Out[6]: 1.5 > > Hope this helps, > -greg > |