Class RInChIGenerator


  • public final class RInChIGenerator
    extends StatusMessagesOutput
    This class generates a IUPAC Reaction International Chemical Identifier (RInChI) for a provided CDK IReaction object.

    In this implementation, generation of the RInChI is based on generating InChIs and associated auxiliary information (auxinfo) for the individual reaction components using the JNA wrapper for the InChI C++ library. The pieces are then assembled into a RInChI string and reaction auxiliary information (rauxinfo) string. Computation of the three different RInChI keys Long-RInChIKey, Short-RInChIKey and Web-RInChIKey are implemented in Java.

    Consequently, any limitation of the InChIGenerator also impacts on the computation of the RInChI. In addition, this RInChI implementation has the following limitations:

    • The RAuxInfo may differ in the /rA layers, as the CDK interprets the mol-file differently than the command line interface of the RInChI.
    • If the Rxnfile contains additional structures other than those specified in the ‘count line’, these are interpreted by the CDK as products. The RInChI software strictly adheres to the ‘count line’.

    Please note that there are no exceptions thrown if an issue is encountered during processing. Instead, a StatusMessagesOutput.Status can be retrieved with StatusMessagesOutput.getStatus() that should be assessed. If the status is not StatusMessagesOutput.Status.SUCCESS emitted messages can be accessed with StatusMessagesOutput.getMessages(). These messages should capture relevant information about what exactly went wrong.

    Given an IReaction, RInChI, RAuxInfo, Long-RInChIKey, Short-RInChIKey and Web-RInChIKey can be generated using default options:
         // All that's needed is an IReaction object, e.g., by loading an RXN file.
         IReaction reaction = ....;
         RInChIGenerator generator = new RInChIGenerator().generate(reaction);
         if (generator.getStatus() == Status.SUCCESS) {
             String rinchi = generator.getRInChI();
             String rAuxInfo = generator.getAuxInfo();
             String longKey = generator.getLongRInChIKey();
             String shortKey = generator.getShortRInChIKey();
             String webKey = generator.getWebRInChIKey();*
         } else {
             System.out.printf("RInChIGenerator came back with status %s: %s",
               generator.getStatus(), String.join("; ", generator.getMessages()));
         }
     
    Alternatively, a customized set of options can be used:
         IReaction reaction = ....;
         RInChIOptions rinchiOptions = RInChIOptions.RInChIOptions.builder().forceEquilibrium().build();
         RInChIGenerator generator = new RInChIGenerator(rinchiOptions).generate(reaction);
     

    See:
    Author:
    Felix Bänsch, Uli Fechner
    Source code:
    main
    Belongs to CDK module:
    rinchi
    • Constructor Detail

      • RInChIGenerator

        public RInChIGenerator()
        Constructs a new instance of RInChIGenerator using the default RInChIOptions.
      • RInChIGenerator

        public RInChIGenerator​(RInChIOptions options)
        Generates RInChI from a CDK Reaction.
        Parameters:
        options - zero or more options
    • Method Detail

      • generate

        public RInChIGenerator generate​(IReaction reaction)
        Generates RInChI and related keys for the provided chemical reaction.
        Parameters:
        reaction - the chemical reaction to be converted into the RInChI format;
        Returns:
        the current instance of RInChIGenerator with generated RInChI and keys,
      • getRInChI

        public String getRInChI()
        Gets generated RInChI string.
        Returns:
        generated RInChI
      • getAuxInfo

        public String getAuxInfo()
        Gets auxiliary information.
        Returns:
        RInChI AuxInfo
      • getShortRInChIKey

        public String getShortRInChIKey()
        Returns Short-RInChIKey.
        Returns:
        Short-RInChIKey
      • getLongRInChIKey

        public String getLongRInChIKey()
        Returns Long-RInChIKey.
        Returns:
        Long-RInChIKey
      • getWebRInChIKey

        public String getWebRInChIKey()
        Returns Web-RInChIKey.
        Returns:
        Web-RInChIKey