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 or an AuxInfo string. It places calls to a JNI wrapper for the InChI C library.

It acts as a wrapper around the JNI-InChI library functions, parsing the InChI or AuxInfo string to regenerate the molecular structure.

The generated IAtomContainer will have all 2D and 3D coordinates set to 0.0, in case an InChI string was parsed. If an AuxInfo string was parsed the resulting IAtomContainer will have the same 2D or 3D coordinates as given in the AuxInfo string. If there are no coordinates given they are also set to 0.0. If only 2D coordinates are provided the Z-coordinate is 0.0. but may have atom parities set. Double bond and allene stereochemistry are not currently recorded. In some cases are no implicit hydrogens returned by the InChI API, if an AuxInfo string is parsed. To set hydrogens the CDKAtomTypeMatcher is intended.


Example usage

 String inchi = "InChI=1S/CH4/h1H4";
 InChIToStructure parser = InInChIToStructure.fromInChI(inchi, SilentChemObjectBuilder.getInstance);

 if (InChIStatus.SUCCESS.equals(parser.getStatus())
  IAtomContainer structure = parser.getAtomContainer();
 else
  System.err.println("Error parsing InChI: " + parser.getMessage());

 --------
 
 String auxInfo = "AuxInfo=1/0/N:1/rA:1nC/rB:/rC:10.425,-3.075,0;";
 InChIToStructure parser = InInChIToStructure.fromAuxInfo(auxInfo, SilentChemObjectBuilder.getInstance);

 if (InChIStatus.SUCCESS.equals(parser.getStatus())
  IAtomContainer structure = parser.getAtomContainer();
 else
  System.err.println("Error parsing AuxInfo: " + parser.getMessage());
 
Author:
Sam Adams, Felix Bänsch
  • Field Details

    • inchiOutput

      protected io.github.dan2097.jnainchi.InchiInputFromInchiOutput inchiOutput
    • auxinfoOutput

      protected io.github.dan2097.jnainchi.InchiInputFromAuxinfoOutput auxinfoOutput
    • options

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

      protected IAtomContainer molecule
  • Method Details

    • fromInChI

      public static InChIToStructure fromInChI(String inchi, IChemObjectBuilder builder, io.github.dan2097.jnainchi.InchiOptions opts) throws CDKException
      Generates IAtomContainer from InChI string.
      Parameters:
      inchi - String
      builder - IChemObjectBuilder
      opts - InChIOptions
      Returns:
      InChIToStructure object
      Throws:
      CDKException - if parsing the InChI fails.
    • fromInChI

      public static InChIToStructure fromInChI(String inchi, IChemObjectBuilder builder) throws CDKException
      Generates IAtomContainer from InChI string with default options.
      Parameters:
      inchi - String
      builder - IChemObjectBuilder
      Returns:
      InChIToStructure object
      Throws:
      CDKException - if parsing InChI fails.
    • fromInChI

      public static InChIToStructure fromInChI(String inchi, IChemObjectBuilder builder, String options) throws CDKException
      Generates IAtomContainer from InChi string.
      Parameters:
      inchi - String
      builder - IChemObjectBuilder
      options - String
      Returns:
      InChIToStructure object
      Throws:
      CDKException - if parsing InChI fails.
    • fromInChI

      public static InChIToStructure fromInChI(String inchi, IChemObjectBuilder builder, List<String> options) throws CDKException
      Generates IAtomContainer from InChi string.
      Parameters:
      inchi - String
      builder - IChemObjectBuilder
      options - List
      Returns:
      InChIToStructure object
      Throws:
      CDKException - if parsing InChI fails.
    • fromAuxInfo

      public static InChIToStructure fromAuxInfo(String auxInfo, IChemObjectBuilder builder) throws CDKException
      Generates IAtomContainer from AuxInfo string.

      It should be noted that issues such as the potential absence of hydrogen atoms may arise during the process of reconversion within the InChI API. It is important to note that the result should be checked.

      Parameters:
      auxInfo - String
      builder - IChemObjectBuilder
      Returns:
      InChIToStructure object
      Throws:
      CDKException - if parsing AuxInfo fails.
    • 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.

      For InChI input only.

    • getWarningFlags

      public long[][] getWarningFlags()
      Returns warning flags, see INCHIDIFF in inchicmp.h.

      For InChI input only.

      [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

    • getChiralFlag

      public Boolean getChiralFlag()
      Returns chiral flag, whether input structure is chiral or not.

      For AuxInfo input only.