Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDKit failures if molgrid is imported first #65

Open
RMeli opened this issue Jul 1, 2021 · 5 comments
Open

RDKit failures if molgrid is imported first #65

RMeli opened this issue Jul 1, 2021 · 5 comments

Comments

@RMeli
Copy link
Member

RMeli commented Jul 1, 2021

I encountered an odd incompatibility between molgrid and rdkit which seems to depend on the order of import statements. I installed molgrid using pip in a conda environment where rdkit has been installed from the conda-forge channel.


The following snippet works as expected:

from rdkit import Chem
from rdkit.Chem import AllChem

m = Chem.MolFromSmiles('C1CCC1OC')
m2 = Chem.AddHs(m)
cids = AllChem.EmbedMultipleConfs(m2, numConfs=2)

If molgrid is imported before rdkit

import molgrid
from rdkit import Chem
from rdkit.Chem import AllChem

m = Chem.MolFromSmiles('C1CCC1OC')
m2 = Chem.AddHs(m)
cids = AllChem.EmbedMultipleConfs(m2, numConfs=2)

I get the following failure on the last line (EmbedMultipleConfs call):

TypeError: No to_python (by-value) converter found for C++ type: std::vector<int, std::allocator<int> >

The error does not appear if molgrid is imported after rdkit:

from rdkit import Chem
from rdkit.Chem import AllChem
import molgrid

m = Chem.MolFromSmiles('C1CCC1OC')
m2 = Chem.AddHs(m)
cids = AllChem.EmbedMultipleConfs(m2, numConfs=2)

conda environment to reproduce the issue:

name: rdkit-molgrid
channels:
  - conda-forge
  - pytorch
dependencies:
  - python=3.7
  - ipython
  - pip

  - rdkit=2021.03.3
  - cudatoolkit=11.1
  - pytorch

  - pip:
    - molgrid==0.2.1
@dkoes
Copy link
Contributor

dkoes commented Sep 14, 2021

Can you check to see if this is still a problem with 0.5.1?

@RMeli
Copy link
Member Author

RMeli commented Sep 14, 2021

By upgrading molgrid with python -m pip install -U molgrid the problem seems to persist. I'll try to re-build the whole conda environment.

I tried to run the same script within a Singularity container where molgrid==0.2.1 and rdkit==2021_03_1 are compiled from source and there is no such problem.

@dkoes
Copy link
Contributor

dkoes commented Sep 14, 2021

It may depend on what version of boost-python rdkit was built with.

@RMeli
Copy link
Member Author

RMeli commented Sep 14, 2021

Yes, probably a similar problem to #62.

@dkoes
Copy link
Contributor

dkoes commented Sep 14, 2021

Not really. #62 is a problem because I am relying on bit-for-bit compatibility with openbabel data structures. The issue here is the way rdkit/boost-python are adding symbols to the python environment. I'm 80% sure the correct fix involves changed rdkit, not molgrid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants