Hi Jan,

Wow, I need to cut down on my caffeine intake.  This application reads an
sdf file and writes out smis.  The exception that you pointed out was for
code reached before this MolToSmiles block.  A simple catch Exception e
appears to have fixed everything.

Thanks for pointing that out Jan!
Matt



On Mon, Jun 2, 2014 at 1:27 PM, Matthew Lardy <mla...@gmail.com> wrote:

> Hi Jan,
>
> The exception should be a org.RDKit.MolSanitizeException, but the
> following code fails too:
>
> String smi = "";
>
> try {
> smi = rdmol.MolToSmiles();
> } catch (Exception e) {
> System.err.println("Bad Mol Found: ");
> }
>
> Shouldn't this catch everything? Because that isn't working either.
> That's why I am confused as to what to do (in fact that type of catch works
> fine with other APIs [eg. ChemAxon]).
>
> Matt
>
>
> On Mon, Jun 2, 2014 at 11:12 AM, Jan Holst Jensen <j...@biochemfusion.com>
> wrote:
>
>>  Hi Matt,
>>
>> You are catching exceptions for Mol*To*Smiles(), but the exception that
>> is giving you trouble is caused by Mol*From*Smiles():
>>
>>
>> >    at org.RDKit.RDKFuncsJNI.RWMol_Mol*From*Smiles__SWIG_3(Native
>> Method)
>> >    at org.RDKit.RWMol.Mol*From*Smiles(RWMol.java:422)
>>
>> So my guess is that 'smi' is used in downstream code with an invalid
>> value that causes the error ? And it might be fixed by
>>
>>
>> try {
>> smi = rdmol.MolToSmiles();
>> } catch (org.RDKit.MolSanitizeException e) {
>> *smi = "CC"; // Some valid dummy value in case of read errors.*
>>
>> System.err.println("Bad Mol Found: " + smi);
>> }
>>
>> ?
>>
>> Does the catch-clause work ? Does it output an error to stderr ?
>>
>> Cheers
>> -- Jan
>>
>>
>> On 2014-06-02 19:46, Matthew Lardy wrote:
>>
>>  Hi all,
>>
>> Thanks all!  I should have been a bit more explicit.  This is the context
>> of the offending line:
>>
>> try {
>> smi = rdmol.MolToSmiles();
>> } catch (org.RDKit.MolSanitizeException e) {
>> System.err.println("Bad Mol Found: " + smi);
>> }
>>
>>  I thought after reading the comments, that maybe I was being too
>> specific.  So, I tried the same try/catch block with a more general
>> exception (which I hadn't tried before):
>>
>> try {
>> smi = rdmol.MolToSmiles();
>> } catch (Exception e) {
>> System.err.println("Bad Mol Found: " + smi);
>> }
>>
>>  Nothing changed (I reached the same error):
>>
>> Exception in thread "main" org.RDKit.MolSanitizeException
>>     at org.RDKit.RDKFuncsJNI.RWMol_MolFromSmiles__SWIG_3(Native Method)
>>     at org.RDKit.RWMol.MolFromSmiles(RWMol.java:422)
>>
>>  Hopefully my issue is a bit more clear now.  There is another route
>> around this issue, reading the input file line by line and excising those
>> offending lines.  This would work, but I would rather not have to buffer my
>> RDKit code.  :)
>>
>>  Thanks!
>> Matt
>>
>>
>>
>> On Sun, Jun 1, 2014 at 12:55 AM, Toby Wright <toby.wri...@inhibox.com>
>> wrote:
>>
>>> If you just want to ignore the error add a try...catch block around the
>>> offending line.
>>>
>>>  Yours,
>>>
>>>  Toby Wright
>>>
>>>
>>>   On 31 May 2014 00:03, Matthew Lardy <mla...@gmail.com> wrote:
>>>
>>>>    Hi all,
>>>>
>>>>  I am having this issue with the Java wrapper while trying to create a
>>>> smiles string from a RWMol class object.  I don't care about trying to
>>>> figure out what is going wrong, I just want to bypass this record without
>>>> my application closing.  Any ideas?
>>>>
>>>>  Here is the offending line:
>>>>
>>>> rdmol.MolToSmiles();
>>>>
>>>>  The error:
>>>>
>>>> Exception in thread "main" org.RDKit.MolSanitizeException
>>>>     at org.RDKit.RDKFuncsJNI.RWMol_MolFromSmiles__SWIG_3(Native Method)
>>>>     at org.RDKit.RWMol.MolFromSmiles(RWMol.java:422)
>>>>
>>>>  Thanks in advance!
>>>> Matt
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Time is money. Stop wasting it! Get your web API in 5 minutes.
>>>> www.restlet.com/download
>>>> http://p.sf.net/sfu/restlet
>>>> _______________________________________________
>>>> Rdkit-discuss mailing list
>>>> Rdkit-discuss@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>>>
>>>>
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> Learn Graph Databases - Download FREE O'Reilly Book
>> "Graph Databases" is the definitive new guide to graph databases and their
>> applications. Written by three acclaimed leaders in the field,
>> this first edition is now available. Download your free book 
>> today!http://p.sf.net/sfu/NeoTech
>>
>>
>>
>> _______________________________________________
>> Rdkit-discuss mailing 
>> listRdkit-discuss@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>
>>
>>
>
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their 
applications. Written by three acclaimed leaders in the field, 
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to