-
Notifications
You must be signed in to change notification settings - Fork 11
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
[BUG] Issue merging small molecules #116
Comments
Thanks for reporting. I think from the stack trace that something is going wrong with the transfer of the RDKit shared pointer from C++ up to Python. This is in the sire layer, so I've transferred the issue across to this repo so I can debug and track this here. The wrapping of the RDKit shared pointer is, I think, handled by RDKit. Could you let me know what version of RDKit you have installed? Do this by running;
I get We're going to release |
Just to say that I've also tested locally on Linux (Python 3.11) and it's working for me too. I have: In [1]: import rdkit
In [2]: rdkit.__version__
Out[2]: '2023.09.1' |
I've pushed a commit to the I'll know once I can reproduce the issue locally. |
I think this will fix it. Looking at the RDKit source code, they mix For example, here they define while in the Python wrapping code here they expose the Python wrapper using That code has been there for a long time - git blame shows;
So I am not sure how this has even been working? Note that they use All I can guess is that somewhere else, they were exposing the My fix here won't break anything, as wrapping this twice is not a problem (beside a boost::python warning about a duplicate wrap). Including the wrap here will make sure that the code works for versions of RDKit that do provide the wrap, and versions that don't (since we use |
Hi @chryswoods, @lohedges Thanks for both your replies. import rdkit
print(rdkit.__version__)
2023.03.3 Were either of you able to reproduce this issue eventually? I've just tried again using the code block above and the input files and I'm definitely getting the same error. I tried to install the sire branch fix_116 in a new env:
But when installing BioSimSpace afterwards with
And so I've been unable to test the fix. How do you suggest installing BSS with a custom compiled sire version? Do I also need to build BSS from source rather than using a package manager? |
HI @noahharrison64. After the Sire install you can install BioSimSpace into the environment and skip the installation of dependencies as follows: BSS_SKIP_DEPENDENCIES=1 python setup.py install |
Could you try running only using sire? e.g.
When I run this I get
which shows that it is working. |
In the new python env with sire installed from source and on the 'fix_116' branch (version 2023.5.0.dev) ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in <module>:1 │
│ │
│ /root/miniforge3/envs/biosimspace_v23_sire_update/lib/python3.9/site-packages/sire/convert/__ini │
│ t__.py:66 in to │
│ │
│ 63 │ if format == "sire": │
│ 64 │ │ return to_sire(obj, map=map) │
│ 65 │ elif format == "rdkit": │
│ ❱ 66 │ │ return to_rdkit(obj, map=map) │
│ 67 │ elif format == "biosimspace": │
│ 68 │ │ return to_biosimspace(obj, map=map) │
│ 69 │ elif format == "openmm": │
│ │
│ /root/miniforge3/envs/biosimspace_v23_sire_update/lib/python3.9/site-packages/sire/convert/__ini │
│ t__.py:181 in to_rdkit │
│ │
│ 178 │ Convert the passed object from its current object format to a │
│ 179 │ rdkit object format. │
│ 180 │ """ │
│ ❱ 181 │ return sire_to_rdkit(to_sire(obj, map=map), map=map) │
│ 182 │
│ 183 │
│ 184 def to_openmm(obj, map=None): │
│ │
│ /root/miniforge3/envs/biosimspace_v23_sire_update/lib/python3.9/site-packages/sire/convert/__ini │
│ t__.py:427 in sire_to_rdkit │
│ │
│ 424 │ │
│ 425 │ from ..base import create_map │
│ 426 │ │
│ ❱ 427 │ mols = _sire_to_rdkit(obj, map=create_map(map)) │
│ 428 │ │
│ 429 │ if mols is None: │
│ 430 │ │ return None │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: No Python class registered for C++ class RDKit::ROMol On the original env I was using (2023.4.0) ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /mnt/notebooks/development/mdynamics/pyscript.py:5 in <module> │
│ │
│ 2 │
│ 3 mols = sr.load("ejm31.sdf") │
│ 4 │
│ ❱ 5 rdmol = sr.convert.to(mols, "rdkit") │
│ 6 │
│ 7 print(rdmol) │
│ 8 │
│ │
│ /root/miniforge3/envs/biosimspace_v23_4/lib/python3.9/site-packages/sire/convert/__init__.py:66 │
│ in to │
│ │
│ 63 │ if format == "sire": │
│ 64 │ │ return to_sire(obj, map=map) │
│ 65 │ elif format == "rdkit": │
│ ❱ 66 │ │ return to_rdkit(obj, map=map) │
│ 67 │ elif format == "biosimspace": │
│ 68 │ │ return to_biosimspace(obj, map=map) │
│ 69 │ elif format == "openmm": │
│ │
│ /root/miniforge3/envs/biosimspace_v23_4/lib/python3.9/site-packages/sire/convert/__init__.py:181 │
│ in to_rdkit │
│ │
│ 178 │ Convert the passed object from its current object format to a │
│ 179 │ rdkit object format. │
│ 180 │ """ │
│ ❱ 181 │ return sire_to_rdkit(to_sire(obj, map=map), map=map) │
│ 182 │
│ 183 │
│ 184 def to_openmm(obj, map=None): │
│ │
│ /root/miniforge3/envs/biosimspace_v23_4/lib/python3.9/site-packages/sire/convert/__init__.py:427 │
│ in sire_to_rdkit │
│ │
│ 424 │ │
│ 425 │ from ..base import create_map │
│ 426 │ │
│ ❱ 427 │ mols = _sire_to_rdkit(obj, map=create_map(map)) │
│ 428 │ │
│ 429 │ if mols is None: │
│ 430 │ │ return None │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: No to_python (by-value) converter found for C++ type: boost::shared_ptr<RDKit::ROMol> When I try and run the code block above (i.e. merging the mols) I get the following error, which I assume is because I followed @lohedges advice on skipping BSS install dependencies: ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in <module>:1 │
│ │
│ ❱ 1 import BioSimSpace as BSS │
│ 2 paramd = [] │
│ 3 for filebase in ['ejm31', 'ejm42']: │
│ 4 │ mol = BSS.IO.readMolecules([f"input_folder/{filebase}.sdf"]) │
│ │
│ /root/miniforge3/envs/biosimspace_v23_sire_update/lib/python3.9/site-packages/BioSimSpace-2023.5 │
│ .0.dev0-py3.9.egg/BioSimSpace/__init__.py:240 in <module> │
│ │
│ 237 from . import Align │
│ 238 from . import Box │
│ 239 from . import Convert │
│ ❱ 240 from . import FreeEnergy │
│ 241 from . import Gateway │
│ 242 from . import IO │
│ 243 from . import Metadynamics │
│ │
│ /root/miniforge3/envs/biosimspace_v23_sire_update/lib/python3.9/site-packages/BioSimSpace-2023.5 │
│ .0.dev0-py3.9.egg/BioSimSpace/FreeEnergy/__init__.py:43 in <module> │
│ │
│ 40 │ getData │
│ 41 """ │
│ 42 │
│ ❱ 43 from ._relative import * │
│ 44 from ._utils import * │
│ 45 │
│ │
│ /root/miniforge3/envs/biosimspace_v23_sire_update/lib/python3.9/site-packages/BioSimSpace-2023.5 │
│ .0.dev0-py3.9.egg/BioSimSpace/FreeEnergy/_relative.py:111 in <module> │
│ │
│ 108 │ │ _os.path.normpath(_getShareDir()), "scripts", "analyse_freenrg.py" │
│ 109 │ ) │
│ 110 if not _os.path.isfile(_analyse_freenrg): │
│ ❱ 111 │ raise _MissingSoftwareError( │
│ 112 │ │ "Cannot find free energy analysis script in expected location: '%s'" │
│ 113 │ │ % _analyse_freenrg │
│ 114 │ ) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
MissingSoftwareError: Cannot find free energy analysis script in expected location:
'/root/miniforge3/envs/biosimspace_v23_sire_update/bin/analyse_freenrg' |
That doesn't make sense, since you've already installed Sire, which provides the script that it says is missing. |
Alright I'll try another fresh install , things may have got mixed up after I removed BSS/Sire following the mamba install I described above
|
Something looks like it has gone wrong with your RDKit installation, as Could you try running this script. It imports the
I get output
If this still doesn't work, then I can only think that your Python is loading a different RDKit library at runtime from the one installed by mamba. Check that you don't have a |
I'm still getting the same error on conversion. Checking sys.path I just have the following:
Checking the AllChem module file: from rdkit.Chem import AllChem
AllChem.__file__
'/root/miniforge3/envs/biosimspace_v23_sire_update/lib/python3.9/site-packages/rdkit/Chem/AllChem.py' Currently re-building sire from source in a fresh env. Will update once that's finished. |
Okay I've finally got to the bottom of this. It looks like the issue didn't require the fix you pushed @chryswoods. Instead there appears to have been an rdkit version mismatch that snuck its way in during my "fresh install". This install consisted of mamba installing biosimspace and dependencies, followed by my github repo, which required an install of chembl_structure_pipeline (CSP). I was pip installing CSP, not noticing that it in the process pip installed rdkit=2023.3.3. I think the version of rdkit (2023.03.3) I imported into my IPython kernel was from the conda channel, while it appears Sire was trying to communicate with the pip installed version? Thanks for the help, apologies for not spotting this sneaky rdkit install earlier. |
No problem at all - your experience is not going to be that uncommon. You've helped us see the symptoms of this problem, which will help us debug the issue for others in the future. I think I'll keep the fix as it doesn't seem to break anything, and I am surprised that RDKit works when it is trying to expose a |
Hi,
I've been encountering issues when trying to use the Align.merge() functionality.
Code:
Error:
Large stack trace so added as text file
Input files
I am using the tyk2 data files provided in the old BioSimSpaceTutorials repo.
ejm31.sdf, ejm42.sdf
(please complete the following information):
Many thanks,
Noah
The text was updated successfully, but these errors were encountered: