Open egonw opened 6 months ago
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"
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.
> 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
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
Looks like theres a different code path for OSX vs Windows/Linux
@rajarshi any chance you can take a look at this one?
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>
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()
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...
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 ... )
Can you show me how you are getting mol? e.g. did you paste my exact code? The class/type of mol
is wrong.
you could try doing mol[[1]] (Its probably coming in as a list)
On Thu, May 2, 2024 at 7:55 AM zachcp @.***> wrote:
Can you show me how you are getting mol? e.g. did you paste my exact code? The class/type of mol is wrong.
— Reply to this email directly, view it on GitHub https://github.com/CDK-R/cdkr/issues/152#issuecomment-2090731175, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAIMOIINFWDN5KUCYUAXZLZAJHWTAVCNFSM6AAAAABHA57S7OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJQG4ZTCMJXGU . You are receiving this because you were mentioned.Message ID: @.***>
-- Rajarshi Guha | http://blog.rguha.net | @rguha https://twitter.com/rguha
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()
Given this code (in RStudio):
The last code fails with this exception:
Screenshots If applicable, add screenshots to help explain your problem.
System: