kmansouri / OPERA

Free and open-source application (command line and GUI) providing QSAR models predictions as well as applicability domain and accuracy assessment for physicochemical properties, environmental fate and toxicological endpoints. ==================>Download the latest compiled version from the "releases" tab and run the executable installer.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using the python libraries

JenniferHem opened this issue · comments

Hi @kmansouri ,

I am interested in using OPERA, however to adapt it to our workflow I would really like to use it within Python. I managed to get everything running, however now that I have imported the library I am a bit stuck. How do I proceed from here to be able to access the models? Could you point me to any documentation or few examples which can get me started?
In addition: does the python library need a working installation of the OPERA Gui/CL? (so far I did only install the python libraries)

Thanks a lot!
Best,
Jennifer

Is there any answer to this question yet? I am having the same problem.

@vinnieribeiro unfortunately not

I'm also interested in this. In the past I've written a Python-based API wrapper that calls the OPERA CLI, but calling OPERA programmatically within Python would be ideal.

Hi all,

Thank you all for your interest and for using OPERA
Sorry for the delayed reply. Yes, it is possible to use the CLI version and call it from your Python code/app. If you want to use the provided Python library. You need to install it using the command: python setup.py install
for more information and details please take a look at the provided readme.txt.
You do not need to install the CLI version as well but if you did then you don't have to install the runtime again if you haven't then you'll need to install it. Then you just need to import libOPERA_Py to use it in your code.
Here's an example that probably might help: https://itectec.com/matlab/matlab-how-to-export-a-function-as-a-python-package-and-use-it-in-python/

An example with OPERA:

import libOPERA_Py as OPERA

opera = OPERA.initialize()
opera.OPERA('-s',<sdf_file_name>,'-o',<output_file_name>,'-a')

@kmansouri thank you for the tips. I just hat troubles to figure out what function would call Opera. I used @vinnieribeiros code and that was what I was missing. Tabcompletion did not show me that I can call opera.OPERA. Thank you both for your help.

I tried it yesterday and it worked well for most models. An Error occurs with the provided sample sdf file as well as with my own sdf when calling logD and pKa models (and thus also for the -a and -pc options). The command I called was:

pred = opera.OPERA('-s','.\Programs\libOPERA2_Py\Sample_50.sdf','-o','pred.sdf','-logd','-v',1)

However, for the endpoints logD and pKa I get the error:

MatlabRuntimeError: An error occurred when evaluating the result from a function. Details: 
  File C:\Users\HemmerJ3\AppData\Local\Temp\HemmerJ3\mcrCache9.4\libOPE0\libOPERA_Py\OPERA.m, line 3218, in OPERA
Undefined function 'svmpredict' for input arguments of type 'struct'.

In addition I noticed, that the output file is generated, however it stays empty. If I remove the output file I get back a matlab object, which does not seem to be convertible into any useable python datatype (sorry if this is just due to my lack of knowledge).

And a last question would be: In the input file directory many files are generated but never cleaned up. Is there a way to specify a temporary directory for the file generation?

I will look into the logd/pka error. I wasn't getting that before so I'll check it and get back to you.
For cleaning the temp files you should use the "-c" option as mentioned in the help file. You can also get the help commands by using the "-h" or "--help" option.

Thanks for all the info, @kmansouri. I'm testing out the Python library to use for our application. The install has gone well, now I get this message: "Python 3.7 is not supported" when I import the library. What versions of Python work with the libOPERA_Py package? Thanks!

Nevermind it's already in the docs. Just had to read hah

Hi, I tried to use the code @vinnieribeiro supplied, but I ran into an error.

Default install folder was changed during installation. Update OPERA_installdir.txt file in /g/g19/he6/.mcrCache9.4/libOPE0

It looks like it's looking for the CLI version of OPERA which I have not installed. @kmansouri, I thought I didn't need to install the CLI version of OPERA to use the python module, did I do something wrong?

Thanks!

I updated OPERA_installdir.txt to point to where I unpackaged the tarball. At first I ran into an error that said 'NaN can not be converted to a logistic', but that error has disappeared. Things appear to be working smoothly.

Thanks!

Thanks @stewarthe6! usually, a simple search of the PaDEL/CDK tools can reveal where the different files were installed and point to it would solve the problem.