Re: [Rdkit-discuss] Ridiculously easy problem - capture RDKit's error messages
Open-Source Cheminformatics and Machine Learning
Brought to you by:
glandrum
From: Greg L. <gre...@gm...> - 2015-01-23 15:14:22
|
Hi JP, Unfortunately this is a gap in the RDKit's logging functionality. There's really no way to do this at the moment without starting your python job in another process and capturing its output to stderr. There is a "todo" item to switch to using a better logging solution in the c++ backend, but I haven't made any progress on that yet. -greg On Fri, Jan 23, 2015 at 8:58 AM, JP <jea...@in...> wrote: > > Yo RDKitters, > > I am stuck on something so basic, its embarrassing. But for the life of > me I cannot figure it out on my own. This is probably more of a python > question than an RDKit one. > > I want to capture the RDKit warning/error message from python. e.g. > > >>> import rdkit > >>> from rdkit import Chem > >>> Chem.MolFromSmiles('XXX') > [14:51:32] SMILES Parse Error: syntax error for input: XXX > > I want to capture that error message (which in this case isn't very > informative, but if you read in a mol2 you can get something like > [14:25:46] 3ZGZ.A: warning - O.co2 with non C.2 or S.o2 neighbor. Which I > am also interested in). The big picture is that I built a web up where you > upload an sdf, mol, mol2 or smi file - and I want to show RDKit's error > message if there something funny in the query file. > > I have tried the obvious (I think): > > #!/usr/bin/env python > import sys > import rdkit > from rdkit import Chem > > f = open("err.log", "w") > original_stderr = sys.stderr > sys.stderr = f > Chem.MolFromSmiles('XXX') > sys.stderr = original_stderr > f.close() > > This still shows the error message in the terminal and not in the file. I > tried the same for stdout, still no cigar. > > Any ideas ? > > THANKS! > JP > > > ------------------------------------------------------------------------------ > New Year. New Location. New Benefits. New Data Center in Ashburn, VA. > GigeNET is offering a free month of service with a new server in Ashburn. > Choose from 2 high performing configs, both with 100TB of bandwidth. > Higher redundancy.Lower latency.Increased capacity.Completely compliant. > http://p.sf.net/sfu/gigenet > _______________________________________________ > Rdkit-discuss mailing list > Rdk...@li... > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss > > |