On 02/08/12 14:48, Gonzalo Colmenarejo-Sanchez wrote:

Hi,

I have a c++ code that uses SmilesToMol. As soon as there is one SMILES that the program fails to sanitize I get an error message like this:

/[13:46:35] Explicit valence for atom # 15 N, 5, is greater than permitted/

/terminate called after throwing an instance of 'RDKit::MolSanitizeException'/

/what(): N5RDKit20MolSanitizeExceptionE/

/Abort/

//

and the program exits.

Is there a way to handle this error and avoid the exit?


Yes.

What does SmilesToMol returns when it fails?



My understanding is that shouldn't happen. If it succeeds, it returns an RWMol *. If it fails, it throws an exception.

To answer your question though - and presuming you have a vector of smiles_strings (and it is not clear (to me) if you wrote the c++ code or if vendor software is using rdkit) the call to SmilesToMol() should be wrapped with a try/catch...

try {
   rwmol = SmilesToMol(smiles_strings[i]);
   // cool stuff here...
}
catch (RDKit::MolSanitizeException msg) {
    // do something (or nothing)...
   std::cout << msg.what() << std::endl;
}

It is not clear to me if SmilesToMol might throw other exceptions (I suspect that it does), so perhaps you are better catching a std::exception rather than a RDKit::MolSanizeException.

Paul.



------------------------------------------------------------------------------
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
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to