Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

visualization with view.molecule.2d fails with an <init> error message #152

Open
egonw opened this issue Apr 30, 2024 · 11 comments
Open

visualization with view.molecule.2d fails with an <init> error message #152

egonw opened this issue Apr 30, 2024 · 11 comments

Comments

@egonw
Copy link
Contributor

egonw commented Apr 30, 2024

Given this code (in RStudio):

library(rcdk)

cxSMILES = "O=C(*)Oc1ccc(cc1)C(C)(C)c1ccc(O*)cc1 |Sg:n:0,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20::ht| Poly(bisphenol-A-carbonate"
mol = rcdk::parse.smiles(cxSMILES)
rcdk::view.molecule.2d(mol)

The last code fails with this exception:

Error in rcdk::view.molecule.2d(mol) : 
  java.lang.NoSuchMethodError: <init>

Screenshots
If applicable, add screenshots to help explain your problem.

System:

  • Java Version: 17.0.11+9-Debian-1deb12u1
  • sessionInfo()
R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Debian GNU/Linux 12 (bookworm)

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.21.so;  LAPACK version 3.11.0

locale:
 [1] LC_CTYPE=en_US.UTF-8          LC_NUMERIC=C                  LC_TIME=C                    
 [4] LC_COLLATE=en_US.UTF-8        LC_MONETARY=en_US.UTF-8       LC_MESSAGES=en_US.UTF-8      
 [7] LC_PAPER=en_US.UTF-8          LC_NAME=en_US.UTF-8           LC_ADDRESS=en_US.UTF-8       
[10] LC_TELEPHONE=en_US.UTF-8      LC_MEASUREMENT=en_US.UTF-8    LC_IDENTIFICATION=en_US.UTF-8

time zone: Europe/Amsterdam
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rcdk_3.8.1   rcdklibs_2.9 rJava_1.0-6 

loaded via a namespace (and not attached):
[1] compiler_4.4.0    parallel_4.4.0    fingerprint_3.5.7 tools_4.4.0       iterators_1.0.14  itertools_0.1-3  
[7] png_0.1-8        
@schymane
Copy link
Contributor

schymane commented Apr 30, 2024

I confirm the same ...

> ext_smiles <- "O=C(*)Oc1ccc(cc1)C(C)(C)c1ccc(O*)cc1 |Sg:n:0,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20::ht| Poly(bisphenol-A-carbonate)"
> mol <- rcdk::parse.smiles(ext_smiles)
> view.molecule.2d(mol)
Error in view.molecule.2d(mol) : java.lang.NoSuchMethodError: <init>

SessionInfo:


> sessionInfo()
R version 4.3.3 (2024-02-29 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
[1] LC_COLLATE=English_Australia.utf8  LC_CTYPE=English_Australia.utf8   
[3] LC_MONETARY=English_Australia.utf8 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.utf8    

time zone: Europe/Paris
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rcdk_3.8.1   rcdklibs_2.9 rJava_1.0-11

Java version:

> .jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
[1] "1.8.0_401-b10"

@zachcp
Copy link
Contributor

zachcp commented May 1, 2024

Hmm. I don't replicate this on my machine; I can see the molecule fine. I'll try an isolated build. Is there a further stacktrace? Looks like I'm on Mac you two are on Debian and Windows respectively.

image
> sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.4.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rcdk_3.8.1   rcdklibs_2.9 rJava_1.0-11

loaded via a namespace (and not attached):
[1] compiler_4.3.2    parallel_4.3.2    fingerprint_3.5.7 tools_4.3.2      
[5] iterators_1.0.14  itertools_0.1-3   png_0.1-8   

@zachcp
Copy link
Contributor

zachcp commented May 1, 2024

I can try a few other JVMs.

>  .jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
[1] "20.0.1+9-jvmci-23.0-b12"

Edit: I tried R with java8 and java 21. They work fine

@zachcp
Copy link
Contributor

zachcp commented May 1, 2024

Looks like theres a different code path for OSX vs Windows/Linux

@rajarshi any chance you can take a look at this one?

image

@zachcp
Copy link
Contributor

zachcp commented May 1, 2024

Okay I can replicate this. looks like a type error in the initialization call. I don't remember any changes to this recently though so its a bit odd not to have surfaced much earlier....

In my view rcdk should move away from having special compiled Java classes as the extra compilation steps make everything much harder. I also would move away from Java-GUIs for the same reason and move VIZ into base R via PNG/ SVG/files.

@egonw and @schymane - are you heavily reliant on the Java AWT bits?

v2d <- .jnew("org/guha/rcdk/view/ViewMolecule2D", mol, as.integer(200), as.integer(200), depictor)
Error: java.lang.NoSuchMethodError: <init>

@zachcp
Copy link
Contributor

zachcp commented May 1, 2024

Note: You can also use the Depict Package for viz.

devtools::install_github("CDK-R/depict")
library(depict)

cxSMILES = "O=C(*)Oc1ccc(cc1)C(C)(C)c1ccc(O*)cc1 |Sg:n:0,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20::ht| Poly(bisphenol-A-carbonate"
mol <- parse_smiles(cxSMILES)

depiction() |>
  set_zoom(2) |>
  depict(mol) |>
  get_image() |>
  grid::rasterGrob() |>
  grid::grid.draw()

image

@schymane
Copy link
Contributor

schymane commented May 1, 2024

Ok cool we thought about the depict package yesterday but weren't sure and used the inbuilt one instead. We don't think we're heavily reliant on the AWT parts...
We can try depict one back from the excursion...

@schymane
Copy link
Contributor

schymane commented May 2, 2024

So we tried to use your depict code to visualize and that didn't work for us either :-(
Any idea what I've done wrong?

> library(depict)
> depiction() |>
+     set_zoom(2) |>
+     depict(mol) |>
+     get_image() |>
+     grid::rasterGrob() |>
+     grid::grid.draw()
Error in checkJavaClass(mol, c("org/openscience/cdk/AtomContainer", "org/openscience/cdk/AtomContainer2",  : 
  this is not a Java Object
> depiction() |>
+     set_zoom(2) |>
+     depict(mol[[1]]) |>
+     get_image() |>
+     grid::rasterGrob() |>
+     grid::grid.draw()
Error in depict(set_zoom(depiction(), 2), mol[[1]]) : 
  depict requires an AtomContainer, Reaction, ReactionSet, or an ArrayList of them

(I get the same irrespective of how "mol" was created, but the mol is creating valid output in other areas ... )

@zachcp
Copy link
Contributor

zachcp commented May 2, 2024

Can you show me how you are getting mol? e.g. did you paste my exact code? The class/type of mol is wrong.

@rajarshi
Copy link
Collaborator

rajarshi commented May 2, 2024 via email

@schymane
Copy link
Contributor

schymane commented May 2, 2024

ahh parse_smiles not parse.smiles ... so we have to use the depict read-in not the rcdk read-in, that's confusing ... sorry, missed that ...

> cxSMILES = "O=C(*)Oc1ccc(cc1)C(C)(C)c1ccc(O*)cc1 |Sg:n:0,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20::ht| Poly(bisphenol-A-carbonate"
> mol <- parse_smiles(cxSMILES)
> 
> depiction() |>
+   set_zoom(2) |>
+   depict(mol) |>
+   get_image() |>
+   grid::rasterGrob() |>
+   grid::grid.draw()

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants