User bfe5c11485
31-03-2016 18:45:42
I'm getting various errors trying to use the MolImporter to import an InChi string to obtain a Molecule. Note that I've been successful importing SMILES strings to get the Molecule, so the basic mechanism is working.
Sample Code
final String inchi = "InChI=1S/C2H8NO3P/c3-1-2-7(4,5)6/h1-3H2,(H2,4,5,6)";
MolImporter importer = null;
try {
// NOTE: I've tried calling without "inchi" option and get the same results:
importer = new MolImporter(new ByteArrayInputStream(inchi.getBytes()), "inchi");
Molecule molecule = importer.read();
// Assert.fail("Expected MolFormatException for inchiKey!");
} catch (IOException e) {
e.printStackTrace();
} finally {
IOUtils.INSTANCE.closeCloseable(importer, "We couldn't close the InChi importer!");
}
Specific Problem (Junit Test Output)
Running com.agilent.amp.unittests.ChemAxonTest
Mar 31, 2016 11:22:45 AM chemaxon.marvin.io.formats.inchi.Inchi installFromResource
WARNING: could not open from resource: inchi64.dll
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.283 sec <<< FAILURE! - in com.agilent.amp.unittests.ChemAxonTest
MoleculeImporterTest(com.agilent.amp.unittests.ChemAxonTest) Time elapsed: 0.27 sec <<< ERROR!
java.lang.IllegalAccessError: tried to access method net.sf.jniinchi.JniInchiStructure.getAtomIndex(Lnet/sf/jniinchi/JniInchiAtom;)I from class chemaxon.marvin.io.formats.inchi.InchiImport
at com.agilent.amp.unittests.ChemAxonTest.MoleculeImporterTest(ChemAxonTest.java:67)
Maven pom.xml
Note that I've had to add other dependencies for jchem that I would have thought are self contained. I've also tried directly using the jchem.jar library (without maven) and get the same problem:
<repository>
<id>jni-inchi</id>
<name>JNI-InChI Maven Repository</name>
<url>http://jni-inchi.sourceforge.net/m2repo</url>
</repository>
<repository>
<id>ChemAxon Public Repository</id>
<url>https://repository.chemaxon.com/artifactory/libs-release</url>
</repository>
<!-- Chemaxon molImporter uses PIG(?) which requires the following: -->
<dependency>
<groupId>dk.brics.automaton</groupId>
<artifactId>automaton</artifactId>
<version>1.11-8</version>
</dependency>
<!-- Chemaxon molImporter uses jni-inchi: -->
<dependency>
<groupId>net.sf.jni-inchi</groupId>
<artifactId>jni-inchi</artifactId>
<version>0.7</version>
</dependency>
<dependency>
<groupId>com.chemaxon</groupId>
<artifactId>jchem</artifactId>
<version>16.1.18.0</version>
</dependency>
System
Java 1.8.0_71, Windows 7, JChem Java library 16.1.18.0 (both via Maven repository and direct use from jchem.jar)