CDK-R / rinchi

An R wrapper around the InChI functionality provided by the rcdk
1 stars 2 forks source link

The `parse.inchi()` function does not work with the `rcdklibs` package v2.8 #3

Open AndreySamokhin opened 1 year ago

AndreySamokhin commented 1 year ago

I have been using both the rcdk and the rinchi packages in my work. Thank you for creating them. The other day I decided to download the latest version of the rcdklibs package. I encountered a problem. The parse.inchi() function does not work with the rcdklibs package v2.8. This is an example:

mol <- parse.inchi("InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H")

#> Error in .jcall("net/sf/jniinchi/INCHI_RET", "Lnet/sf/jniinchi/INCHI_RET;",  : 
#>  method getValue with signature (I)Lnet/sf/jniinchi/INCHI_RET; not found

Session info:

R version 4.2.3 (2023-03-15 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)
...
other attached packages:
[1] rinchi_0.5   rcdk_3.7.0   rcdklibs_2.8 rJava_1.0-6 
...

The root of the problem is that the getValue method is not available for the rcdklibs package v2.8:

javap -classpath cdk-jniinchi-support-2.8.jar net/sf/jniinchi/INCHI_RET

Compiled from "INCHI_RET.java"
public final class net.sf.jniinchi.INCHI_RET extends java.lang.Enum<net.sf.jniinchi.INCHI_RET> {
  public static final net.sf.jniinchi.INCHI_RET SKIP;
  public static final net.sf.jniinchi.INCHI_RET EOF;
  public static final net.sf.jniinchi.INCHI_RET OKAY;
  public static final net.sf.jniinchi.INCHI_RET WARNING;
  public static final net.sf.jniinchi.INCHI_RET ERROR;
  public static final net.sf.jniinchi.INCHI_RET FATAL;
  public static final net.sf.jniinchi.INCHI_RET UNKNOWN;
  public static final net.sf.jniinchi.INCHI_RET BUSY;
  public static net.sf.jniinchi.INCHI_RET[] values();
  public static net.sf.jniinchi.INCHI_RET valueOf(java.lang.String);
  static {};
}

This is a kludge that I came up with to overcome the problem.

  1. Comment the first line (i.e., OKAY <- .jcall(...)) in the body of the parse.inchi() function.
  2. Add the following line instead of the commented one: OKAY <- J("net/sf/jniinchi/INCHI_RET")$OKAY.

Anyway, I'm looking forward to getting an official solution from the developers.

stanstrup commented 5 months ago

I can confirm this is still an issue with rcdklibs 2.9 repo with the hack above: https://github.com/stanstrup/rinchi/