Re: [Rdkit-discuss] Can't stifle warnings / logs
Hi Cameron, While you are waiting for an answer about the proper way to silence errors, I can give you a work-around which will help with the metaphorical reams of teletype paper you are printing out. However, it is a very crude solution. Basically, close the C/C++ stderr file descriptor, and tell Python to route its error messages to a new stderr. # Copy the stderr descriptor new_fd = os.dup(2) # Close the original stderr os.close(2) # Tell Python about the new stderr sys.__stderr__ = sys.stderr = os.fdopen(new_fd, "w", 0) Here it is in context: import os import sys from rdkit import Chem print("Error?") Chem.MolFromSmiles("Q") # error message # Copy the stderr descriptor new_fd = os.dup(2) # Close the original stderr os.close(2) # Tell Python about the new stderr sys.__stderr__ = sys.stderr = os.fdopen(new_fd, "w", 0) print("Error again?") Chem.MolFromSmiles("Q") # No warning or error message. This assumes that neither RDKit nor some other code at the C level write directly to file descriptor 2 assuming it's stderr. Otherwise there's a problem if you ever open up a new file and it's assigned fd 2. If you *really* want to be sure that C/C++ code doesn't write to stderr, and the above doesn't work, and you are on a Unix-like system, then add the following after the "sys.__stderr__ = .." line: # Reroute the original descriptor number 2 to /dev/null fd2 = os.open("/dev/null", os.O_WRONLY) if fd2 != 2: raise SystemExit("Unable to reroute file descriptor 2: %d\n" % (fd2,)) Andrew da...@dalkescientific.com -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
[Rdkit-discuss] Can't stifle warnings / logs
Hi There, I'm a longtime rdkit user but a first time mailing list user. One thing that has always haunted me is the warnings and errors that get thrown whilst reading in a dirty sd file or smiles list. I've tried to no avail to silence the warnings and errors many times and normally just live with the endless scroll on my terminal but today I've finally had enough. Any help would be appreciated!! I've tried wrapping a ForwardSDMolSupplier with the following : from io import StringIO import sys Chem.WrapLogs() def silent_supplier(supplier): sio = sys.stderr = StringIO() for m in supplier: sio = sys.stderr = StringIO() if m is None: continue else: yield m but still get a stream of these sorts of errors: [11:39:24] S group DAT ignored on line 143364 [11:39:24] Can't kekulize mol. Unkekulized atoms: 5 6 7 8 9 10 11 13 14 [11:39:24] ERROR: Could not sanitize molecule ending on line 143370 [11:39:24] ERROR: Can't kekulize mol. Unkekulized atoms: 5 6 7 8 9 10 11 13 14 [11:39:24] S group DAT ignored on line 145111 [11:39:24] Can't kekulize mol. Unkekulized atoms: 3 4 5 6 26 [11:39:24] ERROR: Could not sanitize molecule ending on line 145117 [11:39:24] ERROR: Can't kekulize mol. Unkekulized atoms: 3 4 5 6 26 [11:39:24] S group DAT ignored on line 159380 [11:39:24] Can't kekulize mol. Unkekulized atoms: 5 6 7 8 9 10 11 12 13 [11:39:24] ERROR: Could not sanitize molecule ending on line 159386 [11:39:24] ERROR: Can't kekulize mol. Unkekulized atoms: 5 6 7 8 9 10 11 12 13 -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Re: [Rdkit-discuss] mmpdb installation on windows using mingw
Hi Markus, thanks for pointing this out. The reason for that error message is that signal.SIGPIPE is not available under windows. This seems to have slipped below our radar, since we developed the code on Linux. There is a simple solution to this: In the mmpdb file, one needs to import os and then change the error-causing line to: if not os.name=="nt": signal.signal(signal.SIGPIPE, signal.SIG_DFL) That solves the problem on my window laptop. I will add this and update mmpdb in the repo asap. Bests, Christian *Dr. Christian Kramer* Computer-Aided Drug Design (CADD) Scientist F. Hoffmann-La Roche Ltd Pharma Research and Early Development Bldg. 092/3.56 C CH-4070 Basel Phone +41 61 682 2471 mailto: christian.kra...@roche.com *Confidentiality Note: *This message is intended only for the use of the named recipient(s) and may contain confidential and/or proprietary information. If you are not the intended recipient, please contact the sender and delete this message. Any unauthorized use of the information contained in this message is prohibited. On Fri, Sep 22, 2017 at 2:01 PM, Peter Gedeckwrote: > Here is a relevant stackoverflow question. > > https://stackoverflow.com/questions/1948862/is-the- > python-3-x-signal-library-for-windows-incomplete > > What happens if you comment out the code if you run on windows? > > Best > > Peter > On Fri, Sep 22, 2017 at 7:25 AM Markus Metz wrote: > >> Hello Christian: >> >> I am trying to install your program and get the following error message: >> >> $ mmpdb help-analysis >> Traceback (most recent call last): >> File "C:/Users/---/Anaconda3/envs/my-rdkit-env/Scripts/mmpdb", line 8, >> in >> signal.signal(signal.SIGPIPE, signal.SIG_DFL) # Allow the output pipe >> to be closed >> AttributeError: module 'signal' has no attribute 'SIGPIPE' >> >> Not sure what to do about it. Any input would be greatly appreciated. >> >> Cheers, >> Markus >> >> >> -- >> Check out the vibrant tech community on one of the world's most >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot__ >> _ >> Rdkit-discuss mailing list >> Rdkit-discuss@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss >> > > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > ___ > Rdkit-discuss mailing list > Rdkit-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss > > -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Re: [Rdkit-discuss] mmpdb installation on windows using mingw
Here is a relevant stackoverflow question. https://stackoverflow.com/questions/1948862/is-the-python-3-x-signal-library-for-windows-incomplete What happens if you comment out the code if you run on windows? Best Peter On Fri, Sep 22, 2017 at 7:25 AM Markus Metzwrote: > Hello Christian: > > I am trying to install your program and get the following error message: > > $ mmpdb help-analysis > Traceback (most recent call last): > File "C:/Users/---/Anaconda3/envs/my-rdkit-env/Scripts/mmpdb", line 8, > in > signal.signal(signal.SIGPIPE, signal.SIG_DFL) # Allow the output pipe > to be closed > AttributeError: module 'signal' has no attribute 'SIGPIPE' > > Not sure what to do about it. Any input would be greatly appreciated. > > Cheers, > Markus > > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > ___ > Rdkit-discuss mailing list > Rdkit-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss > -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
[Rdkit-discuss] mmpdb installation on windows using mingw
Hello Christian: I am trying to install your program and get the following error message: $ mmpdb help-analysis Traceback (most recent call last): File "C:/Users/---/Anaconda3/envs/my-rdkit-env/Scripts/mmpdb", line 8, in signal.signal(signal.SIGPIPE, signal.SIG_DFL) # Allow the output pipe to be closed AttributeError: module 'signal' has no attribute 'SIGPIPE' Not sure what to do about it. Any input would be greatly appreciated. Cheers, Markus -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss