MorganCThomas / MolScore

An automated scoring function to facilitate and standardize the evaluation of goal-directed generative models for de novo molecular design
MIT License
148 stars 24 forks source link

errors when I $ streamlit run molscore/config_generator.py #27

Closed xuzhang5788 closed 3 years ago

xuzhang5788 commented 3 years ago

You can now view your Streamlit app in your browser.

Local URL: http://localhost:8501 Network URL: http://192.168.0.25:8501

2021-08-31 15:32:27.169 Traceback (most recent call last): File "/home/xzhang/miniconda3/envs/molscore/lib/python3.6/site-packages/streamlit/script_runner.py", line 350, in _run_script exec(code, module.dict) File "/home/xzhang/projects/MolScore/molscore/config_generator.py", line 344, in config['scoring']['metrics'] = [getspconfig(options=smetric_options, key_i=i) for i in range(ss.n_sp)] File "/home/xzhang/projects/MolScore/molscore/config_generator.py", line 344, in config['scoring']['metrics'] = [getspconfig(options=smetric_options, key_i=i) for i in range(ss.n_sp)] File "/home/xzhang/projects/MolScore/molscore/config_generator.py", line 193, in getspconfig key=f'{key_i}: sp_name') File "/home/xzhang/miniconda3/envs/molscore/lib/python3.6/site-packages/streamlit/elements/selectbox.py", line 129, in selectbox serializer=serialize_select_box, File "/home/xzhang/miniconda3/envs/molscore/lib/python3.6/site-packages/streamlit/state/widgets.py", line 149, in register_widget user_key, streamlit.errors.DuplicateWidgetID: There are multiple identical st.selectbox widgets with key='0: sp_name'.

To fix this, please make sure that the key argument is unique for each st.selectbox you create.

MorganCThomas commented 3 years ago

Can I ask which branch you're using? I think I may have fixed this issue in the master branch.

xuzhang5788 commented 3 years ago

@MorganCThomas Thank you for your quick reply. I used the default branch. I checked it today. It is the main branch.

MorganCThomas commented 3 years ago

Can you please try updating this to the master branch git pull origin master (or however you've named the remote repo).

If you installed molscore in the environment using python setup_molscore.py install you'll need to uninstall via pip uninstall molscore and reinstall it. If you installed it using python setup_molscore.py develop you should not need to re-install molscore.

Meanwhile, I still need to more thoroughly test the master branch for merging it to make it default.

xuzhang5788 commented 3 years ago

I used python setup_molscore.py develop to install molscore. I tried git pull origin master, and then ran $ streamlit run molscore/config_generator.py. I got:

2021-09-02 10:34:09.446 Traceback (most recent call last): File "/home/xzhang/miniconda3/envs/molscore/lib/python3.6/site-packages/streamlit/script_runner.py", line 350, in _run_script exec(code, module.dict) File "/home/xzhang/projects/MolScore/molscore/config_generator.py", line 10, in import molscore.scoring_functions as scoring_functions File "/home/xzhang/projects/MolScore/molscore/scoring_functions/init.py", line 1, in from molscore.scoring_functions.glide import GlideDock, GlideDockFromROCS File "/home/xzhang/projects/MolScore/molscore/scoring_functions/glide.py", line 11, in from rdkit.Chem.EnumerateStereoisomers import EnumerateStereoisomers, StereoEnumerationOptions, GetStereoisomerCount ImportError: cannot import name 'GetStereoisomerCount'

MorganCThomas commented 3 years ago

Which version of RDKit are you running? It seems the function doesn't exist in older versions < 2019.03 (which may be the issue). I'll also specify this in the environment file for future use in the master branch which as I said I'll merge soon. Alternatively, if you don't need the Glide code you can comment out the lines referring to Glide in molscore/scoring_functions/init.py which should fix this issue temporarily.

MorganCThomas commented 3 years ago

I've updated the master branch to reflect this dependency.

If you pull the master branch now and start fresh it should work, I've just tested it on my Linux and it works fine. i.e., install the conda environment again and then install molscore again

xuzhang5788 commented 3 years ago

Sorry. It still doesn't work. First of all, I git clone the master branch and reinstalled molscore, I got: 2021-09-02 12:09:10.867 Traceback (most recent call last): File "/home/xzhang/miniconda3/envs/molscore/lib/python3.6/site-packages/streamlit/script_runner.py", line 350, in _run_script exec(code, module.dict) File "/home/xzhang/projects/MolScore/molscore/config_generator.py", line 344, in config['scoring']['metrics'] = [getspconfig(options=smetric_options, key_i=i) for i in range(ss.n_sp)] File "/home/xzhang/projects/MolScore/molscore/config_generator.py", line 344, in config['scoring']['metrics'] = [getspconfig(options=smetric_options, key_i=i) for i in range(ss.n_sp)] File "/home/xzhang/projects/MolScore/molscore/config_generator.py", line 193, in getspconfig key=f'{key_i}: sp_name') File "/home/xzhang/miniconda3/envs/molscore/lib/python3.6/site-packages/streamlit/elements/selectbox.py", line 129, in selectbox serializer=serialize_select_box, File "/home/xzhang/miniconda3/envs/molscore/lib/python3.6/site-packages/streamlit/state/widgets.py", line 149, in register_widget user_key, streamlit.errors.DuplicateWidgetID: There are multiple identical st.selectbox widgets with key='0: sp_name'.

To fix this, please make sure that the key argument is unique for each st.selectbox you create.

Then I followed your direction to reinstall molscore main branch, I did the followings: $conda env create -f molscore_environment.yml $conda activate molscore $python setup_molscore.py develop $git pull origin master $streamlit run molscore/config_generator.py Then I got: 2021-09-02 12:20:57.828 Traceback (most recent call last): File "/home/xzhang/miniconda3/envs/molscore/lib/python3.6/site-packages/streamlit/script_runner.py", line 350, in _run_script exec(code, module.dict) File "/home/xzhang/projects/MolScore_main/molscore/config_generator.py", line 10, in import molscore.scoring_functions as scoring_functions File "/home/xzhang/projects/MolScore_main/molscore/scoring_functions/init.py", line 1, in from molscore.scoring_functions.glide import GlideDock, GlideDockFromROCS File "/home/xzhang/projects/MolScore_main/molscore/scoring_functions/glide.py", line 11, in from rdkit.Chem.EnumerateStereoisomers import EnumerateStereoisomers, StereoEnumerationOptions, GetStereoisomerCount ImportError: cannot import name 'GetStereoisomerCount'

I modified molscore/scoring_functions/init.py into

from molscore.scoring_functions.glide import GlideDock, GlideDockFromROCS

from molscore.scoring_functions.smina import SminaDock from molscore.scoring_functions.rocs import ROCS from molscore.scoring_functions.oedock import FRED from molscore.scoring_functions.tanimoto import TanimotoSimilarity from molscore.scoring_functions.reinvent_svm import ActivityModel from molscore.scoring_functions.descriptors import RDKitDescriptors from molscore.scoring_functions.substructure_filters import SubstructureFilters from molscore.scoring_functions.substructure_match import SubstructureMatch from molscore.scoring_functions.sklearn_model import SKLearnModel, EnsembleSKLearnModel from molscore.scoring_functions.rascore_xgb import RAScore_XGB from molscore.scoring_functions.chemprop import ChemPropModel

all_scoring_functions = [ ROCS,

GlideDock,

GlideDockFromROCS,

SminaDock,
FRED,
RDKitDescriptors,
TanimotoSimilarity,
SubstructureFilters,
SubstructureMatch,
SKLearnModel,
EnsembleSKLearnModel,
RAScore_XGB,
ChemPropModel

] run $streamlit run molscore/config_generator.py I got: 2021-09-02 12:23:52.731 Traceback (most recent call last): File "/home/xzhang/miniconda3/envs/molscore/lib/python3.6/site-packages/streamlit/script_runner.py", line 350, in _run_script exec(code, module.dict) File "/home/xzhang/projects/MolScore_main/molscore/config_generator.py", line 10, in import molscore.scoring_functions as scoring_functions File "/home/xzhang/projects/MolScore_main/molscore/scoring_functions/init.py", line 6, in from molscore.scoring_functions.reinvent_svm import ActivityModel File "/home/xzhang/projects/MolScore_main/molscore/scoring_functions/reinvent_svm.py", line 11, in from sklearn.externals import joblib ImportError: cannot import name 'joblib'

MorganCThomas commented 3 years ago

I'm quite confused as to the order of things you've done here. If you used the updated master branch you shouldn't see the first error (if you click master branch in GitHub and then look at config_generator.p, line 193, the code reads key=f'{key_i}: sp_modifier' instead. So you must be using the old installation of molscore still (did you uninstall the old one with pip uninstall molscore?)

When installing the molscore_environment.yml, check the file to ensure that the rdkit version is specified (i.e. 'rdkit>=2019.03') in the dependencies, if it's not there, you're not using the most recent update.

Apologies for the last error, I should have commented out import molscore.scoring_functions.reinvent_svm import ActivityModel. This uses a script that requires a specific older sklearn version that also required a hot fix, if you wish to use this specific model you can install the dependency here by running the bash script found here generative_models/reinvent/install_scikit-learn.sh). This script is only needed for running the older DRD2 SVM model published in the original REINVENT publication - which you may not be interested in.

xuzhang5788 commented 3 years ago

Thank you for your reply. You are right. I git clone the master branch just before you update molscore_environment.yml. Maybe I will try it later

Refer to molscore/scoring_functions/init.py in the main branch I comment out

from molscore.scoring_functions.glide import GlideDock, GlideDockFromROCS

from molscore.scoring_functions.reinvent_svm import ActivityModel

from molscore.scoring_functions.chemprop import ChemPropModel

Then it works now. But I am not sure if those comment out lines will affect the performance.

GlideDock,

GlideDockFromROCS,

ChemPropModel

Then it works now. But I am not sure if those comment-out lines will affect the performance. Anyways, many thanks

MorganCThomas commented 3 years ago

Okay, in that case I'll close the issue, you should be able un-comment GlideDock & GlideDockFromROCS for use (with a license) as soon you ensure the rdkit version is 2019.03 or newer.

You should be able to run ChemProp once you install it, see here https://github.com/chemprop/chemprop