Class InChIGeneratorFactory


  • public class InChIGeneratorFactory
    extends Object

    Factory providing access to InChIGenerator and InChIToStructure. See those classes for examples of use. These methods make use of the JNI-InChI library.

    The InChIGeneratorFactory is a singleton class, which means that there exists only one instance of the class. An instance of this class is obtained with:

     InChIGeneratorFactory factory = InChIGeneratorFactory.getInstance();
     

    InChI/Structure interconversion is implemented in this way so that we can check whether or not the native code required is available. If the native code cannot be loaded during the first call to getInstance method (when the instance is created) a CDKException will be thrown. The most common problem is that the native code is not in the * the correct location. Java searches the locations in the PATH environmental variable, under Windows, and LD_LIBRARY_PATH under Linux, so the JNI-InChI native libraries must be in one of these locations. If the JNI-InChI jar file is being used and either the current working directory, or '.' are contained in PATH of LD_LIBRARY_PATH then the native code should be placed automatically. If the native files are in the correct location but fail to load, then they may need to be recompiled for your system. See:

    • http://sourceforge.net/projects/jni-inchi
    • http://www.iupac.org/inchi/
    Author:
    Sam Adams
    Source code:
    main
    Belongs to CDK module:
    inchi
    • Method Detail

      • getInstance

        public static InChIGeneratorFactory getInstance()
                                                 throws CDKException
        Gives the one InChIGeneratorFactory instance, if needed also creates it.
        Returns:
        the one InChIGeneratorFactory instance
        Throws:
        CDKException - if unable to load native code when attempting to create the factory
      • setIgnoreAromaticBonds

        @Deprecated
        public void setIgnoreAromaticBonds​(boolean ignore)
        Deprecated.
        "the use of aromatic bonds is strongly discouraged" - InChI FAQ, the InChI will fail for many compounds if ignore aromatic bonds is not enabled and the compound have aromatic flags.
        Sets whether aromatic bonds should be treated as single and double bonds for the InChI generation. The bond type INCHI_BOND_TYPE.ALTERN is considered special in contrast to single, double, and triple bonds, and is not bulletproof. If the molecule has clearly defined single and double bonds, the option can be used to force the class not to use the alternating bond type.

        http://www.inchi-trust.org/fileadmin/user_upload/html/inchifaq/inchi-faq.html#16.3

        Parameters:
        ignore - if aromatic bonds should be treated as bonds of type single and double
      • getIgnoreAromaticBonds

        @Deprecated
        public boolean getIgnoreAromaticBonds()
        Deprecated.
        Returns whether aromatic bonds are treated as single and double bonds for the InChI generation.
        Returns:
        if aromatic bonds are treated as bonds of type single and double
      • getInChIGenerator

        public InChIGenerator getInChIGenerator​(IAtomContainer container,
                                                String options)
                                         throws CDKException
        Gets InChI generator for CDK IAtomContainer.
        Parameters:
        container - AtomContainer to generate InChI for.
        options - Space or comma delimited string of options for InChI generation.
        Returns:
        the InChI generator object
        Throws:
        CDKException - if the generator cannot be instantiated
      • getInChIGenerator

        public InChIGenerator getInChIGenerator​(IAtomContainer container,
                                                io.github.dan2097.jnainchi.InchiOptions options)
                                         throws CDKException
        Get an InChI generator providing flags to customise the generation.
        Parameters:
        container - the molecule
        options - the inchi option flags
        Returns:
        the InChI generator
        Throws:
        CDKException - something went wrong
      • getInChIToStructure

        public InChIToStructure getInChIToStructure​(String inchi,
                                                    IChemObjectBuilder builder)
                                             throws CDKException
        Gets structure generator for an InChI string.
        Parameters:
        inchi - InChI to generate structure from.
        builder - the builder to use
        Returns:
        the InChI structure generator object
        Throws:
        CDKException - if the generator cannot be instantiated
      • getInChIToStructure

        public InChIToStructure getInChIToStructure​(String inchi,
                                                    IChemObjectBuilder builder,
                                                    String options)
                                             throws CDKException

        Gets structure generator for an InChI string.

        Parameters:
        inchi - InChI to generate structure from.
        builder - the builder to employ
        options - String of options for structure generation.
        Returns:
        the InChI structure generator object
        Throws:
        CDKException - if the generator cannot be instantiated
      • getInChIToStructure

        public InChIToStructure getInChIToStructure​(String inchi,
                                                    IChemObjectBuilder builder,
                                                    List<String> options)
                                             throws CDKException

        Gets structure generator for an InChI string.

        Parameters:
        inchi - InChI to generate structure from.
        options - List of options (net.sf.jniinchi.INCHI_OPTION) for structure generation.
        builder - the builder to employ
        Returns:
        the InChI structure generator object
        Throws:
        CDKException - if the generator cannot be instantiated