Hi everybody,
apologies in advance if this topic has already been dealt with and I haven't been able to find it.
I have tried to access RDKit functionality not available within existing nodes through the Java Snippet node. I have added org.RDKit.jar to the "Additional Libraries" and I have tried running the following snippet:
//System.load("C:/Program Files/KNIME_3.1.2/plugins/org.rdkit.knime.bin.win32.x86_64_3.0.0.v201606050430/os/win32/x86_64/GraphMolWrap.dll");
ROMol m = RWMol.MolFromMolBlock(c_Molecule, true, false);
if (m != null) {
RDKFuncs.assignStereochemistry(m, false, true, true);
out_nChiral_1 = 0;
for (int i = 0; i < m.getNumAtoms(); ++i) {
if ((m.getAtomWithIdx(i).getChiralTag() != Atom.ChiralType.CHI_UNSPECIFIED)
|| m.getAtomWithIdx(i).hasProp("_ChiralityPossible"))
++out_nChiral_1;
}
}
This unfortunately fails with the error message:
java.lang.UnsatisfiedLinkError: org.RDKit.RDKFuncsJNI.RWMol_MolFromMolBlock__SWIG_0(Ljava/lang/String;ZZ)J
However, if I attempt to load the DLL uncommenting the first line in the Java Snippet node, I get the following error message:
java.lang.UnsatisfiedLinkError: Native Library C:\Program Files\KNIME_3.1.2\plugins\org.rdkit.knime.bin.win32.x86_64_3.0.0.v201606050430\os\win32\x86_64\GraphMolWrap.dll already loaded in another classloader
Googling for this issue I found a few reports of similar cases, but no solution. In this one:
https://tech.knime.org/forum/knime-users/java-snippet-having-two-java-snippets-using-a-jni-library-causes-unsatisfiedlinker#comment-form
Thorsten seems to suggest that, as long as the DLL is included in a plugin which is loaded when KNIME starts, things should work, but this does not seem to be the case.
What am I doing wrong? Is it possible at all to try to access RDKit functionality within a Java Snippet node? That would be REALLY nice, if it were possible. I know I can use the Python Snippet node for the same purpose, but that requires a local RDKit install, while the Java Snippet could use the KNIME RDKit plugin.
Please do not suggest alternative ways to achieve the above with existing KNIME nodes - this is just an example, and I am aware I can count chiral centres using existing KNIME nodes. I would like to learn, if it is possible, how to access RDKit functionality within the Java Snippet node.
Thanks a lot in advance, kind regards
Paolo