Class InChIGenerator

java.lang.Object
org.openscience.cdk.inchi.InChIGenerator

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. 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 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

      protected IAtomContainer 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 public INCHI_RET getReturnStatus()
      Deprecated.
      use getStatus
      Gets 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

      public String getInchi()
      Gets generated InChI string.
    • getInchiKey

      public String getInchiKey() throws CDKException
      Gets generated InChIKey string.
      Throws:
      CDKException
    • getAuxInfo

      public String getAuxInfo()
      Gets auxillary information.
    • getMessage

      public String getMessage()
      Gets generated (error/warning) messages.
    • getLog

      public String getLog()
      Gets generated log.