I don't have a problematic sdf file to try, as I was reading smiles strings.
A bad smiles string returned None rather than a molecule object (as well as generating a warning). I assume the sdf reader does the same? I was only interested in filtering out bad smiles so I used: if mol is not None: Not sure how to capture the actual warning message. ==================== Dr. Steve O'Hagan, -----Original Message----- From: Jean-Marc Nuzillard [mailto:jm.nuzill...@univ-reims.fr] Sent: 21 January 2019 13:24 To: RDKit Discuss <rdkit-discuss@lists.sourceforge.net> Subject: Re: [Rdkit-discuss] Warning as error My problem is more to know which molecules cause problems than avoiding the printing of warning messages in the console window. I am looking for an option that would turn warnings into errors, if any. Jean-Marc Le 21/01/2019 à 13:44, Stephen O'hagan a écrit : > I've had similar problems; none of the claimed methods to switch off RDKit > logging of warnings has worked for me. > > I ended up just re-directing stderr when running the script like this: > > python myfile.py 2> myErrorLog.txt > > ==================== > Dr. Steve O'Hagan, > > > -----Original Message----- > From: Jean-Marc Nuzillard [mailto:jm.nuzill...@univ-reims.fr] > Sent: 21 January 2019 12:33 > To: RDKit Discuss <rdkit-discuss@lists.sourceforge.net> > Subject: [Rdkit-discuss] Warning as error > > Dear all, > > The minimalist python code: > reader = Chem.SDMolSupplier('my_file.sdf') > for mol in reader: > pass > > gives me warning messages when run on a particular SD file. > How can I simply run a specific action for the molecules that cause problem, > possibly using try/catch statements? > Best, > > Jean-Marc > > > -- > Jean-Marc Nuzillard > Directeur de Recherches au CNRS > > Institut de Chimie Moléculaire de Reims CNRS UMR 7312 Moulin de la > Housse CPCBAI, Bâtiment 18 BP 1039 > 51687 REIMS Cedex 2 > France > > Tel : 03 26 91 82 10 > Fax : 03 26 91 31 66 > http://www.univ-reims.fr/ICMR > http://eos.univ-reims.fr/LSD/CSNteam.html > > http://www.univ-reims.fr/LSD/ > http://www.univ-reims.fr/LSD/JmnSoft/ > > > --- > L'absence de virus dans ce courrier électronique a été vérifiée par le > logiciel antivirus Avast. > https://www.avast.com/antivirus > > > > _______________________________________________ > Rdkit-discuss mailing list > Rdkit-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss -- Jean-Marc Nuzillard Directeur de Recherches au CNRS Institut de Chimie Moléculaire de Reims CNRS UMR 7312 Moulin de la Housse CPCBAI, Bâtiment 18 BP 1039 51687 REIMS Cedex 2 France Tel : 03 26 91 82 10 Fax : 03 26 91 31 66 http://www.univ-reims.fr/ICMR http://eos.univ-reims.fr/LSD/CSNteam.html http://www.univ-reims.fr/LSD/ http://www.univ-reims.fr/LSD/JmnSoft/ _______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss _______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss