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

Problem with mk_export.py #295

Closed
xavgit opened this issue Dec 25, 2024 · 32 comments
Closed

Problem with mk_export.py #295

xavgit opened this issue Dec 25, 2024 · 32 comments
Assignees
Labels
bug Something isn't working

Comments

@xavgit
Copy link

xavgit commented Dec 25, 2024

Hi,
I'm experiencing a problem using mk_export.py with the command:

mk_export.py DB15122_docking_res_ad4_sf.dlg -s DB15122_docking_res_ad4_sf.sdf --all_dlg_poses

In the produced .sdf file there are the following first lines
DB15122_docking_res_ad4_sf
RDKit 3D

40 41 0 0 0 0 0 0 0 0999 V2000
-nan -nan -nan H 0 0 0 0 0 0 0 0 0 0 0 0
50.4710 64.8700 80.2250 C 0 0 0 0 0 0 0 0 0 0 0 0
-nan -nan -nan H 0 0 0 0 0 0 0 0 0 0 0 0
-nan -nan -nan H 0 0 0 0 0 0 0 0 0 0 0 0
51.6230 65.3190 79.3370 C 0 0 2 0 0 0 0 0 0 0 0 0
52.0950 64.1880 78.6110 O 0 0 0 0 0 0 0 0 0 0 0 0
52.7740 65.9730 80.1110 C 0 0 0 0 0 0 0 0 0 0 0 0
53.3564 66.6855 80.7136 H 0 0 0 0 0 0 0 0 0 0 0 0

The presence of nan could causing the following error with prolif package:

Processing DB15122_docking_res_ad4_sf
0%| | 0/32 [00:00<?, ?it/s][20:03:38] ERROR: Cannot process coordinates on line 5
[20:03:38] ERROR: moving to the beginning of the next molecule
0%| | 0/32 [00:00<?, ?it/s]
....................................................................................................................

What I can do?

Thanks.

Saverio

DB15122_docking_res_ad4_sf.dlg.txt
DB15122_docking_res_ad4_sf.sdf.txt

P.S.:
I have used the previous mk_export.py command to convert 9715
molecules.
For this set of drugs six of them have this type of problem as the following shows:

$ grep nan DB*.sdf | uniq
DB12161_docking_res_ad4_sf.sdf: -nan -nan -nan H 0 0 0 0 0 0 0 0 0 0 0 0
DB12628_docking_res_ad4_sf.sdf: -nan -nan -nan H 0 0 0 0 0 0 0 0 0 0 0 0
DB15122_docking_res_ad4_sf.sdf: -nan -nan -nan H 0 0 0 0 0 0 0 0 0 0 0 0
DB15141_docking_res_ad4_sf.sdf: -nan -nan -nan H 0 0 0 0 0 0 0 0 0 0 0 0
DB15414_docking_res_ad4_sf.sdf: -nan -nan -nan H 0 0 0 0 0 0 0 0 0 0 0 0
DB16650_docking_res_ad4_sf.sdf: -nan -nan -nan H 0 0 0 0 0 0 0 0 0 0 0 0

If this can be useful I can give the corresponding .dlg files

@rwxayheee
Copy link
Contributor

Hello @xavgit
This might have something to do with how the coordinates of H isotopes (deuterium, [2H] in your compound) are set. If you're already done with many docking calculations like this, a quick walkaround without redoing the calculation is to re-prepare the compounds without the isotopes and just replace the remarks in your current output.

For example in this DLG file you could replace the remarks:

DOCKED: REMARK SMILES [2H]C([2H])([2H])[C@H](O)C([2H])([2H])CCCn1c(=O)c2c(ncn2C)n(C)c1=O
DOCKED: REMARK SMILES IDX 10 1 7 2 5 3 2 4 6 5 11 7 12 8 13 9 14 10 24 11 16 12 22 13
DOCKED: REMARK SMILES IDX 20 14 17 15 19 16 18 17 15 18 25 19 23 20 21 21
DOCKED: REMARK H PARENT 6 6

by...

DOCKED: REMARK SMILES C[C@H](O)CCCCn1c(=O)c2c(ncn2C)n(C)c1=O
DOCKED: REMARK SMILES IDX 5 1 4 2 2 3 1 4 3 5 6 7 7 8 8 9 9 10 19 11 11 12 17 13 15 14
DOCKED: REMARK SMILES IDX 12 15 14 16 13 17 10 18 20 19 18 20 16 21
DOCKED: REMARK H PARENT 3 6

the later you can obtain from running ligand preparation (mk_prepare_ligand.py) for the non-deuterated version of the compound. To get the Smiles for the non-deuterated compound, simply delete patterns [2H] and ([2H]).

This is an interesting observation. Thanks for reporting. We will take a look and explore ways to improve the code.

@xavgit
Copy link
Author

xavgit commented Dec 26, 2024

Hi,
thanks for your suggestion.
I will exclude the docked ligands with this problem from the analysis.

Saverio

@rwxayheee
Copy link
Contributor

rwxayheee commented Dec 26, 2024

Hey @xavgit
Happy holidays. I have the modified version ready in PR #296. It may not be the final version, but should resolve the original problem you reported without manipulating the files.

To install the modified version, check it out from my repository:

git clone https://github.com/rwxayheee/Meeko.git
cd Meeko; git checkout update_pos_of_H_isotopes; pip install -e .; cd ..

Starting from the input DLG in your original post, my output is now:
DB15122_docking_res_ad4_sf_mine.sdf.txt

The command is the same. The coordinates of hydrogen isotopes are now created in the same way a regular Hs would be added.

Hope you like it, and please don't hesitate to reach out if you have any further questions.

Note that there are two related issues that might be affecting your inputs/outputs:
#297 - this is not solvable by us.
#298 this has been solved, but might require you to re-run the preparation with the version in #296 and rerun the calculation with the corrected input. For the ligands that were prepared with the old version. they might have been affected if there are polar hydrogen isotopes. If my fix is correct, this issue should be resolved from now on.

@rwxayheee rwxayheee self-assigned this Dec 26, 2024
@xavgit
Copy link
Author

xavgit commented Dec 26, 2024

Hi
thanks for your work!
I'll follow your instructions to install and use
your modified version.

Thanks again.

Saverio

@xavgit
Copy link
Author

xavgit commented Dec 26, 2024

Hi,
I receive an error when installing the modified package reported below
along with all the executed instructions:

xxxx@xxxx-X399-DESIGNARE-EX:~/sources$ git clone https://github.com/rwxayheee/Meeko.git
Cloning into 'Meeko'...
remote: Enumerating objects: 6359, done.
remote: Counting objects: 100% (1183/1183), done.
remote: Compressing objects: 100% (385/385), done.
remote: Total 6359 (delta 906), reused 834 (delta 798), pack-reused 5176 (from 3)
Receiving objects: 100% (6359/6359), 9.28 MiB | 3.44 MiB/s, done.
Resolving deltas: 100% (4078/4078), done.
xxxx@xxxx-X399-DESIGNARE-EX:~/sources$ cd Meeko
xxxx@xxxx-X399-DESIGNARE-EX:~/sources/Meeko$ git checkout update_pos_of_H_isotopes
Branch 'update_pos_of_H_isotopes' set up to track remote branch 'update_pos_of_H_isotopes' from 'origin'.
Switched to a new branch 'update_pos_of_H_isotopes'
xxxx@xxxx-X399-DESIGNARE-EX:~/sources/Meeko$ pip install -e .
Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///home/xxxx/sources/Meeko
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [43 lines of output]
running egg_info
creating /tmp/pip-pip-egg-info-egc8s_8p/meeko.egg-info
writing /tmp/pip-pip-egg-info-egc8s_8p/meeko.egg-info/PKG-INFO
writing dependency_links to /tmp/pip-pip-egg-info-egc8s_8p/meeko.egg-info/dependency_links.txt
writing entry points to /tmp/pip-pip-egg-info-egc8s_8p/meeko.egg-info/entry_points.txt
writing top-level names to /tmp/pip-pip-egg-info-egc8s_8p/meeko.egg-info/top_level.txt
writing manifest file '/tmp/pip-pip-egg-info-egc8s_8p/meeko.egg-info/SOURCES.txt'
reading manifest file '/tmp/pip-pip-egg-info-egc8s_8p/meeko.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'example/*'
adding license file 'LICENSE'
Traceback (most recent call last):
File "", line 2, in
File "", line 34, in
File "/home/xxxx/sources/Meeko/setup.py", line 22, in
setup(
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/init.py", line 117, in setup
return distutils.core.setup(**attrs)
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 183, in setup
return run_commands(dist)
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 199, in run_commands
dist.run_commands()
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 954, in run_commands
self.run_command(cmd)
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/dist.py", line 995, in run_command
super().run_command(command)
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 973, in run_command
cmd_obj.run()
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 313, in run
self.find_sources()
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 321, in find_sources
mm.run()
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 549, in run
self.prune_file_list()
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/command/sdist.py", line 162, in prune_file_list
super().prune_file_list()
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/_distutils/command/sdist.py", line 380, in prune_file_list
base_dir = self.distribution.get_fullname()
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/_core_metadata.py", line 267, in get_fullname
return _distribution_fullname(self.get_name(), self.get_version())
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/_core_metadata.py", line 285, in _distribution_fullname
canonicalize_version(version, strip_trailing_zero=False),
TypeError: canonicalize_version() got an unexpected keyword argument 'strip_trailing_zero'
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

xxxx@xxxx-X399-DESIGNARE-EX:~/sources/Meeko$ pip3 list | grep setuptools
setuptools 75.6.0

Any suggestions?

Thanks.

Saverio

@rwxayheee
Copy link
Contributor

Hi,

I can’t reproduce this :’( but it seems like an error because of unexpected Python or setuptools version.

The PR didn’t change dependencies. So itself shouldn’t introduce this error. But it’s based on develop branch so it includes some other changes we haven’t merged into an official release.

In my environment I have:
Python 3.10.
setuptools 75.1.0

Could you please try this?

pip install -e . --use-pep517

If it doesn’t work, will it be possible to adjust the version of setuptools?

@xavgit
Copy link
Author

xavgit commented Dec 26, 2024

Hi,
the output:

xxxx@xxxx-X399-DESIGNARE-EX:~/sources/Meeko$ pip install -e . --use-pep517
Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///home/xxxx/sources/Meeko
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Installing collected packages: meeko
Attempting uninstall: meeko
Found existing installation: meeko 0.6.1
Uninstalling meeko-0.6.1:
Successfully uninstalled meeko-0.6.1
Running setup.py develop for meeko
error: subprocess-exited-with-error

× python setup.py develop did not run successfully.
│ exit code: 1
╰─> [32 lines of output]
    running develop
    /usr/lib/python3/dist-packages/setuptools/command/easy_install.py:158: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    WARNING: The user site-packages directory is disabled.
    /usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    error: can't create or remove files in install directory
    
    The following error occurred while trying to add or remove files in the
    installation directory:
    
        [Errno 13] Permission denied: '/usr/local/lib/python3.10/dist-packages/test-easy-install-877907.write-test'
    
    The installation directory you specified (via --install-dir, --prefix, or
    the distutils default setting) was:
    
        /usr/local/lib/python3.10/dist-packages/
    
    Perhaps your account does not have write access to this directory?  If the
    installation directory is a system-owned directory, you may need to sign in
    as the administrator or "root" account.  If you do not have administrative
    access to this machine, you may wish to choose a different installation
    directory, preferably one that is listed in your PYTHONPATH environment
    variable.
    
    For information on other options, you may wish to consult the
    documentation at:
    
      https://setuptools.pypa.io/en/latest/deprecated/easy_install.html
    
    Please make the appropriate changes for your system and try again.
    
    [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

WARNING: No metadata found in /home/xxxx/.local/lib/python3.10/site-packages
Rolling back uninstall of meeko
Moving to /home/xxxx/.local/bin/mk_export.py
from /tmp/pip-uninstall-4s2efn4j/mk_export.py
Moving to /home/xxxx/.local/bin/mk_prepare_ligand.py
from /tmp/pip-uninstall-4s2efn4j/mk_prepare_ligand.py
Moving to /home/xxxx/.local/bin/mk_prepare_receptor.py
from /tmp/pip-uninstall-4s2efn4j/mk_prepare_receptor.py
Moving to /home/xxxx/.local/lib/python3.10/site-packages/meeko-0.6.1.dist-info/
from /home/xxxx/.local/lib/python3.10/site-packages/~eeko-0.6.1.dist-info
Moving to /home/xxxx/.local/lib/python3.10/site-packages/meeko/
from /home/xxxx/.local/lib/python3.10/site-packages/~eeko
error: subprocess-exited-with-error

× python setup.py develop did not run successfully.
│ exit code: 1
╰─> [32 lines of output]
running develop
/usr/lib/python3/dist-packages/setuptools/command/easy_install.py:158: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
WARNING: The user site-packages directory is disabled.
/usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: '/usr/local/lib/python3.10/dist-packages/test-easy-install-877907.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /usr/local/lib/python3.10/dist-packages/

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

  https://setuptools.pypa.io/en/latest/deprecated/easy_install.html

Please make the appropriate changes for your system and try again.

[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

@xavgit
Copy link
Author

xavgit commented Dec 26, 2024

Hi,
on Ubuntu 22.04 there is Python 3.10.12.
I can try to downgrade setuptools to 75.1.0

Thanks.
Saverio

@rwxayheee
Copy link
Contributor

rwxayheee commented Dec 26, 2024

Thanks for letting us know. I will look at the setup details a little later today. I’m not entirely sure which exact changes we made to develop branch that can be causing this.. but in the past I also encountered some problems on Ubuntu, which I think it was maybe because we are doing the old way of package setup. pep517 was the walkaround that worked for me.

I can try to reproduce this later in the afternoon. It might be something we will discuss with the team when we are back from the holiday. Thanks again for the info! This is very useful.

@rwxayheee
Copy link
Contributor

rwxayheee commented Dec 26, 2024

Alternatively you can look at the diff (files changed) of that PR and apply it to Meeko in your current environment if possible:

https://github.com/forlilab/Meeko/pull/296/files

It’s not complicated, I just added a code block to handle hydrogen isotopes as if regular hydrogens. And I made very minor change to function that’s used by the basic ligand preparation. I still need to write the summary, and I will do that later today!

@xavgit
Copy link
Author

xavgit commented Dec 26, 2024

Hi,
thanks.
As you have guessed the problem can be related to something
in Ubuntu 22.04 because running the following command I receive
almost the same type of error using a different package:

xxxx@xxxx-X399-DESIGNARE-EX:~$ pip3 install --upgrade rcsbsearchapi
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: rcsbsearchapi in ./.local/lib/python3.10/site-packages (1.6.0)
Collecting rcsbsearchapi
Using cached rcsbsearchapi-2.0.0.tar.gz (181 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [47 lines of output]
/home/xxxx/.local/lib/python3.10/site-packages/setuptools/_distutils/dist.py:261: UserWarning: Unknown distribution option: 'test_suite'
warnings.warn(msg)
/home/xxxx/.local/lib/python3.10/site-packages/setuptools/_distutils/dist.py:261: UserWarning: Unknown distribution option: 'tests_require'
warnings.warn(msg)
running egg_info
creating /tmp/pip-pip-egg-info-pxqn0lgk/rcsbsearchapi.egg-info
writing /tmp/pip-pip-egg-info-pxqn0lgk/rcsbsearchapi.egg-info/PKG-INFO
writing dependency_links to /tmp/pip-pip-egg-info-pxqn0lgk/rcsbsearchapi.egg-info/dependency_links.txt
writing requirements to /tmp/pip-pip-egg-info-pxqn0lgk/rcsbsearchapi.egg-info/requires.txt
writing top-level names to /tmp/pip-pip-egg-info-pxqn0lgk/rcsbsearchapi.egg-info/top_level.txt
writing manifest file '/tmp/pip-pip-egg-info-pxqn0lgk/rcsbsearchapi.egg-info/SOURCES.txt'
reading manifest file '/tmp/pip-pip-egg-info-pxqn0lgk/rcsbsearchapi.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'HISTORY.txt'
adding license file 'LICENSE'
Traceback (most recent call last):
File "", line 2, in
File "", line 34, in
File "/tmp/pip-install-x0sfaixg/rcsbsearchapi_3618eec8ead5471986dc224aa352ab15/setup.py", line 28, in
setup(
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/init.py", line 117, in setup
return distutils.core.setup(**attrs)
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 183, in setup
return run_commands(dist)
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 199, in run_commands
dist.run_commands()
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 954, in run_commands
self.run_command(cmd)
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/dist.py", line 950, in run_command
super().run_command(command)
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 973, in run_command
cmd_obj.run()
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 311, in run
self.find_sources()
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 319, in find_sources
mm.run()
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 545, in run
self.prune_file_list()
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/command/sdist.py", line 161, in prune_file_list
super().prune_file_list()
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/_distutils/command/sdist.py", line 380, in prune_file_list
base_dir = self.distribution.get_fullname()
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/_core_metadata.py", line 267, in get_fullname
return _distribution_fullname(self.get_name(), self.get_version())
File "/home/xxxx/.local/lib/python3.10/site-packages/setuptools/_core_metadata.py", line 285, in _distribution_fullname
canonicalize_version(version, strip_trailing_zero=False),
TypeError: canonicalize_version() got an unexpected keyword argument 'strip_trailing_zero'
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Hope this useful.

Saverio

@diogomart diogomart added the bug Something isn't working label Dec 26, 2024
@diogomart
Copy link
Contributor

This is the smallest smiles I could find that reproduces the problem. It's notable that none of the 18 deutorated test molecules had showed this problem before.

scrub.py "[2H]C([2H])C" -o test.sdf
mk_prepare_ligand.py -i test.sdf -o test.pdbqt
mk_export.py test.pdbqt --write_sdf test_exported.sdf
grep -ci nan test_exported.sdf

@rwxayheee
Copy link
Contributor

rwxayheee commented Dec 26, 2024

Yeah, with the current release version I also didn't get any nan from the DLG:
DB15122_docking_res_ad4_sf_release.sdf.txt

But the geometry from SetTerminalAtomCoords is not great (see the first pose), maybe also because of the torsional angles in the docked poses.
Screenshot 2024-12-26 at 1 38 41 PM

@xavgit,
Just wanted to let you know that Diogo @diogomart helped me with the existing issues (#297 and #298) I mentioned before. #297 seems solvable, but I need a little bit more time to work on it. #298 I think it's also a bug and it changes how the ligand is prepared.
Thanks again for the reporting. I really appreciate it, we will keep you posted.

@rwxayheee
Copy link
Contributor

rwxayheee commented Dec 26, 2024

edit because so many things I wrote here are incorrect

@diogomart
Copy link
Contributor

@rwxayheee here's more information that may be helpful. To export a docked pose, the first step is to create an RDKit molecule from the smiles, and then the positions from PDBQT are set. Deuterium is a real atom in the smiles (most hydrogens are not) and thus it becomes a special case because it exists as an atom in the rdkit molecule, but it does not have a position yet. This code block calculates coordinates to such atoms using RDKit's AllChem.SetTerminalAtomCoords():

# some hydrogens (isotopes) may have no coordinate set yet
for i, is_set in enumerate(coord_is_set):
if not is_set:
atom = mol.GetAtomWithIdx(i)
if atom.GetAtomicNum() != 1:
raise RuntimeError("Only H allowed to be in SMILES but not in PDBQT")
neigh = atom.GetNeighbors()
if len(neigh) != 1:
raise RuntimeError("Expected H to have one neighbor")
AllChem.SetTerminalAtomCoords(mol, i, neigh[0].GetIdx())

@rwxayheee
Copy link
Contributor

rwxayheee commented Dec 26, 2024

Yes, I see that we're assigning the coordinates with this. But the geometry is not good (and can cause nan in extreme cases). You can compare the two exported SDF with and without the PR:

With:
DB15122_docking_res_ad4_sf_mine.sdf.txt

Without:
DB15122_docking_res_ad4_sf_release.sdf.txt

It's a lot better to use AddHs and RemoveHs but requires more work. I think it's worth implementing a correction, but maybe not the way I did.

@diogomart
Copy link
Contributor

I agree. Possibly the first call of AllChem.SetTerminalAtomCoords on a methyl is causing the NaNs because there aren't enough atoms to define the geometry.

@rwxayheee
Copy link
Contributor

I actually can't reproduce nan. Has something changed in RDKit? (maybe @xavgit can tell us which version he used) But because SetTerminalAtomCoords is geometry-aware, it isn't really capable of handling the docked poses we have now.

But to preserve the chirality tag, AddHs, and RemoveHs are not so convenient.. I will think more about this

@diogomart
Copy link
Contributor

It could be an RDKit version. I could reproduce NaN with 2023.09.6, but with 2024.09.3 I get the following error:

Traceback (most recent call last):
  File "/home/diogom/micromamba/envs/testmk/bin/mk_export.py", line 33, in <module>
    sys.exit(load_entry_point('meeko', 'console_scripts', 'mk_export.py')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/diogom/Work/code/Meeko/meeko/cli/mk_export.py", line 104, in main
    sdf_string, failures = RDKitMolCreate.write_sd_string(
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/diogom/Work/code/Meeko/meeko/rdkit_mol_create.py", line 458, in write_sd_string
    mol_list = RDKitMolCreate.from_pdbqt_mol(pdbqt_mol, only_cluster_leads, keep_flexres)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/diogom/Work/code/Meeko/meeko/rdkit_mol_create.py", line 232, in from_pdbqt_mol
    mol = cls.add_pose_to_mol(mol, coordinates, index_map) 
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/diogom/Work/code/Meeko/meeko/rdkit_mol_create.py", line 334, in add_pose_to_mol
    AllChem.SetTerminalAtomCoords(mol, i, neigh[0].GetIdx())
RuntimeError: Cannot normalize a zero length vector

@rwxayheee
Copy link
Contributor

rwxayheee commented Dec 26, 2024

Got it. I have 2024.03.4 therefore I was able to write the SDF.

The PR applies correction after using it. But if it throws a runtime error, could we replace SetTerminalAtomCoords?

I don't have a very specific plan how to do this (within add_pose_to_mol, or defer to add_hydrogens? ), but I might try the other way (not using AddHs and RemoveHs; instead I want to doembed and align bond vectors).

@xavgit
Copy link
Author

xavgit commented Dec 27, 2024

Hi all,
if this can be useful
the rdkit version that I've used is 2024.3.6.

Thanks.

Saverio

@rwxayheee
Copy link
Contributor

Hi all, if this can be useful the rdkit version that I've used is 2024.3.6.

Thanks.

Saverio

Thanks for the info! There's a recent change on the RDKit function we're discussing here.

With this version in my current environment:

  + rdkit            2024.09.3  py310h7378585_0  conda-forge       18MB

And the unmodified develop branch of Meeko, the output SDF is:
rdkit_2024_09_3.sdf.txt

I didn't see the "Cannot normalize a zero length vector" error. It might have been fixed since a recent build.

@xavgit
Copy link
Author

xavgit commented Jan 6, 2025

Hi,
if this can be useful , the drugs ( 6 out of 9715 ) that have the
"nan" problem when mk_exported to sdf format were all docked
with ad-gpu whereas the same molecules docked with Vina , with
vina and vinardo s.f., don't present any problem when converted
to sdf format.
This is also true for almost all the six docking boxes of the the corresponding
representative frame of the chosen clusters of the MD simulation.

Thanks.

Saverio

@diogomart
Copy link
Contributor

Hi,
Just noting that I could reproduce the nan problem without docking: I just write the PDBQT and exported it.

@rwxayheee
Copy link
Contributor

rwxayheee commented Jan 6, 2025

Hi @xavgit can you try the latest of my PR:
#301
It should resolve the problem you initially reported. I recall you were also having trouble with installing from GitHub (with setup.py?). Could you please confirm that this issue persists? If so, I can draft a tomlized (or yaml) setup with restrictions, but I’m not sure if it’s going to displace our current way of setup (if more people report setup problems, maybe

@xavgit
Copy link
Author

xavgit commented Jan 7, 2025

Hi,
for "latest of my PR" can I use
git clone https://github.com/rwxayheee/Meeko.git
cd Meeko; git checkout update_pos_of_H_isotopes; pip install -e .; cd .. ?

Thanks.

Saverio

@xavgit
Copy link
Author

xavgit commented Jan 7, 2025

Hi,
having used
git clone https://github.com/rwxayheee/Meeko.git
cd Meeko; git checkout update_pos_of_H_isotopes; pip install -e .; cd ..
on Ubuntu 20.04
$ pwd
/home/xxxx/sources/Meeko
$ pip3 install -e .
/usr/bin/pip3:6: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import load_entry_point
Obtaining file:///home/xxxx/sources/Meeko
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Installing collected packages: meeko
Attempting uninstall: meeko
Found existing installation: meeko 0.5.1
Uninstalling meeko-0.5.1:
Successfully uninstalled meeko-0.5.1
Running setup.py develop for meeko
Successfully installed meeko
xxxx@xxxx-Lenovo-IdeaPad-S340-15API:/sources/Meeko$ pip3 list | grep Meeko
/usr/bin/pip3:6: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import load_entry_point
meeko 0.6.1 /home/xxxx/sources/Meeko
xxxx@xxxx-Lenovo-IdeaPad-S340-15API:
/sources/Meeko$ pip3 list | grep setuptools
/usr/bin/pip3:6: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import load_entry_point
setuptools 75.3.0
xxxx@xxxx-Lenovo-IdeaPad-S340-15API:~/sources/Meeko$ pip3 list | grep packaging
/usr/bin/pip3:6: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import load_entry_point
packaging 21.3
xxxx@xxxx-Lenovo-IdeaPad-S340-15API:/sources/Meeko$ pip3 install --upgrade packaging
/usr/bin/pip3:6: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import load_entry_point
Collecting packaging
Using cached packaging-24.2-py3-none-any.whl (65 kB)
Installing collected packages: packaging
Attempting uninstall: packaging
Found existing installation: packaging 21.3
Uninstalling packaging-21.3:
Successfully uninstalled packaging-21.3
Successfully installed packaging-24.2
xxxx@xxxx-Lenovo-IdeaPad-S340-15API:
/sources/Meeko$ pip3 install -e .
/usr/bin/pip3:6: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import load_entry_point
Obtaining file:///home/xxxx/sources/Meeko
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Installing collected packages: meeko
Attempting uninstall: meeko
Found existing installation: meeko 0.6.1
Uninstalling meeko-0.6.1:
Successfully uninstalled meeko-0.6.1
Running setup.py develop for meeko
Successfully installed meeko

On Ubuntu 22.04

$ pip3 install --upgrade packaging
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: packaging in /home/xxxx/.local/lib/python3.10/site-packages (21.3)
Collecting packaging
Using cached packaging-24.2-py3-none-any.whl (65 kB)
Installing collected packages: packaging
Attempting uninstall: packaging
Found existing installation: packaging 21.3
Uninstalling packaging-21.3:
Successfully uninstalled packaging-21.3
Successfully installed packaging-24.2
xxxx@xxxx-X399-DESIGNARE-EX:~/sources/Meeko$ pip3 install -e .
Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///home/xxxx/sources/Meeko
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Installing collected packages: meeko
Attempting uninstall: meeko
Found existing installation: meeko 0.6.1
Uninstalling meeko-0.6.1:
Successfully uninstalled meeko-0.6.1
Running setup.py develop for meeko
error: subprocess-exited-with-error

× python setup.py develop did not run successfully.
│ exit code: 1
╰─> [32 lines of output]
    running develop
    /usr/lib/python3/dist-packages/setuptools/command/easy_install.py:158: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    WARNING: The user site-packages directory is disabled.
    /usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    error: can't create or remove files in install directory
    
    The following error occurred while trying to add or remove files in the
    installation directory:
    
        [Errno 13] Permission denied: '/usr/local/lib/python3.10/dist-packages/test-easy-install-3112792.write-test'
    
    The installation directory you specified (via --install-dir, --prefix, or
    the distutils default setting) was:
    
        /usr/local/lib/python3.10/dist-packages/
    
    Perhaps your account does not have write access to this directory?  If the
    installation directory is a system-owned directory, you may need to sign in
    as the administrator or "root" account.  If you do not have administrative
    access to this machine, you may wish to choose a different installation
    directory, preferably one that is listed in your PYTHONPATH environment
    variable.
    
    For information on other options, you may wish to consult the
    documentation at:
    
      https://setuptools.pypa.io/en/latest/deprecated/easy_install.html
    
    Please make the appropriate changes for your system and try again.
    
    [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

WARNING: No metadata found in /home/xxxx/.local/lib/python3.10/site-packages
Rolling back uninstall of meeko
Moving to /home/xxxx/.local/bin/mk_export.py
from /tmp/pip-uninstall-qu6lswo4/mk_export.py
Moving to /home/xxxx/.local/bin/mk_prepare_ligand.py
from /tmp/pip-uninstall-qu6lswo4/mk_prepare_ligand.py
Moving to /home/xxxx/.local/bin/mk_prepare_receptor.py
from /tmp/pip-uninstall-qu6lswo4/mk_prepare_receptor.py
Moving to /home/xxxx/.local/lib/python3.10/site-packages/meeko-0.6.1.dist-info/
from /home/xxxx/.local/lib/python3.10/site-packages/~eeko-0.6.1.dist-info
Moving to /home/xxxx/.local/lib/python3.10/site-packages/meeko/
from /home/xxxx/.local/lib/python3.10/site-packages/~eeko
error: subprocess-exited-with-error

× python setup.py develop did not run successfully.
│ exit code: 1
╰─> [32 lines of output]
running develop
/usr/lib/python3/dist-packages/setuptools/command/easy_install.py:158: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
WARNING: The user site-packages directory is disabled.
/usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: '/usr/local/lib/python3.10/dist-packages/test-easy-install-3112792.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /usr/local/lib/python3.10/dist-packages/

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

  https://setuptools.pypa.io/en/latest/deprecated/easy_install.html

Please make the appropriate changes for your system and try again.

[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

Thanks.

Saverio

@rwxayheee
Copy link
Contributor

Hi @xavgit
Yes that’s exactly what I meant. Seems like you have downgraded setuptools and the install issue went away. If not, please see #303 for a quick solution.

Let me know what you think of that draft version by the PR, and feel free to reach out if you have any further questions.

@xavgit
Copy link
Author

xavgit commented Jan 7, 2025

Hi,
sorry , I'm not precise in my reporting.
For both version of Ubuntu I've used the "quick solution" using the
pyproject.toml.
I've now update with the results of the installation for Ubuntu 22.04.
For Ubuntu 20.04 the installation works with both the two
version of setuptools.

Now I can try to use mk_export in Ubuntu 20.04 to
check if the nan problem is present for the six drugs.

Thanks again.

Saverio

@rwxayheee
Copy link
Contributor

Thanks for the report! Glad to know #303 helps.

@xavgit
Copy link
Author

xavgit commented Jan 7, 2025

Hi,
if this can be useful , on another laptop with Ubuntu 22.04
the two command lines:
git clone https://github.com/rwxayheee/Meeko.git
cd Meeko; git checkout update_pos_of_H_isotopes; pip install -e .; cd ..
complete the installation without the use of the "quick solution" and any error.

$ git clone https://github.com/rwxayheee/Meeko.git
cd Meeko; git checkout update_pos_of_H_isotopes; pip3 install -e .
Cloning into 'Meeko'...
remote: Enumerating objects: 6409, done.
remote: Counting objects: 100% (1233/1233), done.
remote: Compressing objects: 100% (426/426), done.
remote: Total 6409 (delta 943), reused 853 (delta 807), pack-reused 5176 (from 3)
Receiving objects: 100% (6409/6409), 9.30 MiB | 3.79 MiB/s, done.
Resolving deltas: 100% (4115/4115), done.
Branch 'update_pos_of_H_isotopes' set up to track remote branch 'update_pos_of_H_isotopes' from 'origin'.
Switched to a new branch 'update_pos_of_H_isotopes'
Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///home/xxxx/sources/Meeko
Preparing metadata (setup.py) ... done
Installing collected packages: meeko
Attempting uninstall: meeko
Found existing installation: meeko 0.6.1
Uninstalling meeko-0.6.1:
Successfully uninstalled meeko-0.6.1
DEPRECATION: Legacy editable install of meeko==0.6.1 from file:///home/xxxx/sources/Meeko (setup.py develop) is deprecated. pip 25.0 will enforce this behaviour change. A possible replacement is to add a pyproject.toml or enable --use-pep517, and use setuptools >= 64. If the resulting installation is not behaving as expected, try using --config-settings editable_mode=compat. Please consult the setuptools documentation for more information. Discussion can be found at pypa/pip#11457
Running setup.py develop for meeko
Successfully installed meeko

Also,
$ pip3 list | grep -E 'setuptools|packaging|rdkit'
packaging 24.1
rdkit 2024.9.4
setuptools 75.7.0
useful_rdkit_utils 0.3.12

Thanks.

Saverio

@rwxayheee
Copy link
Contributor

Hi @xavgit
For the original issue you reported, we have reviewed and merged PR #296. We consider this issue as resolved. However, if you find any further problems with similar ligands, please feel free to re-open this issue. Thank you again for bringing this to our attention

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants