Class InChIToStructure

java.lang.Object
org.openscience.cdk.inchi.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();


Author:
Sam Adams
Source code:
main
Belongs to CDK module:
inchi
  • 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.
      Throws:
      CDKException
    • getAtomContainer

      public IAtomContainer getAtomContainer()
      Returns generated molecule.
      Returns:
      An AtomContainer object
    • 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
    • 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][y]:
      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