Class ReactionEncoder


  • public class ReactionEncoder
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Reaction decode​(byte[] rxnCode, byte[] rxnMapping, byte[] rxnCoords, java.lang.String rxnObjects, byte[] rxnCatalysts, boolean ensureCoordinates)
      Creates a Reaction object by interpreting a reaction code, mapping, coordinates and drawing objects that were earlier created by this class.
      static Reaction decode​(java.lang.String s, boolean ensureCoordinates)  
      static Reaction decode​(java.lang.String s, boolean ensureCoordinates, Reaction rxn)
      Creates a Reaction object by interpreting a reaction code, mapping, coordinates and drawing objects that were earlier created by this class and are passed OBJECT_DELIMITER-delimited within one string.
      static Reaction decode​(java.lang.String s, int includeOptions, Reaction rxn)
      Creates a Reaction object by interpreting a reaction string encoded by this class.
      static Reaction decode​(java.lang.String rxnCode, java.lang.String rxnMapping, java.lang.String rxnCoords, java.lang.String rxnObjects, java.lang.String rxnCatalysts, boolean ensureCoordinates, Reaction rxn)
      Creates a Reaction object by interpreting a reaction code, mapping, coordinates and drawing objects that were earlier created by this class.
      static StereoMolecule[] decodeCatalysts​(byte[] rxnBytes)
      Generates an array of all catalysts of the encoded reaction string as bytes.
      static StereoMolecule[] decodeMolecules​(byte[] rxnBytes, byte[] coords, byte[] mapping, boolean includeReactants, boolean includeProducts)
      Generates an array of all reactants and/or products of the encoded reaction string as bytes.
      static StereoMolecule[] decodeMolecules​(java.lang.String s, boolean includeCoords, boolean includeMapping, boolean includeReactants, boolean includeProducts)
      Generates an array of all reactants and/or products of the encoded reaction string as bytes.
      static java.lang.String[] encode​(Reaction reaction, boolean keepAbsoluteCoordinates)
      Creates a String containing a unique reaction code by creating idcodes of every reactant and product and concatenating them in lexical order.
      static java.lang.String encode​(Reaction reaction, boolean keepAbsoluteCoordinates, int mode)
      Creates a String containing a reaction code by creating idcodes of every reactant and product and concatenating them in original (if mode includes RETAIN_REACTANT_AND_PRODUCT_ORDER) or in lexical order.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • encode

        public static java.lang.String[] encode​(Reaction reaction,
                                                boolean keepAbsoluteCoordinates)
        Creates a String containing a unique reaction code by creating idcodes of every reactant and product and concatenating them in lexical order. If mapping information is available this will be encoded in a 2nd string. Otherwise this will be null. Coordinates, if available, will be encoded in a 3rd string. If there are drawing objects assigned to this reaction then these are encoded in a 4th string.
        Returns:
        String[5] with reaction code, mapping, coordinates, drawing objects, catalysts
      • encode

        public static java.lang.String encode​(Reaction reaction,
                                              boolean keepAbsoluteCoordinates,
                                              int mode)
        Creates a String containing a reaction code by creating idcodes of every reactant and product and concatenating them in original (if mode includes RETAIN_REACTANT_AND_PRODUCT_ORDER) or in lexical order. In the latter case this string is a canonical reaction encoding. If mapping information is available this will be encoded in a 2nd string. Coordinates, if available, will be encoded in a 3rd string. If there are drawing objects assigned to this reaction then these are encoded in a 4th string.
        Returns:
        One String with reaction code, coordinates, mapping, drawing objects as defined by mode.
      • decode

        public static Reaction decode​(java.lang.String rxnCode,
                                      java.lang.String rxnMapping,
                                      java.lang.String rxnCoords,
                                      java.lang.String rxnObjects,
                                      java.lang.String rxnCatalysts,
                                      boolean ensureCoordinates,
                                      Reaction rxn)
        Creates a Reaction object by interpreting a reaction code, mapping, coordinates and drawing objects that were earlier created by this class. If rxnCoords are relative or null, and if ensureCoordinates==true then all reactants and products are placed automatically along a horizontal line.
        Returns:
        Reaction
      • decode

        public static Reaction decode​(byte[] rxnCode,
                                      byte[] rxnMapping,
                                      byte[] rxnCoords,
                                      java.lang.String rxnObjects,
                                      byte[] rxnCatalysts,
                                      boolean ensureCoordinates)
        Creates a Reaction object by interpreting a reaction code, mapping, coordinates and drawing objects that were earlier created by this class. If rxnCoords are relative or null, and if ensureCoordinates==true then all reactants and products are placed automatically along a horizontal line.
        Returns:
        Reaction
      • decode

        public static Reaction decode​(java.lang.String s,
                                      boolean ensureCoordinates)
      • decode

        public static Reaction decode​(java.lang.String s,
                                      boolean ensureCoordinates,
                                      Reaction rxn)
        Creates a Reaction object by interpreting a reaction code, mapping, coordinates and drawing objects that were earlier created by this class and are passed OBJECT_DELIMITER-delimited within one string. If rxnCoords are relative or null, and if ensureCoordinates==true then all reactants and products are placed automatically along a horizontal line.
        Returns:
        Reaction
      • decode

        public static Reaction decode​(java.lang.String s,
                                      int includeOptions,
                                      Reaction rxn)
        Creates a Reaction object by interpreting a reaction string encoded by this class. Include options define whether mapping, coordinates, catalysts, and drawing objects # are included in the reaction object.
        Parameters:
        s -
        includeOptions -
        Returns:
        Reaction
      • decodeMolecules

        public static StereoMolecule[] decodeMolecules​(java.lang.String s,
                                                       boolean includeCoords,
                                                       boolean includeMapping,
                                                       boolean includeReactants,
                                                       boolean includeProducts)
        Generates an array of all reactants and/or products of the encoded reaction string as bytes. If the string includes atom coordinates or if they are explicitly, these are used. At least one of includeReactants and includeProducts must be true.
        Parameters:
        s - encoded reaction
        includeReactants -
        includeProducts -
        includeMapping -
        Returns:
        null (if reactants or products are missing) or StereoMolecule array with at least one molecule
      • decodeMolecules

        public static StereoMolecule[] decodeMolecules​(byte[] rxnBytes,
                                                       byte[] coords,
                                                       byte[] mapping,
                                                       boolean includeReactants,
                                                       boolean includeProducts)
        Generates an array of all reactants and/or products of the encoded reaction string as bytes. If the string includes atom coordinates or if they are explicitly, these are used. At least one of includeReactants and includeProducts must be true.
        Parameters:
        rxnBytes - may contain atom coordinates
        coords - may be null
        mapping - may be null
        includeReactants -
        includeProducts -
        Returns:
        null (if reactants or products are missing) or StereoMolecule array with at least one molecule
      • decodeCatalysts

        public static StereoMolecule[] decodeCatalysts​(byte[] rxnBytes)
        Generates an array of all catalysts of the encoded reaction string as bytes. If the string includes atom coordinates, these are used.
        Parameters:
        rxnBytes -
        Returns:
        null or StereoMolecule array with at least one molecule