JChem Integration with Perl

User be1039f1ca

20-04-2006 13:16:19

I have imported some mol files and setup a database (MSSQL) using "jcman". I also have "Marvin" passing mol files into my perl script. I'm having difficulty figuring out how to execute the actual search from my perl script.





What I need is something I can pass the target mol file and search parameters to and it will return a list of "cd_ids" that match the search.





I have played with "jcsearch" but I doesn't seem to be able to give me a list of "cd_ids", it just wants to give me the results as mol files or SMILES.





I'm looking into calling the Java functions directly from within my perl script, but I was hoping from for something less complicated.





Any suggestions?





Thanks.

ChemAxon a3d59b832c

21-04-2006 07:23:57

Hi,





You are right, jcsearch does not currently have an option to return cd_id-s.





If you were using Oracle, I would recommend JChem Cartridge, which can be used from any environment accessing oracle SQL. ( http://www.chemaxon.com/jchem/index.html?content=doc/guide/cartridge/index.html )





I don't know how easily perl can be integrated with java. Python users have the lucky situation to have jython. See: http://www.chemaxon.com/forum/ftopic143.html





If it is not very urgent, we can put cd_id return option into jcsearch from the next release.





Best regards,


Szabolcs

User be1039f1ca

21-04-2006 14:07:16

Szabolcs wrote:
Hi,


If it is not very urgent, we can put cd_id return option into jcsearch from the next release.


How long until the next release?


I could write the perl software to do a lookup based on cd_smiles (which jcsearch will return) as a temporary measure. That way I could get most of the perl code working while I wait for the new version of jcsearch.





I think this would be the smoothest way for me to integrate JChem with the data and code we already have.





I'm checking into perl and java integration now. I'll let you know what I find.

ChemAxon aa7c50abf8

21-04-2006 14:52:47

Hi,





I guess you are aware that using jcsearch the way you intend to use it is very inefficient. Each time you call jcsearch, the Java runtime will be (re)started and, perhaps more importantly, the structure cache will have to be built up from scratch again and again.





Cheers,


Peter

User be1039f1ca

21-04-2006 15:14:27

pkovacs wrote:



I guess you are aware that using jcsearch the way you intend to use it is very inefficient. Each time you call jcsearch, the Java runtime will be (re)started and, perhaps more importantly, the structure cache will have to be built up from scratch again and again.
I hadn't really though of this. Even if I call the "JChemSearch" inline from perl this will still be the case correct?





So do I need to run a Java Application Server like Tomcat to make sure I'm using JChemSearch effectively? Then my IIS/Perl server can request search results from it?

ChemAxon aa7c50abf8

21-04-2006 15:46:01

nathand wrote:



I hadn't really though of this. Even if I call the "JChemSearch" inline from perl this will still be the case correct?
I am not sure I see what you mean by 'calling the "JChemSearch" inline from perl'.
nathand wrote:



So do I need to run a Java Application Server like Tomcat to make sure I'm using JChemSearch effectively? Then my IIS/Perl server can request search results from it?
Yes. Look at the example under http://www.chemaxon.com/jchem/examples/jsp1_x/. One of the options seems to be to set up this example and communicate with it via http.





Cheers,


Peter

User be1039f1ca

21-04-2006 15:57:15

pkovacs wrote:



I am not sure I see what you mean by 'calling the "JChemSearch" inline from perl'.
It would be similar to what python users are doing here:


http://www.chemaxon.com/forum/ftopic143.html

ChemAxon aa7c50abf8

21-04-2006 16:44:16

Not being a Jython expert (actually this is the first time I hear of it), from the single-phrase description of Jython by Szabolcs I infer that Jython code makes direct references to native Java objects, ie. (1) your python implementation runs in the same process as the JChem objects being referred to and (2) the lifecycle of the JChem objects themselves is completely identical to the lifecycle of their python proxies (the JChem objects' references in the python code).





If my assumptions above about Jython are correct and if Jython can be integrated with an HTTP server so that the underlying Java runtime keeps its state across calls made in the same HTTP session, then efficiency is most probably better than with jcsearch by orders of magnitude.





I am not sure how relevant this is for your perl environment. Is there a perl interpreter written in Java with features similar to Jython's (or with features I assume Jython has)?





Cheers,


Peter

User be1039f1ca

21-04-2006 17:24:59

I think I missunderstood what Jython was.





For Perl with inline Java the lifecycle of the JChem objects is the same as the perl script, which in my case might just be single search. I'll have to look into this as it relates to PerlEx and ISAPIPerl.

ChemAxon a3d59b832c

21-04-2006 21:23:41

As far as I know, jython is a python implementation written in java. Therefore it has a native hook to java functionality, and all java calls from jython scripts run in the same JRE as the script itself.





I agree with Peter. If your perl script only performs a few searches and is restarted many times, an application server or a web service may be the best solution.





Is it not an option moving to Oracle? This would make this whole problem void as JChem Cartridge is available directly from perl.





Best regards,


Szabolcs

User be1039f1ca

24-04-2006 20:15:05

Szabolcs wrote:
I agree with Peter. If your perl script only performs a few searches and is restarted many times, an application server or a web service may be the best solution.
I'm looking into setting up Tomcat to work with apache or IIS6 to do this now.
Szabolcs wrote:



Is it not an option moving to Oracle? This would make this whole problem void as JChem Cartridge is available directly from perl.
This would be a fairly complicated change for us since we have so much invested in MS-SQL right now. (obviously JChem Cartridge for MS-SQL would be perfect, but I understand the difficulties with that.) I think it will be easier to get Tomcat to work with apache or IIS6 and have perl make an HTTP request to a jsp? script that would return matches.

ChemAxon a3d59b832c

25-04-2006 05:51:53

Hi Nathan,





Thanks for the update. Let us know if you need help on the Tomcat side.





All the best,


Szabolcs

User be1039f1ca

02-05-2006 01:37:46

Okay I got tomcat installed and the demos working. I also was able to easily import my mol files including a custom field using SD files. However, the demos at /jchem/examples/jsp1_x are far more complicated than I need.





I need to strip out the session handling, hard code the database connection information and modify the search so that it will just return cd_ids. Not being familiar with java, this looks like it may take me a while to modify through trial and error. Do you have anything that will push me in the right direction.





It looks like I could hard code the connection values in init.jsp (this installation will not be publicly accessable). It also looks like the main searching happens in searching.jsp.





Thanks.

ChemAxon 9c0afc9aaf

02-05-2006 09:05:31

Hi,





I have attached a simpler example.





Please also take a look at these pages:





Our Java API:


http://www.chemaxon.com/jchem/doc/api/





Developers' guide:


http://www.chemaxon.com/jchem/doc/guide/





Best regards,





Szilard

User be1039f1ca

05-05-2006 21:24:27

The simplified example is exactly what I needed. I'm almost there.


Thanks.

ChemAxon 43e6884a7a

18-05-2006 17:40:41

Nathan,


Have you solved the problem?


I think many forum readers would be interested in the technical details of the integration with Perl. Could you submit some useful details or even some source code? (Either here or at the Contributions forum)

User be1039f1ca

18-05-2006 17:55:50

I do have it working. However, the code is still a bit rough. I'm working on cleaning it up, but I know VERY little about Java. I'm also still working on the error handling. Once this is done, I should be able to post some code.