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

QSARTuna - How to use models trained with QSARTuna #101

Closed JanoschMenke closed 4 months ago

JanoschMenke commented 4 months ago

Hi,

I was just wondering what the right process is to train a model with QSARTuna (I guess formally Qptuna) and then use it as a scoring component in Reinvent4.

I trained using QSARTuna models, however then I get the error:

  File "../comp_qptuna.py", line 73, in load_model
    model = pickle.load(mfile)
ModuleNotFoundError: No module named 'optunaz'

I tried installing QSARTuna in the Reinvent4 environment:

python -m pip install https://github.com/MolecularAI/QSARtuna/files/15091368/qsartuna-3.0.0.1.tar.gz

but this is not possible as: ERROR: Package 'qsartuna' requires a different Python: 3.10.14 not in '==3.10.10'

I could reininstall Reinvent4 with Python 3.10.10. But would that solve the issue? Below is the code that I used to generate the model, I am using buildconfig functionality:

study = optimize(config, study_name="my_study")
buildconfig = buildconfig_best(study)
build_best(buildconfig, f"{data_directory}{file}/{file}_model.pkl")

out = pickle.load(open(f"{data_directory}{file}/{file}_model.pkl", "rb"))
JanoschMenke commented 4 months ago

Reinstalling Reinvent4 with Python 3.10.10, and then installing qsartuna:

python -m pip install https://github.com/MolecularAI/QSARtuna/files/15091368/qsartuna-3.0.0.1.tar.gz

even tho there are some dependency issues, REINVENT can run and produce the scores.

But is this the way it is intended

halx commented 4 months ago

There is no clear guideline as to how to approach this because of the dependency issues you describe. QSARTuna has a rather conservative choice in the Python version. It used to work with the development version of QPtuna and it still seems to do so when you are happy to ignore dependency issues. For that reason, or actually because of scikit-learn, we have implemented the ExternalProcess scoring component such that the user can run any arbitrary code (in any arbitrary environment if needed).

JanoschMenke commented 4 months ago

Alright sounds good. I just wasn't sure if there is an official way to get Qptuna running in Reinvent.