Adapting from https://github.com/rdkit/rdkit/issues/642 I wrote:
reader = Chem.SDMolSupplier(file_sdf, sanitize = False)
for mol in reader:
try:
Chem.SanitizeMol(mol)
except:
sys.stderr.write("Bad: %s\n" % (mol.GetProp("_Name"),))
continue
A good point is that this code does not produce any warning, and that it
does
when I remove the "sanitize = False" option.
However Chem.SanitizeMol(mol) never raises an error,
unless something is missing in my try/except statements.
The warning message I want to track is:
[19:58:01] Conflicting single bond directions around double bond at
index 27.
[19:58:01] BondStereo set to STEREONONE and single bond directions set
to NONE.
I know which bond has a problem but I still do not know in which molecule.
Jean-Marc
PS. Markus, sorry for the duplicated message.
Le 21/01/2019 à 14:55, Markus Sitzmann a écrit :
Maybe this helps (at least, it is from Greg):
https://github.com/rdkit/rdkit/issues/642
Markus
On Mon, Jan 21, 2019 at 2:25 PM Jean-Marc Nuzillard
<jm.nuzill...@univ-reims.fr <mailto:jm.nuzill...@univ-reims.fr>> wrote:
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
<mailto:jm.nuzill...@univ-reims.fr>]
> Sent: 21 January 2019 12:33
> To: RDKit Discuss <rdkit-discuss@lists.sourceforge.net
<mailto: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
<mailto: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
<mailto: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/
---
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