Thanks Paul, David and Greg. It's much useful.

Greg, are you planning to add a "Getting started with the RDKit in C++" chapter 
in the documentation? It would help C++ users a lot. 

Thanks,

Gonzalo

-----Original Message-----
From: Greg Landrum [mailto:[email protected]] 
Sent: 03 August 2012 15:20
To: Gonzalo Colmenarejo-Sanchez
Cc: [email protected]
Subject: Re: [Rdkit-discuss] SmilesToMol runtime error

On Fri, Aug 3, 2012 at 6:17 AM, DAvid Cosgrove <[email protected]> 
wrote:
> Hi,
>
>
>
> It's a minor point in the discussion, maybe, but Meyers' 'More 
> Effective
> C++' recommends always catching exceptions by reference.  It's quicker 
> C++than
> catching by value because it avoids copy construction, and, more 
> importantly, it avoids the problem of class slicing if a derived class 
> exception object is caught as a base exception.
>
>
>
> Paul's code snippet becomes
>
>
>
> try {
>    rwmol = SmilesToMol(smiles_strings[i]);
>    // cool stuff here...
> }
> catch (RDKit::MolSanitizeException &msg) {
>     // do something (or nothing)...
>    std::cout << msg.what() << std::endl; }
>

Dave is definitely right here: this is how you should handle things if you want 
to deal specifically with different exception times.

The RDKit python wrapper for building molecules from SMILES
($RDBASE/Code/GraphMol/Wrap/rdmolfiles.cpp) does the following:

    RWMol *newM;
    try {
      newM = SmilesToMol(smiles,0,sanitize,&replacements);
    } catch (...) {
      newM=0;
    }
    return static_cast<ROMol *>(newM);

the Python wrapper always returns a None when the molecule cannot be processed 
(no matter the reason), so I don't need to do anything with the exception and I 
don't care what type it is. Consequently I use the less than elegant form above.

-greg



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to