You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you are using conda, which channel did you install the rdkit from? Conda Forge
If you are not using conda: how did you install the RDKit?
Description:
This is a weird one :)
SDMolSupplier needs two iterations on the supplier instance to get the molecules loaded on Python 3.6 and 3.7. Python 3.8 does not exhibit this problem.
The text was updated successfully, but these errors were encountered:
jaimergp
changed the title
SDMolSupplier requires several attempts to load a SDF file in Python 3.6
SDMolSupplier requires several attempts to load a SDF file in Python 3.6/3.7
Oct 21, 2020
@jaimergp I will investigate more in-depth over the weekend. For now I guess the reason is that the SDMolSupplier wrapper exposes a random access container to Python, while it does not 100% fulfil Python requirements for iterators.
For the time being, here are some workarounds:
import sys
import rdkit
from rdkit.Chem import SDMolSupplier, ForwardSDMolSupplier
print("System:", sys.platform)
print("Python:", ".".join(map(str, sys.version_info)))
print("RDKit:", rdkit.__version__)
System: linux
Python: 3.6.10.final.0
RDKit: 2021.03.1dev1
supplier = SDMolSupplier("/home/toscopa1/sdf/chembl100.sdf")
mols = list(supplier)
len(mols)
0
# Use ForwardSDMolSupplier
supplier = ForwardSDMolSupplier("/home/toscopa1/sdf/chembl100.sdf")
mols = list(supplier)
len(mols)
100
# Use ForwardSDMolSupplier
supplier = ForwardSDMolSupplier("/home/toscopa1/sdf/chembl100.sdf")
mols = tuple(supplier)
len(mols)
100
# Explicitly iterate with a list comprehension
supplier = SDMolSupplier("/home/toscopa1/sdf/chembl100.sdf")
mols = [m for m in supplier]
len(mols)
100
# Explicitly iterate with a map
supplier = SDMolSupplier("/home/toscopa1/sdf/chembl100.sdf")
mols = list(map(lambda m: m, supplier))
len(mols)
100
Oh, I see. ForwardSDMolSupplier seems to be the way to go. We were using a plain comprehension before and it worked, but it was refactored into that list(...) call for simplicity. Interesting 🤔 Thanks for looking into it!
ptosco
added a commit
to ptosco/rdkit
that referenced
this issue
Oct 24, 2020
Configuration:
Description:
This is a weird one :)
SDMolSupplier
needs two iterations on the supplier instance to get the molecules loaded on Python 3.6 and 3.7. Python 3.8 does not exhibit this problem.Python 3.6 🚫
Python 3.7 🚫
Python 3.8 ✅
Python 3.9 ✅
Zipped sample SDF: sample.zip
Thanks!
The text was updated successfully, but these errors were encountered: