MolImporter: Problems Creating Molecule From InChi String

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)

ChemAxon 044c6721bc

01-04-2016 14:20:09

Hi,


The code works well in my computer, so you are right about that. Can you check the inchi64.dll file in your home\chemaxon\lib\inchi-(version) folder and the CHEMAXON_HOME environment variable?


Janos

User bfe5c11485

01-04-2016 17:17:57

I don't have any ChemAxon stuff directly installed on my machine except for whatever Maven downloads to my local maven repository. I'm trying to use the jchem library from a Java application (via Maven) to run calculators and do substructure searching (which mostly works).


So, does the MolImporter, for inchi, require some ChemAxon .dll -based software to be installed on the machine where the application is running?


 

ChemAxon 044c6721bc

04-04-2016 07:27:59

Hi,


Can you check your local maven repo for the inchi64.dll file?


I think you doesn't need any installed ChemAxon software to make the inchi import work, but you can try installing MarvinBeans.