ccsb-scripps / AutoDock-Vina

AutoDock Vina
http://vina.scripps.edu
Apache License 2.0
561 stars 199 forks source link

The ligand is outside the grid box. #242

Open Dadiao-shuai opened 9 months ago

Dadiao-shuai commented 9 months ago

I already have computed the ligand center according to the input ligand.pdbqt, then I use the following script to calculate the vina.score( ) :

    v = Vina(sf_name='vina')
    rec_file = os.path.join(rec_dir,rec)
    v.set_receptor(rec_file)
    v.set_ligand_from_file(lig_file)
    center = get_ligand_center(lig_file)
    **size = [25, 25, 25]**
    v.compute_vina_maps(center=center, box_size=size)
    energy = v.score()

I think [25,25,25] is big enough for ligands in PDBbind dataset, But it raises error:

Computing Vina grid ... done.
Computing Vina grid ... done.
ERROR: The ligand is outside the grid box. Increase the size of the grid box or center it accordingly around the ligand.
rwxayheee commented 9 months ago

Hi @Dadiao-shuai, similar to get_ligand_center, maybe you could also define a get_ligand_range. Take a look at the largest rectangular box when you go through the dataset and see if that fits the [25, 25, 25] cubic box. (Not very familiar with PDBbind but there seems to be ligands with MW > 1000) Hope this is mildly helpful..

rwxayheee commented 9 months ago

Hi @Kerro-junior,

I feel that the way you check "can_molecule_fit" should work if you center the grid box at the mid-range x, y, z, which is: [(max(x_coords) + min(x_coords)) / 2, (max(y_coords) + min(y_coords)) / 2, (max(z_coords) + min(z_coords)) / 2]

If you still want to center the grid box at the center of ligand, you should check the distances from the center of the ligand to the x, y, z extrema and make sure all extrema are within the box. In principle, the distances should be no more than 30/2 but I would leave some room for errors (so maybe leave some minimal distance to the actual boundary and don't let them fit with the equal sign).

Edits: My initial reply was very unclear, sorry

Dadiao-shuai commented 9 months ago

Everything goes fine, your suggestion is nice. @rwxayheee

rwxayheee commented 9 months ago

Hi @Kerro-junior, To me it's a bit difficult to tell what the problem is without looking at the files and the rest of your codes. I have the following suggestions –

  1. To find out what the problem was, run your function interactively on the specific ligand file and see which part of the check failed.
  2. For efficiency,
    min_point = center - size/2
    max_point = center + size/2

    can be done outside of the function.

  3. I would suggest to set the default returned value of the function to be True.
  4. Depending on the precision of your inputs, leave like 0.05 or 0.1 minimal distance to the actual boundary. Something like:
    min_point = center - size/2 + 0.05
    max_point = center + size/2 - 0.05

    Hope this helps..

Edits: wrong sign, my bad..

rwxayheee commented 9 months ago

For more information, when I used the sdf files of ligand in PDBbind dataset to convert into PDBQT, mk_prepare_ligand.py -i ligand.sdf -o ligand.pdbqt, the mk_prepare_ligand.py reported some error informations like:

[17:07:07] ERROR: Could not sanitize molecule ending on line 39
[17:07:07] ERROR: Can't kekulize mol.  Unkekulized atoms: 3 4 5 6 7
[17:07:22] Can't kekulize mol.  Unkekulized atoms: 14 15 16 17 18

Does this influence the coordinates of sdf files and therir corresponding pdbqt files?

These messages indicated problems with bond order or atom type assignment in your input sdf. Were you still able to generate the ligand.pdbqt?