@TestClass(value="org.openscience.cdk.inchi.InChIGeneratorTest") public class InChIGenerator extends Object
This class generates the IUPAC International Chemical Identifier (InChI) for a CDK IAtomContainer. It places calls to a JNI wrapper for the InChI C++ library.
If the atom container has 3D coordinates for all of its atoms then they will be used, otherwise 2D coordinates will be used if available.
Spin multiplicities and some aspects of stereochemistry are not currently handled completely.
// Generate factory - throws CDKException if native code does not load
InChIGeneratorFactory factory = new InChIGeneratorFactory();
// Get InChIGenerator
InChIGenerator gen = factory.getInChIGenerator(container);
INCHI_RET ret = gen.getReturnStatus();
if (ret == INCHI_RET.WARNING) {
// InChI generated, but with warning message
System.out.println("InChI warning: " + gen.getMessage());
} else if (ret != INCHI_RET.OKAY) {
// InChI generation failed
throw new CDKException("InChI failed: " + ret.toString()
+ " [" + gen.getMessage() + "]");
}
String inchi = gen.getInchi();
String auxinfo = gen.getAuxInfo();
TODO: distinguish between singlet and undefined spin multiplicity
TODO: double bond and allene parities
TODO: problem recognising bond stereochemistry
Modifier and Type | Method and Description |
---|---|
String |
getAuxInfo()
Gets auxillary information.
|
String |
getInchi()
Gets generated InChI string.
|
String |
getInchiKey()
Gets generated InChIKey string.
|
String |
getLog()
Gets generated log.
|
String |
getMessage()
Gets generated (error/warning) messages.
|
net.sf.jniinchi.INCHI_RET |
getReturnStatus()
Gets return status from InChI process.
|
@TestMethod(value="testGetInchiFromLandDAlanine3D,testGetInchiEandZ12Dichloroethene2D") public net.sf.jniinchi.INCHI_RET getReturnStatus()
@TestMethod(value="testGetInchiEandZ12Dichloroethene2D,testGetInchiFromEthyne,testGetInchiFromEthene") public String getInchi()
@TestMethod(value="testGetInchiFromEthane") public String getInchiKey() throws CDKException
CDKException
@TestMethod(value="testGetAuxInfo") public String getAuxInfo()
@TestMethod(value="testGetMessage,testGetWarningMessage") public String getMessage()
@TestMethod(value="testGetLog") public String getLog()