Hi,
Thanks for the pointers and taking to time to read and respond to my questions. This is what I was doing before, however, despite all the on-line docs and the help from the RDKit Docs, there is nothing mentioned about capturing the WARNINGS adequately from the program, although I see that some years ago there was a thread about this, but it was never addressed to completeness. The issue is that RDkit at the cmd line generates WANRING: Omitted undefined stereo and other related warnings, these messages are not going to stderr or stdout. There is a way to change the log reporting, that didn’t seem to work either. Thoughts and suggestions are welcome – code snippets are gratefully accepted. I’ve enclosed the challenging SDF if anyone wants to have a play. Cheers, mike From: Lukas Pravda <lpra...@ebi.ac.uk> Sent: 26 September 2019 00:20 To: Brian Lee <brian.kihoon....@gmail.com>; mi...@novadatasolutions.co.uk Cc: RDKIT mailing list <rdkit-discuss@lists.sourceforge.net> Subject: Re: [Rdkit-discuss] Fwd: sending warnings to stderr/stdout to files That’s true, but I always hated ‘do your homework’ kind of answers, especially when I was completely lost and did not know where to start from (which may not be your case). import sys from rdkit import Chem saved_std_err = sys.stderr log = sys.stderr = open('test_log.log', mode='w') Chem.WrapLogs() mol = Chem.MolFromSmiles('c1ccccc1(C)(C)') log.close() sys.stderr = saved_std_err works Lukas From: Brian Lee <brian.kihoon....@gmail.com <mailto:brian.kihoon....@gmail.com> > Date: Wednesday, 25 September 2019 at 20:55 To: <mi...@novadatasolutions.co.uk <mailto:mi...@novadatasolutions.co.uk> > Cc: RDKIT mailing list <rdkit-discuss@lists.sourceforge.net <mailto:rdkit-discuss@lists.sourceforge.net> >, Lukas Pravda <lpra...@ebi.ac.uk <mailto:lpra...@ebi.ac.uk> > Subject: Re: [Rdkit-discuss] Fwd: sending warnings to stderr/stdout to files This isn't so much an RDKit question as it is a python IO question. I'd look into the docs at https://docs.python.org/3/library/io.html as a starting point. On Wed, Sep 25, 2019 at 2:13 AM <mi...@novadatasolutions.co.uk <mailto:mi...@novadatasolutions.co.uk> > wrote: Hi. Yes this works for me as per the RDKit docs. But I need to pipe it to a file, any suggestions? Thanks. Mike Get Outlook for Android <https://aka.ms/ghei36> On Tue, Sep 24, 2019 at 10:28 PM +0100, "Lukas Pravda" <lpra...@ebi.ac.uk <mailto:lpra...@ebi.ac.uk> > wrote: Hi Mike, The following code works for me: import sys from io import StringIO from rdkit import Chem saved_std_err = sys.stderr log = sys.stderr = StringIO() Chem.WrapLogs() # do whatever you want with rdkit whatever_used_to_be_printed_by_rdkit_in_console_as_str = log.getvalue() sys.stderr = saved_std_err This populated the stream in memory, if you replace StringIO with FileIO I think you can directly redirect it to file, but have not tested that. Let me know if this works for you. Lukas From: <mi...@novadatasolutions.co.uk <mailto:mi...@novadatasolutions.co.uk> > Date: Tuesday, 24 September 2019 at 16:52 To: RDKIT mailing list <rdkit-discuss@lists.sourceforge.net <mailto:rdkit-discuss@lists.sourceforge.net> > Subject: [Rdkit-discuss] Fwd: sending warnings to stderr/stdout to files Hi Rdkit forum, Easy question, perhaps difficult to answer… I’ve been reading a lot of support messages, many a very old about how to get warnings (only visible at the cmd line) to be send to files. I can get error messages sent, but not warnings. The type I’m trying to capture are – which I can see when I run code at the cmd line, but not in jupyter-notebook. “charges were rearranged” “Omitted undefined stereo” Ideally I’d like to run the code in jupyter-notebook and also at the cmd line with python script.py etc and get the warnings into a file. Can you provide me with a simple example as to how to do this? Thanks, mike Error! Filename not specified. Dr Mike Mazanetz, FRSC Director Honorary Lecturer School of Natural and Computing Sciences University of Aberdeen +44 (0) 141 533 0930 +44 (0) 7780 672509 mi...@novadatasolutions.co.uk <mailto:mi...@novadatasolutions.co.uk> www.novadatasolutions.co.uk <http://www.novadatasolutions.co.uk/> skype michael.mazanetz NovaData Solutions Ltd. PO Box 639 Abingdon-on-Thames Oxfordshire OX14 9JD United Kingdom _______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net <mailto:Rdkit-discuss@lists.sourceforge.net> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss _______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net <mailto:Rdkit-discuss@lists.sourceforge.net> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
SDF Test_Concat.sdf
Description: chemical/mdl-sdfile
_______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss