ci-lab-cz / easydock

BSD 3-Clause "New" or "Revised" License
35 stars 12 forks source link

Retrieving poses fails #24

Closed davidoskky closed 4 months ago

davidoskky commented 4 months ago

It is impossible to retrieve poses which are not the first one.

I do have a working solution running in my system already. If I verify everything works correctly I'll refactor the code a little bit and submit a PR.

On a side note: what is the reason of being able to select single poses? I'd rather have --poses 5 return the first 5 poses.

Greetings

get_sdf_from_dock_db -i docked.db -o docked.sdf --poses 2

Traceback (most recent call last):
  File "/home/davide/Lavoro/libraries/easydock/easydock/preparation_for_docking.py", line 157, in pdbqt2molblock
    pdbqt_mol = PDBQTMolecule(pdbqt_block, is_dlg=False, skip_typing=True, poses_to_read=1)
  File "/home/davide/.config/conda/envs/easydock/lib/python3.9/site-packages/meeko/molecule_pdbqt.py", line 360, in __init__
    results = _read_ligand_pdbqt_file(pdbqt_string, poses_to_read, energy_range, is_dlg, skip_typing)
  File "/home/davide/.config/conda/envs/easydock/lib/python3.9/site-packages/meeko/molecule_pdbqt.py", line 282, in _read_ligand_pdbqt_file
    positions = np.array(positions).reshape((n_poses, atoms.shape[0], 3))
AttributeError: 'NoneType' object has no attribute 'shape'
Parsing PDB was failed (fixing did not help): i1_2
DrrDom commented 4 months ago

Did you try the latest version 0.3.0? Because I fixed there this bug in the latest version and it works for me.

On a side note: what is the reason of being able to select single poses? I'd rather have --poses 5 return the first 5 poses.

This was done to be more general and flexible, if a user wants to extract just a particular poses additionally to previously extract ones. Conversion was not that fast and for many compounds it can be slow to regenerate all poses again.

davidoskky commented 4 months ago

Sorry for the late reply. It does now work in the new version. Plenty of exceptions are logged, but the output is there. I didn't check yet whether the poses which log exceptions are present and do not get converted correctly or whether these are not present in the database.

Traceback (most recent call last):
  File "easydock/preparation_for_docking.py", line 157, in pdbqt2molblock
    pdbqt_mol = PDBQTMolecule(pdbqt_block, is_dlg=False, skip_typing=True, poses_to_read=1)
  File "meeko/molecule_pdbqt.py", line 364, in __init__
    raise RuntimeError('read 0 atoms. Consider PDBQTMolecule.from_file(fname)')
RuntimeError: read 0 atoms. Consider PDBQTMolecule.from_file(fname)
Parsing PDB was failed: Compound 1377_3
DrrDom commented 4 months ago

If you ask for the pose which does not exist in PDBQT block this should raise an IndexError and print the corresponding error message, e.g. Pose number 5 is not in the PDB block of m0. It will be skipped.. In your case I would suggest to check the molecule and PDBQT block. This is not an expected error.

davidoskky commented 4 months ago

I have now checked again, the pdb_block of the molecule in the database contains 2 models. Those two are present in the output sdf. However, it logs the error when attempting to retrieve pose 3. Attempting to retrieve pose 4 gives the informative message you provided.

Here is the pdb_block from the database:

MODEL 1
REMARK VINA RESULT:    27.045      0.000      0.000
REMARK INTER + INTRA:          36.092
REMARK INTER:                  35.741
REMARK INTRA:                   0.351
REMARK UNBOUND:                 0.351
REMARK SMILES Cc1cc(=O)c(O)cn1Cc1cc2ccc(OCc3ccccc3)cc2oc1=O
REMARK SMILES IDX 11 1 12 2 13 3 14 4 15 5 16 6 25 7 26 8 27 9 28 10 29 11
REMARK SMILES IDX 10 12 9 13 1 14 2 15 3 16 4 17 8 18 5 19 6 20 7 21 17 23
REMARK SMILES IDX 18 24 19 25 20 26 24 27 21 28 23 29 22 30
REMARK H PARENT 7 22
REMARK Flexibility Score: inf
ROOT
ATOM      1  C   UNL     1      53.995 156.229  24.751  1.00  0.00     0.058 A 
ATOM      2  C   UNL     1      54.351 155.217  23.848  1.00  0.00     0.025 A 
ATOM      3  C   UNL     1      55.067 155.535  22.690  1.00  0.00     0.018 A 
ATOM      4  C   UNL     1      55.421 154.555  21.753  1.00  0.00     0.016 A 
ATOM      5  C   UNL     1      56.143 154.912  20.610  1.00  0.00     0.047 A 
ATOM      6  C   UNL     1      56.511 156.245  20.385  1.00  0.00     0.123 A 
ATOM      7  C   UNL     1      56.154 157.229  21.328  1.00  0.00     0.094 A 
ATOM      8  C   UNL     1      55.434 156.878  22.474  1.00  0.00     0.142 A 
ATOM      9  O   UNL     1      55.090 157.814  23.354  1.00  0.00    -0.422 OA
ATOM     10  C   UNL     1      54.397 157.548  24.458  1.00  0.00     0.341 A 
ATOM     11  O   UNL     1      54.121 158.493  25.241  1.00  0.00    -0.246 OA
ENDROOT
BRANCH   1  12
ATOM     12  C   UNL     1      53.177 155.896  25.985  1.00  0.00     0.165 C 
BRANCH  12  13
ATOM     13  N   UNL     1      52.873 154.449  26.050  1.00  0.00    -0.343 N 
ATOM     14  C   UNL     1      50.458 154.863  26.691  1.00  0.00     0.064 C 
ATOM     15  C   UNL     1      51.613 153.959  26.333  1.00  0.00     0.019 A 
ATOM     16  C   UNL     1      51.388 152.572  26.349  1.00  0.00     0.077 A 
ATOM     17  C   UNL     1      52.438 151.693  26.105  1.00  0.00     0.223 A 
ATOM     18  C   UNL     1      53.910 153.576  25.833  1.00  0.00     0.136 A 
ATOM     19  O   UNL     1      52.230 150.450  26.127  1.00  0.00    -0.286 OA
ATOM     20  C   UNL     1      53.714 152.196  25.850  1.00  0.00     0.179 A 
BRANCH  20  21
ATOM     21  O   UNL     1      54.799 151.351  25.616  1.00  0.00    -0.503 OA
ATOM     22  H   UNL     1      55.542 151.229  26.295  1.00  0.00     0.293 HD
ENDBRANCH  20  21
ENDBRANCH  12  13
ENDBRANCH   1  12
BRANCH   6  23
ATOM     23  O   UNL     1      57.233 156.549  19.220  1.00  0.00    -0.489 OA
BRANCH  23  24
ATOM     24  C   UNL     1      58.526 157.149  19.205  1.00  0.00     0.265 C 
BRANCH  24  25
ATOM     25  C   UNL     1      58.904 157.476  17.789  1.00  0.00    -0.011 A 
ATOM     26  C   UNL     1      58.038 158.241  16.989  1.00  0.00     0.007 A 
ATOM     27  C   UNL     1      60.151 157.082  17.273  1.00  0.00     0.007 A 
ATOM     28  C   UNL     1      58.406 158.587  15.685  1.00  0.00     0.000 A 
ATOM     29  C   UNL     1      60.512 157.428  15.967  1.00  0.00     0.000 A 
ATOM     30  C   UNL     1      59.640 158.178  15.173  1.00  0.00     0.000 A 
ENDBRANCH  24  25
ENDBRANCH  23  24
ENDBRANCH   6  23
TORSDOF 6
ENDMDL
MODEL 2
REMARK VINA RESULT:    28.524      0.906      1.922
REMARK INTER + INTRA:          38.046
REMARK INTER:                  35.584
REMARK INTRA:                   2.462
REMARK UNBOUND:                 0.351
REMARK SMILES Cc1cc(=O)c(O)cn1Cc1cc2ccc(OCc3ccccc3)cc2oc1=O
REMARK SMILES IDX 11 1 12 2 13 3 14 4 15 5 16 6 25 7 26 8 27 9 28 10 29 11
REMARK SMILES IDX 10 12 9 13 1 14 2 15 3 16 4 17 8 18 5 19 6 20 7 21 17 23
REMARK SMILES IDX 18 24 19 25 20 26 24 27 21 28 23 29 22 30
REMARK H PARENT 7 22
REMARK Flexibility Score: inf
ROOT
ATOM      1  C   UNL     1      53.888 155.735  25.091  1.00  0.00     0.058 A 
ATOM      2  C   UNL     1      54.240 154.841  24.069  1.00  0.00     0.025 A 
ATOM      3  C   UNL     1      54.871 155.313  22.916  1.00  0.00     0.018 A 
ATOM      4  C   UNL     1      55.217 154.454  21.864  1.00  0.00     0.016 A 
ATOM      5  C   UNL     1      55.853 154.963  20.728  1.00  0.00     0.047 A 
ATOM      6  C   UNL     1      56.143 156.330  20.624  1.00  0.00     0.123 A 
ATOM      7  C   UNL     1      55.794 157.193  21.682  1.00  0.00     0.094 A 
ATOM      8  C   UNL     1      55.159 156.689  22.822  1.00  0.00     0.142 A 
ATOM      9  O   UNL     1      54.822 157.510  23.811  1.00  0.00    -0.422 OA
ATOM     10  C   UNL     1      54.209 157.096  24.916  1.00  0.00     0.341 A 
ATOM     11  O   UNL     1      53.933 157.941  25.807  1.00  0.00    -0.246 OA
ENDROOT
BRANCH   1  12
ATOM     12  C   UNL     1      53.160 155.235  26.325  1.00  0.00     0.165 C 
BRANCH  12  13
ATOM     13  N   UNL     1      52.911 153.778  26.245  1.00  0.00    -0.343 N 
ATOM     14  C   UNL     1      55.301 153.286  25.565  1.00  0.00     0.064 C 
ATOM     15  C   UNL     1      53.901 152.864  25.937  1.00  0.00     0.019 A 
ATOM     16  C   UNL     1      53.601 151.491  25.907  1.00  0.00     0.077 A 
ATOM     17  C   UNL     1      52.305 151.054  26.163  1.00  0.00     0.223 A 
ATOM     18  C   UNL     1      51.630 153.343  26.474  1.00  0.00     0.136 A 
ATOM     19  O   UNL     1      52.043 149.822  26.130  1.00  0.00    -0.286 OA
ATOM     20  C   UNL     1      51.305 151.987  26.445  1.00  0.00     0.179 A 
BRANCH  20  21
ATOM     21  O   UNL     1      49.990 151.595  26.691  1.00  0.00    -0.503 OA
ATOM     22  H   UNL     1      49.415 152.050  27.391  1.00  0.00     0.293 HD
ENDBRANCH  20  21
ENDBRANCH  12  13
ENDBRANCH   1  12
BRANCH   6  23
ATOM     23  O   UNL     1      56.781 156.790  19.461  1.00  0.00    -0.489 OA
BRANCH  23  24
ATOM     24  C   UNL     1      57.816 157.770  19.441  1.00  0.00     0.265 C 
BRANCH  24  25
ATOM     25  C   UNL     1      58.451 157.792  18.081  1.00  0.00    -0.011 A 
ATOM     26  C   UNL     1      59.657 157.105  17.857  1.00  0.00     0.007 A 
ATOM     27  C   UNL     1      57.814 158.435  17.005  1.00  0.00     0.007 A 
ATOM     28  C   UNL     1      60.228 157.084  16.581  1.00  0.00     0.000 A 
ATOM     29  C   UNL     1      58.392 158.412  15.731  1.00  0.00     0.000 A 
ATOM     30  C   UNL     1      59.599 157.740  15.520  1.00  0.00     0.000 A 
ENDBRANCH  24  25
ENDBRANCH  23  24
ENDBRANCH   6  23
TORSDOF 6
ENDMDL
DrrDom commented 4 months ago

The problem was caused by asking for a pose which is maximum + 1. I pushed the fix to master. It will be available in pip from the next release.