mattragoza / LiGAN

Deep generative models of 3D grids for structure-based drug discovery
GNU General Public License v2.0
225 stars 44 forks source link

Cannot use model with `fit_atoms: True` #62

Closed MaciejDzikowski closed 1 year ago

MaciejDzikowski commented 1 year ago

We are trying to use LiGAN and generate molecule-level metrics.
In order to achieve that, atom fitting is required to be turned on. However, when the option is set on, the process is interrupted by: KeyError: 'minimizedAffinity'. Also, we are getting some Open Babel warnings, but I am not sure if it is relevant in this case.
The error message:
lfit_atoms_err

Sample of PDB files we are providing to model (source) - .csv file fragment:

0 0 0 7rdz.pdb 7rdz_J_ZN.sdf
0 0 0 7rdz.pdb 7rdz_K_MG.sdf
0 0 0 7rdz.pdb 7rdz_L_ADP.sdf
mattragoza commented 1 year ago

If you scroll up a bit in the output you see an error message from gnina: Runtime Error an illegal memory access was encountered. How did you install gnina?

DomaradzkiMaciej commented 1 year ago

Hi Matt, sorry for late reply. I installed gnina directly from the github according to step 2.

image

MaciejDzikowski commented 1 year ago

We decided to use exemplary files from LiGAN repository as an input:

We've got 9 files (receptor, 2x pocket, 6x ligand) but still, there is no trace of files with metrics. :/

Here's a screenshot with an error message from a command line: image

and our generate.config file:

--- # new_atom_typing/generate/gen0_CVAE-1.6_1zyu_A_rec_0_1.0_1.0/generate.config
out_prefix: their_example
model_type: CVAE
random_seed: 0
verbose: True
device: cuda

data:
  data_root: test_this_stuff/their_example
  data_file: test_this_stuff/their_example/eg1_their_example.csv
  batch_size: 5
  rec_typer: oadc-1.0
  lig_typer: oadc-1.0
  use_rec_elems: True
  resolution: 0.5
  grid_size: 48
  shuffle: False
  random_rotation: True
  random_translation: 2.0
  diff_cond_transform: False
  diff_cond_structs: False

gen_model:
  n_filters: 28
  width_factor: 2
  n_levels: 4
  conv_per_level: 4
  kernel_size: 3
  relu_leak: 0.1
  batch_norm: 0
  spectral_norm: 1
  pool_type: a
  unpool_type: 'n'
  pool_factor: 2
  n_latent: 128
  init_conv_pool: 0
  skip_connect: True
  block_type: r
  growth_rate: 0
  bottleneck_factor: 0
  state: weights/train6_CVAE2_0_p0_4.0_4.0_k200_d_1.6_r0_n_4.0_65_iter_1000000.gen_model_state

atom_fitting:
  beam_size: 1
  multi_atom: False
  n_atoms_detect: 1
  apply_conv: False
  threshold: 0.1
  peak_value: 1.5
  min_dist: 0.0
  apply_prop_conv: False
  interm_gd_iters: 10
  final_gd_iters: 100

generate:
  n_examples: 1
  n_samples: 1
  prior: False
  var_factor: 1.0
  post_factor: 1.0
  stage2: False
  truncate: False
  interpolate: False
  spherical: False
  fit_atoms: True
  add_bonds: True
  uff_minimize: True
  gnina_minimize: True
  minimize_real: True

output:
  batch_metrics: False
  output_grids: False
  output_structs: False
  output_mols: True
  output_latents: True
  output_visited: False
  output_conv: False
mattragoza commented 1 year ago

@DomaradzkiMaciej

These are the install instructions for libmolgrid. You also need to install gnina, which is used to minimize and predict the affinity of the generated molecules.

mattragoza commented 1 year ago

@MaciejDzikowski If you scroll up a little in the stderr, you'll see that again there is an error message coming from gnina. This time it says Runtime error out of memory, but it could be due to how you installed gnina.

Did you install it by downloading the gnina executable, or did you build it from source?

MaciejDzikowski commented 1 year ago

@DomaradzkiMaciej

These are the install instructions for libmolgrid. You also need to install gnina, which is used to minimize and predict the affinity of the generated molecules.

@DomaradzkiMaciej and I cooperate in the same project. He's installed the gnina⁣ (Step 3. in the instruction) properly (without any errors or warnings) but, as I see, he pasted a screenshot of only Step 2. Sorry for the misunderstanding. All our tests were performed on this installation (without any further changes).

We also checked out gnina's version, and our version of the program corresponds to the one given in the manual (1.0.2).

@MaciejDzikowski If you scroll up a little in the stderr, you'll see that again there is an error message coming from gnina. This time it says Runtime error out of memory, but it could be due to how you installed gnina.

Did you install it by downloading the gnina executable, or did you build it from source?

The installation was performed by downloading the gnina standalone executable in accordance with the instructions given in the Step 3.:

wget https://github.com/gnina/gnina/releases/download/v1.0.2/gnina -P $CONDA_PREFIX/bin
chmod +x $CONDA_PREFIX/bin/gnina
mattragoza commented 1 year ago

@MaciejDzikowski We can't guarantee that the standalone executable will run without problems on all systems. What is the output when you run pytest tests/test_molecules.py -k test_gnina from the repository root?

If the standalone executable is incompatible with your system, then you will have to either try the Docker image or building it from source.

DomaradzkiMaciej commented 1 year ago

Thank you for your help. We will then try the Docker image.