MolecularAI / REINVENT4

AI molecular design tool for de novo design, scaffold hopping, R-group replacement, linker design and molecule optimization.
Apache License 2.0
359 stars 89 forks source link

Using libinvent.prior reports an error: IndexError: index 196 is out of bounds for axis 0 with size 196 #144

Closed gongxq19 closed 1 month ago

gongxq19 commented 1 month ago

When I use libinvent.prior, an error occurs. The input file is the scaffolds.smi provided by the author.

Traceback (most recent call last): File "/home/mpudgx202301/miniconda3/envs/reinvent4/bin/reinvent", line 8, in sys.exit(main()) File "/home/mpudgx202301/miniconda3/envs/reinvent4/lib/python3.10/site-packages/reinvent/Reinvent.py", line 334, in main runner( File "/home/mpudgx202301/miniconda3/envs/reinvent4/lib/python3.10/site-packages/reinvent/runmodes/samplers/run_sampling.py", line 117, in run_sampling sampled = filter_valid(sampled) File "/home/mpudgx202301/miniconda3/envs/reinvent4/lib/python3.10/site-packages/reinvent/runmodes/samplers/run_sampling.py", line 158, in filter_valid smilies = list(np.array(sampled.smilies)[mask_idx]) IndexError: index 196 is out of bounds for axis 0 with size 196

Here, this is my sampling.toml

tb_logdir = "tb_logs_libinvent" run_type = "sampling" device = "cpu"
json_out_config = "_sampling.json"
model_file = "priors/libinvent.prior" smiles_file = "scaffolds.smi" sample_strategy = "beamsearch" output_file = 'libinvent_LY25.csv'
num_smiles = 100
unique_molecules = true
randomize_smiles = true

Looking forward to your reply!

halx commented 1 month ago

Hi,

many thanks for your interest in REINVENT and welcome to the community!

Many thanks for reporting this is a bug. I have fixed this now for you to test.

Cheers, Hannes.

gongxq19 commented 1 month ago

Hello, Thanks for your reply! I tested your modified script, but the problem is still not solved.

Traceback (most recent call last): File "/home/mpudgx202301/miniconda3/envs/reinvent4/bin/reinvent", line 8, in sys.exit(main()) File "/home/mpudgx202301/miniconda3/envs/reinvent4/lib/python3.10/site-packages/reinvent/Reinvent.py", line 334, in main runner( File "/home/mpudgx202301/miniconda3/envs/reinvent4/lib/python3.10/site-packages/reinvent/runmodes/samplers/run_sampling.py", line 117, in run_sampling sampled = filter_valid(sampled) File "/home/mpudgx202301/miniconda3/envs/reinvent4/lib/python3.10/site-packages/reinvent/runmodes/samplers/run_sampling.py", line 158, in filter_valid smilies = list(np.array(sampled.smilies)[mask_idx]) IndexError: index 967 is out of bounds for axis 0 with size 967

halx commented 1 month ago

Your error message suggests that you are not working with the latest code changes. You need to peform a git pull and if you have not done a local install (-e) also pip install --no-deps . in the source code directory.

gongxq19 commented 1 month ago

I ran thepip install --no-deps . command and it works now, thank you very much!