Hi Greg, I just omitted the from rdkit import Chem. This is the full code (I tried doing it in console):
from rdkit import Chem from rdkit.Chem import rdmolfiles import gzip suppl = ForwardSDMolSupplier(gzip.open('G:\Joanna\RDC\rdkit gz files\pubchem-compound-rnd-1k.sdf.gz')) Traceback (most recent call last): File "<ipython-input-15-0da953541062>", line 1, in <module> suppl = ForwardSDMolSupplier(gzip.open('G:\Joanna\RDC\rdkit gz files\pubchem-compound-rnd-1k.sdf.gz')) NameError: name 'ForwardSDMolSupplier' is not defined I tried using your suggestion, and this is what appeared: from rdkit import Chem suppl = Chem.ForwardSDMolSupplier(gzip.open('G:\Joanna\RDC\rdkit gz files\pubchem-compound-rnd-1k.sdf.gz')) Traceback (most recent call last): File "<ipython-input-24-6d5cbe646b63>", line 1, in <module> suppl = Chem.ForwardSDMolSupplier(gzip.open('G:\Joanna\RDC\rdkit gz files\pubchem-compound-rnd-1k.sdf.gz')) File "D:\Anaconda3\lib\gzip.py", line 58, in open binary_file = GzipFile(filename, gz_mode, compresslevel) File "D:\Anaconda3\lib\gzip.py", line 168, in __init__ fileobj = self.myfileobj = builtins.open(filename, mode or 'rb') OSError: [Errno 22] Invalid argument: 'G:\\Joanna\\RDC\rdkit gz files\\pubchem-compound-rnd-1k.sdf.gz' What actually worked was using a '/' instead of '\'. At least this is only applicable in Spyder4 IDE. Maybe the back slash works in other IDEs. Thank you for the assistance. Joanna ________________________________ From: Greg Landrum <greg.land...@gmail.com> Sent: Thursday, July 9, 2020 10:42 AM To: ITS RDC <itsrdc...@outlook.com> Cc: rdkit-discuss@lists.sourceforge.net <rdkit-discuss@lists.sourceforge.net> Subject: Re: [Rdkit-discuss] ForwardSDMolSupplier function Hi Joanna, The usual way to do this is something like: from rdkit import Chem suppl = Chem.ForwardSDMolSupplier(gzip.open('G:\Joanna\RDC\rdkit gz files\pubchem-compound-rnd-1k.sdf.gz')) -greg On Thu, Jul 9, 2020 at 4:22 AM ITS RDC <itsrdc...@outlook.com<mailto:itsrdc...@outlook.com>> wrote: Hi all/Greg, I have a database of sdf.gz files and I want to gzip it in Windows. From the manual, ForwardSDMolSupplier is found in Chem.rdmolfiles of the 2020.03.01 verson. class rdkit.Chem.rdmolfiles.ForwardSDMolSupplier((object)arg1, (AtomPairsParameters)fileobj[, (bool)sanitize=True[, (bool)removeHs=True[, (bool)strictParsing=True]]]) → None : Bases: Boost.Python.instance A class which supplies molecules from file-like object containing SD data. Usage examples: 1. Lazy evaluation: the molecules are not constructed until we ask for them: >>> suppl = ForwardSDMolSupplier(file('in.sdf')) >>> for mol in suppl: ... if mol is not None: mol.GetNumAtoms() 2. we can also read from compressed files: >>> import gzip >>> suppl = ForwardSDMolSupplier(gzip.open('in.sdf.gz')) >>> for mol in suppl: ... if mol is not None: print mol.GetNumAtoms() Then when I tried it in Spyder 4, this appeared: suppl = ForwardSDMolSupplier(gzip.open('G:\Joanna\RDC\rdkit gz files\pubchem-compound-rnd-1k.sdf.gz')) Traceback (most recent call last): File "<ipython-input-15-0da953541062>", line 1, in <module> suppl = ForwardSDMolSupplier(gzip.open('G:\Joanna\RDC\rdkit gz files\pubchem-compound-rnd-1k.sdf.gz')) NameError: name 'ForwardSDMolSupplier' is not defined I traced the location of rdmolfiles, but it is in pyd so I cannot check if the function was encoded there. I was tracing the location of ForwardSDMolSupplier and I found something in a folder under the "Chem" class folder named "Supplier" but I am not sure if I am in the right direction. I could not locate the location of the function so maybe someone can help me out so I can call out the right subclass. Thank you. Joanna _______________________________________________ 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 https://lists.sourceforge.net/lists/listinfo/rdkit-discuss