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> 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 :
> <#m_1193168595555706688_rdkit.Chem.rdmolfiles.ForwardSDMolSupplier>
>
> 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
> 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

Reply via email to