Dear all,

A couple days ago I created a branch to work on adding some
sanitization changes to the RDKit
(http://rdkit.svn.sourceforge.net/viewvc/rdkit/branches/SanitizationChanges_11Feb2012/).

I've added two things, the ability to specify which sanitization
operations should be carried out and the ability to get a return value
from the SanitizeMol function instead of having it raise an exception.

Here's what it looks like:

In [5]: Chem.SanitizeMol?
Type:       function
Base Class: <type 'builtin_function_or_method'>
String Form:<Boost.Python.function object at 0x1ec6740>
Namespace:  Interactive
Docstring:
SanitizeMol( (Mol)mol [,
(int)sanitizeOps=rdkit.Chem.rdmolops.SanitizeFlags.SANITIZE_ALL [,
(bool)catchErrors=False]]) -> SanitizeFlags :
    Kekulize, check valencies, set aromaticity, conjugation and hybridization

        - The molecule is modified in place.

        - If sanitization fails, an exception will be thrown unless
catchErrors is set

      ARGUMENTS:

        - mol: the molecule to be modified
        - sanitizeOps: (optional) sanitization operations to be carried out
                       these should be constructed by or'ing together the
                       operations in rdkit.Chem.SanitizeFlags
        - catchErrors: (optional) if provided, instead of raising an exception
                       when sanitization fails (the default behavior), the
                       operations that failed (as defined in
rdkit.Chem.SanitizeFlags)
                       is returned. Zero is returned on success.



    C++ signature :
        RDKit::MolOps::SanitizeFlags SanitizeMol(RDKit::ROMol {lvalue}
[,unsigned int=rdkit.Chem.rdmolops.SanitizeFlags.SANITIZE_ALL
[,bool=False]])



An example of using it:

#---------------------------
In [6]: m = Chem.MolFromSmiles('c1cccc1',sanitize=False)

In [7]: Chem.SanitizeMol(m)
[06:17:24] Can't kekulize mol

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/scratch/RDKit_sanit/<ipython-input-7-dd6845fa341c> in <module>()
----> 1 Chem.SanitizeMol(m)

ValueError: Sanitization error: Can't kekulize mol
#---------------------------

That's the same as the current behavior.

Now let's see what the problem was:

#---------------------------
In [8]: m = Chem.MolFromSmiles('c1cccc1',sanitize=False)

In [9]: Chem.SanitizeMol(m,catchErrors=True)
[06:17:41] Can't kekulize mol

Out[9]: rdkit.Chem.rdmolops.SanitizeFlags.SANITIZE_KEKULIZE
#---------------------------

Ok, so it failed in sanitization, so let's try sanitizing the molecule
without doing the kekulization step:

#---------------------------
In [10]: m = Chem.MolFromSmiles('c1cccc1',sanitize=False)

In [11]: 
Chem.SanitizeMol(m,sanitizeOps=Chem.SanitizeFlags.SANITIZE_ALL^Chem.SanitizeFlags.SANITIZE_KEKULIZE)
Out[11]: rdkit.Chem.rdmolops.SanitizeFlags.SANITIZE_NONE
#---------------------------

Note that there is a change even in the default behavior in that
Chem.SanitizeMol now always returns a value. Previously it always
returned None, but now you get a value back.


Any comments or suggestions about the API?
-greg

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to