On Thu, Jan 31, 2013 at 4:50 PM, JP <[email protected]> wrote:
> I am trying to depict R groups using a labels like "R1", "R2" etc.
>
> From a previous discussion:
> http://www.mail-archive.com/[email protected]/msg01793.html
>
> "Here's what's going on currently:
>
> By default the rendering code uses atom.GetSymbol() to determine what should
> show up in the drawing. atom.GetSymbol() using the atomic number, unless the
> atom has the property "dummyLabel" set. If that property is set, it's used.
> It should also be checking for the property "_MolFileRLabel"."
>
>
> I assumed that setting dummyLabel should be enough and this would work:
>
> m = Chem.MolFromSmiles('CCN')
> for a in m.GetAtoms():
> a.SetProp("dummyLabel", "R" + str(a.GetIdx()))
> Draw.MolToFile(m, 'test.png')
>
> Any idea why I do not get my R labels?
Short answer: it's a bug. I will fix it, but in the meantime you can
work around it by passing the "kekulize=False" argument to the drawing
function (you should probably kekulize the molecule yourself first if
you want to see single and double bonds instead of the ugly dashed
aromatic bonds).
Somewhat longer answer:
Doing the SetProp actually does work, you can convince yourself of
this like this:
In [9]: m = Chem.MolFromSmiles('*C')
In [10]: m.Debug()
Atoms:
0 0 * chg: 0 deg: 1 exp: 1 imp: 0 hyb: 0 arom?: 0 chi: 0
1 6 C chg: 0 deg: 1 exp: 1 imp: 3 hyb: 4 arom?: 0 chi: 0
Bonds:
0 0->1 order: 1 conj?: 0 aromatic?: 0
In [11]: m.GetAtomWithIdx(0).SetProp("dummyLabel","R")
In [12]: m.Debug()
Atoms:
0 0 R chg: 0 deg: 1 exp: 1 imp: 0 hyb: 0 arom?: 0 chi: 0
1 6 C chg: 0 deg: 1 exp: 1 imp: 3 hyb: 4 arom?: 0 chi: 0
Bonds:
0 0->1 order: 1 conj?: 0 aromatic?: 0
Unfortunately that information does not survive when the molecule is copied:
In [13]: m2= Chem.Mol(m.ToBinary())
In [14]: m2.Debug()
Atoms:
0 0 * chg: 0 deg: 1 exp: 1 imp: 0 hyb: 0 arom?: 0 chi: 0
1 6 C chg: 0 deg: 1 exp: 1 imp: 3 hyb: 4 arom?: 0 chi: 0
Bonds:
0 0->1 order: 1 conj?: 0 aromatic?: 0
When you draw a molecule, the default behavior is to kekulize the
molecule first. Since drawing your molecule shouldn't modify it, the
drawing code makes a copy first then kekulizes the copy. Making the
copy destroys the dummyLabel information you added... Bad RDKit.
Fortunately, there's a pretty quick fix for this that I'll make now.
-greg
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_jan
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss