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

TypeError: in method 'new_OBMol' #165

Open
ichxw opened this issue Nov 22, 2022 · 2 comments
Open

TypeError: in method 'new_OBMol' #165

ichxw opened this issue Nov 22, 2022 · 2 comments

Comments

@ichxw
Copy link

ichxw commented Nov 22, 2022

I got an error when trying to run the following lines:

import oddt
from rdkit import Chem
from rdkit.Chem import AllChem
smi = 'c1ccccc1NCC(=O)OCCCC'
mol = Chem.MolFromSmiles(smi)
mol = Chem.AddHs(mol)
AllChem.EmbedMultipleConfs(mol, numConfs = 1, numThreads = 1, randomSeed=42)
mol = oddt.toolkit.Molecule(mol)
mol_conf = oddt.toolkits.rdk.diverse_conformers_generator(mol, n_conf=10, method='etkdg', seed=42, rmsd=0.2)

The error message was:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/xzhu/.conda/envs/my-rdkit-env/lib/python3.8/site-packages/oddt/toolkits/rdk.py", line 1217, in diverse_conformers_generator
    mol_clone = mol.clone
  File "/home/xzhu/.conda/envs/my-rdkit-env/lib/python3.8/site-packages/oddt/toolkits/ob.py", line 407, in clone
    return Molecule(ob.OBMol(self.OBMol))
  File "/home/xzhu/.conda/envs/my-rdkit-env/lib/python3.8/site-packages/openbabel/openbabel.py", line 2273, in __init__
    _openbabel.OBMol_swiginit(self, _openbabel.new_OBMol(*args))
TypeError: in method 'new_OBMol', argument 1 of type 'OpenBabel::OBMol const &'
Additional information:
Wrong number or type of arguments for overloaded function 'new_OBMol'.
  Possible C/C++ prototypes are:
    OpenBabel::OBMol::OBMol()
    OpenBabel::OBMol::OBMol(OpenBabel::OBMol const &)

I ran them in python 3.8 on Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-52-generic x86_64). Below are version of some libraries.

>>> babel.__version__
'2.11.0'
>>> rdkit.__version__
'2021.03.1b1'
>>> oddt.__version__
'0.7'

What could be the possible reasons?
Thank you.

@mwojcikowski
Copy link
Contributor

You should be using RDKit flavor of oddt's Molecule. The following change will fix the code.

...
mol = oddt.toolkits.rdk.Molecule(mol)
...

@ichxw
Copy link
Author

ichxw commented Apr 10, 2023

Got it. Thanks a lot.

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