I try setting the "kekulize=False" argument in this way:

print Chem.MolToSmiles(core)
core.Debug()
# need kekulization before passing this to the drawing algorithm
Chem.Kekulize(core)
for r_id in rGroups.keys(): # rGoups is just a list of a few atoms indices
I want to label
      core.GetAtomWithIdx(int(r_id)).SetProp("dummyLabel", "R" + r_id)
Draw.MolToFile(core, core_image, size=(600, 200), kekulize=False)

But I get a ton of these when calling the debug and draw function:

****

N/A imp: -1 hyb: 0 arom?: 0 chi: 0
29 8 O chg: 0  deg: 1 exp: [09:59:59]

****
Pre-condition Violation
getExplicitValence() called without call to calcExplicitValence()
Violation occurred on line 177 in file
/opt/RDKit_2012_12_1/Code/GraphMol/Atom.cpp
Failed Expression: d_explicitValence>-1
****


The core molecule I get using: core =
Chem.MolFromSmarts(MCS.FindMCS(mols).smarts)

This is the SMILES for my
molecule CCC(C)C(NC(C)=O)C(=O)NC(C(=O)NC(C)C(=O)NC(C)CC(N)=O)C(C)O.

And this is the Debug() call on it (this also generates the above errors):

N/A imp: -1 hyb: 0 arom?: 0 chi: 0
Bonds:
0 0->1 order: 1 conj?: 0 aromatic?: 0
 1 1->2 order: 2 conj?: 0 aromatic?: 0
2 1->3 order: 1 conj?: 0 aromatic?: 0
3 3->4 order: 1 conj?: 0 aromatic?: 0
 4 5->6 order: 1 conj?: 0 aromatic?: 0
5 5->7 order: 1 conj?: 0 aromatic?: 0
6 7->8 order: 1 conj?: 0 aromatic?: 0
 7 4->5 order: 1 conj?: 0 aromatic?: 0
8 4->9 order: 1 conj?: 0 aromatic?: 0
9 10->11 order: 1 conj?: 0 aromatic?: 0
 10 12->13 order: 1 conj?: 0 aromatic?: 0
11 12->14 order: 1 conj?: 0 aromatic?: 0
12 11->12 order: 1 conj?: 0 aromatic?: 0
 13 11->15 order: 1 conj?: 0 aromatic?: 0
14 15->16 order: 2 conj?: 0 aromatic?: 0
15 15->17 order: 1 conj?: 0 aromatic?: 0
 16 17->18 order: 1 conj?: 0 aromatic?: 0
17 18->19 order: 1 conj?: 0 aromatic?: 0
18 18->20 order: 1 conj?: 0 aromatic?: 0
 19 21->22 order: 1 conj?: 0 aromatic?: 0
20 22->23 order: 1 conj?: 0 aromatic?: 0
21 22->24 order: 1 conj?: 0 aromatic?: 0
 22 24->25 order: 1 conj?: 0 aromatic?: 0
23 25->26 order: 1 conj?: 0 aromatic?: 0
24 25->27 order: 2 conj?: 0 aromatic?: 0
 25 20->21 order: 1 conj?: 0 aromatic?: 0
26 20->28 order: 2 conj?: 0 aromatic?: 0
27 9->10 order: 1 conj?: 0 aromatic?: 0
 28 9->29 order: 2 conj?: 0 aromatic?: 0

I am quite lost, anyone knows what this actually means - any help/idea what
I am doing wrong?

Many Thanks,
JP

-
Jean-Paul Ebejer
Early Stage Researcher


On 1 February 2013 04:04, Greg Landrum <[email protected]> wrote:

> 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

Reply via email to