zachcp / chemdoodle

htmlwidgets for chemdoodle web components
http://zachcp.github.io/chemdoodle/
18 stars 9 forks source link

remove rJava dependency? #5

Closed chapmandu2 closed 7 years ago

chapmandu2 commented 8 years ago

Hi,

This is great, I was looking for something to depict compound structures well in a shiny app and this is perfect. Had you considered removing the rJava dependency though (thru rcdk) since this a major pain especially when trying to deploy shiny apps or get installed on other people's machines. The ChemmineR and ChemmineOB bioconductor packages use the C++ OpenBabel library instead which is arguably more straightfoward, but the graphical depiction of structures is horrible and non-interactive. As I see it from looking at your code you're just using rcdk's functions to swap between SMILES, Inchi etc rather than writing your own, but then you have your own code to get the JSON out to be sent to the ChemDoodle API which then does all the lovely rendering.

I work for a drug discovery group funded by Cancer Research UK and we're looking to make a shiny app to create a dashboard from our Dotmatics database of screening data, thanks again for creating this!.

Phil

zachcp commented 8 years ago

Hi @chapmandu2,

Glad you like this package! Unfortunately, as it is currently configured, CDK is absolutely necessary as it is used to parse smiles strings and it performs the structure layout. If you are having problems using it you may need to ensure that your system Java is Java8. It works for me and it seems to have worked for others (see https://github.com/zachcp/chemdoodle/issues/4).

With that said, you could definitely use ChemmineR or ChemmineOB as a backend for Chemdoodle on Shiny - you would only need to figure out how to access the atom/position data. Then you convert that to JSON and send it to ChemDoodle. Note that in this repo i don't use any of ChemDoodle's server-side stuff (layout, etc) - it is all handled on the R/Shiny-side by rCDK/CDK.

If you just need depictions I highly recommend checking out @johnmay s work on CDK-depict. For example see here. I also have a barebones wrapper for his new Depict code in this repo, which you may be interested in.

The primary unique utility of this repo would be able to communicate back and forth between the browser and CDK using Shiny. However, the code would need some work to get the scaling correct when placing molecules on Canvas (the atom positions need to be scaled either on the server or the client to get the molecule to look pretty), which you're welcome to play around with. I think a Chemdoodle front end backed by CDK could be a nice combo.

zach cp

johnmay commented 8 years ago

For maximising portability Zach CDK should be 1.7 compatible - for absolute maximum compatibility you can distribute a JRE (openjdk) however you'll hit the same problems with OB which is the native dependency. Not sure how that's handled here with Shiney.

chapmandu2 commented 8 years ago

Hi Zach,

Thanks for pointing me to CDK-depict and your wrapper. This actually may be more appropriate to what I want to do since I do just want nice looking depictions rather than being able to interact with the structure. I'll take a look.

As you say the rJava stuff gets you there eventually but there do seem to be quite a few hurdles: having the right JDK and version of Java, ensuring that R is configured properly to connect with Java, and then there's even an RStudio/rJava issue whereby it worked in the terminal but not in RStudio. All that said, if the primary means of deployment is via shiny on a server then as long as you have it configured correctly on the server then that's all you need to accomplish.

I did notice that ChemDoodle has a function for depicting Molfiles rather than its own JSON output, I will take a look at this as Dotmatics stores compound structures as all of SMIleS, INCHI and Molfiles. So I might just be able to take a shortcut and depict the structure that way.

Finally, just to give you an idea of what I'm aiming for, its going to essentially be a datatable of many compounds with one column as a compound depiction and then other columns as various compound properties and assay results. Something like the table panel in this screenshot: http://www.dotmatics.com/products/vortex/

Once I get there this could be wrapped up into a function/package for depicting compound structures in a datatable, I'll let you know how I get on.

zachcp commented 7 years ago

rCDK 3.3.8 uses J7