Class InChIGenerator
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.
Example usage
// 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
- Author:
- Sam Adams
- Source code:
- main
- Belongs to CDK module:
- inchi
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IAtomContainer
AtomContainer instance refers to.protected final io.github.dan2097.jnainchi.InchiInput
protected io.github.dan2097.jnainchi.InchiOptions
protected io.github.dan2097.jnainchi.InchiOutput
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
InChIGenerator
(IAtomContainer atomContainer, boolean ignoreAromaticBonds) Constructor.protected
InChIGenerator
(IAtomContainer atomContainer, io.github.dan2097.jnainchi.InchiOptions options, boolean ignoreAromaticBonds) protected
InChIGenerator
(IAtomContainer atomContainer, String optStr, boolean ignoreAromaticBonds) Constructor.protected
InChIGenerator
(IAtomContainer atomContainer, List<INCHI_OPTION> opts, boolean ignoreAromaticBonds) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionGets auxillary information.getInchi()
Gets generated InChI string.Gets generated InChIKey string.getLog()
Gets generated log.Gets generated (error/warning) messages.Deprecated.use getStatusio.github.dan2097.jnainchi.InchiStatus
Access the status of the InChI output.
-
Field Details
-
options
protected io.github.dan2097.jnainchi.InchiOptions options -
input
protected final io.github.dan2097.jnainchi.InchiInput input -
output
protected io.github.dan2097.jnainchi.InchiOutput output -
atomContainer
AtomContainer instance refers to.
-
-
Constructor Details
-
InChIGenerator
protected InChIGenerator(IAtomContainer atomContainer, io.github.dan2097.jnainchi.InchiOptions options, boolean ignoreAromaticBonds) throws CDKException - Throws:
CDKException
-
InChIGenerator
protected InChIGenerator(IAtomContainer atomContainer, boolean ignoreAromaticBonds) throws CDKException Constructor. Generates InChI from CDK AtomContainer.
Reads atoms, bonds etc from atom container and converts to format InChI library requires, then calls the library.
- Parameters:
atomContainer
- AtomContainer to generate InChI for.ignoreAromaticBonds
- if aromatic bonds should be treated as bonds of type single and double- Throws:
CDKException
- if there is an error during InChI generation
-
InChIGenerator
protected InChIGenerator(IAtomContainer atomContainer, String optStr, boolean ignoreAromaticBonds) throws CDKException Constructor. Generates InChI from CDK AtomContainer.
Reads atoms, bonds etc from atom container and converts to format InChI library requires, then calls the library.
- Parameters:
atomContainer
- AtomContainer to generate InChI for.optStr
- Space or comma delimited string of options to pass to InChI library. Each option may optionally be preceded by a command line switch (/ or -).ignoreAromaticBonds
- if aromatic bonds should be treated as bonds of type single and double- Throws:
CDKException
-
InChIGenerator
@Deprecated protected InChIGenerator(IAtomContainer atomContainer, List<INCHI_OPTION> opts, boolean ignoreAromaticBonds) throws CDKException Deprecated.Constructor. Generates InChI from CDK AtomContainer.
Reads atoms, bonds etc from atom container and converts to format InChI library requires, then calls the library.
- Parameters:
atomContainer
- AtomContainer to generate InChI for.opts
- List of INCHI_OPTION.ignoreAromaticBonds
- if aromatic bonds should be treated as bonds of type single and double- Throws:
CDKException
-
-
Method Details
-
getReturnStatus
Deprecated.use getStatusGets return status from InChI process. OKAY and WARNING indicate InChI has been generated, in all other cases InChI generation has failed. This returns the JNI INCHI enum and requires the optional "cdk-jniinchi-support" module to be loaded (or the full JNI InChI lib to be on the class path). -
getStatus
public io.github.dan2097.jnainchi.InchiStatus getStatus()Access the status of the InChI output.- Returns:
- the status
-
getInchi
Gets generated InChI string. -
getInchiKey
Gets generated InChIKey string.- Throws:
CDKException
-
getAuxInfo
Gets auxillary information. -
getMessage
Gets generated (error/warning) messages. -
getLog
Gets generated log.
-