Thanks Greg, that helped!
sabrina
*
*
On Fri, Mar 22, 2013 at 9:33 AM, Greg Landrum <[email protected]>wrote:
> Hi Sabrina,
>
> The molecules that come back from an RDKit reaction have not been
> sanitized (i.e. the chemistry checking and valence calculations have
> not yet been done).
>
> If you just want to check if the molecules are chemically reasonable
> you can do the following:
> In [1]: from rdkit import Chem
>
> In [2]: from rdkit.Chem import AllChem
>
> In [3]: rxn = AllChem.ReactionFromSmarts('[C:1][O:2]>>[C:1][O:2]C')
>
> In [4]: ms = [Chem.MolFromSmiles(x) for x in ('CO','CCO','COC')]
>
> In [5]: for m in ms:
> ...: ps = rxn.RunReactants((m,))
> ...: for p in ps:
> ...: try:
> ...: Chem.SanitizeMol(p[0])
> ...: except:
> ...: print 'failed'
> ...: else:
> ...: print Chem.MolToSmiles(p[0])
> ...:
> COC
> CCOC
> [14:33:13] Explicit valence for atom # 1 O, 3, is greater than permitted
> failed
> [14:33:13] Explicit valence for atom # 1 O, 3, is greater than permitted
> failed
>
> -greg
>
>
> On Fri, Mar 22, 2013 at 1:34 AM, Syeda Sabrina <[email protected]>
> wrote:
> > Hi everyone,
> > I was trying to check whether all the atoms of product molecules for a
> > reaction have right number of valences as they supposed to be. I was not
> > clear whether there GetExplicitValence() is the right function to use or
> not
> > for this purpose. So I triet to start with it and I used it in the
> > following code and ended up with Runtime Error.
> >
> >
> >
> rxn=AllChem.ReactionFromSmarts('[C:1]/[C:2]=[C:3]/[C:4][C:5]>>[C;1][C:2]\[C:3]=[C:4]\[C:5]')
> >
> > rxn.Initialize()
> >
> > reactants=[]
> >
> > reactants.append(Chem.MolFromSmiles('C/C=C/CC'))
> >
> > products=rxn.RunReactants(tuple(reactants))
> >
> > for p in products:
> > for mol in p:
> > for atom in mol.GetAtoms():
> > print atom.GetSymbol(), atom.GetExplicitValence()
> >
> >
> C---------------------------------------------------------------------------
> > RuntimeError Traceback (most recent call
> last)
> > <ipython-input-14-513b40c7a212> in <module>()
> > 2 for mol in p:
> > 3 for atom in mol.GetAtoms():
> > ----> 4 print atom.GetSymbol(), atom.GetExplicitValence()
> > 5
> >
> > RuntimeError: Pre-condition Violation
> >
> > However, it can calculate the implicit valence. How can this be possibly
> > fixed? Or, is there any other way to check whether an atom has correct
> > explicit valence that could be permitted.
> >
> > Thanks
> > Sabrina
> >
> >
> >
> ------------------------------------------------------------------------------
> > 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_mar
> > _______________________________________________
> > Rdkit-discuss mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
> >
>
------------------------------------------------------------------------------
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_mar
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss