Class InChIToStructure


public class InChIToStructure extends Object

This class generates a CDK IAtomContainer from an InChI string. It places calls to a JNI wrapper for the InChI C++ library.

The generated IAtomContainer will have all 2D and 3D coordinates set to 0.0, but may have atom parities set. Double bond and allene stereochemistry are not currently recorded.
Example usage // Generate factory - throws CDKException if native code does not load
InChIGeneratorFactory factory = new InChIGeneratorFactory();
// Get InChIToStructure
InChIToStructure intostruct = factory.getInChIToStructure(
inchi, DefaultChemObjectBuilder.getInstance()

INCHI_RET ret = intostruct.getReturnStatus();
if (ret == INCHI_RET.WARNING) {
// Structure generated, but with warning message
System.out.println("InChI warning: " + intostruct.getMessage());
} else if (ret != INCHI_RET.OKAY) {
// Structure generation failed
throw new CDKException("Structure generation failed failed: " + ret.toString()
+ " [" + intostruct.getMessage() + "]");

IAtomContainer container = intostruct.getAtomContainer();

Sam Adams
Source code:
Belongs to CDK module:
  • Field Details

    • output

      protected io.github.dan2097.jnainchi.InchiInputFromInchiOutput output
    • options

      protected io.github.dan2097.jnainchi.InchiOptions options
    • molecule

      protected IAtomContainer molecule
  • Constructor Details

  • Method Details

    • generateAtomContainerFromInchi

      protected void generateAtomContainerFromInchi(IChemObjectBuilder builder) throws CDKException
      Gets structure from InChI, and converts InChI library data structure into an IAtomContainer.
    • getAtomContainer

      public IAtomContainer getAtomContainer()
      Returns generated molecule.
      An AtomContainer object
    • getReturnStatus

      @Deprecated public INCHI_RET getReturnStatus()
      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.
      the status
    • getMessage

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

      public String getLog()
      Gets generated log.
    • getWarningFlags

      public long[][] getWarningFlags()

      Returns warning flags, see INCHIDIFF in inchicmp.h.

      x=0 => Reconnected if present in InChI otherwise Disconnected/Normal
      x=1 => Disconnected layer if Reconnected layer is present
      y=1 => Main layer or Mobile-H
      y=0 => Fixed-H layer