Class ReactionEncoder
- java.lang.Object
-
- com.actelion.research.chem.reaction.ReactionEncoder
-
public class ReactionEncoder extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static char
CATALYST_DELIMITER
static int
INCLUDE_ALL
static int
INCLUDE_CATALYSTS
static int
INCLUDE_COORDS
static int
INCLUDE_DEFAULT
static int
INCLUDE_DRAWING_OBJECTS
static int
INCLUDE_MAPPING
static int
INCLUDE_RXN_CODE_ONLY
static char
MOLECULE_DELIMITER
static java.lang.String
MOLECULE_DELIMITER_STRING
static char
OBJECT_DELIMITER
static java.lang.String
OBJECT_DELIMITER_STRING
static char
PRODUCT_IDENTIFIER
static int
RETAIN_REACTANT_AND_PRODUCT_ORDER
-
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.
-
-
-
Field Detail
-
MOLECULE_DELIMITER
public static final char MOLECULE_DELIMITER
- See Also:
- Constant Field Values
-
PRODUCT_IDENTIFIER
public static final char PRODUCT_IDENTIFIER
- See Also:
- Constant Field Values
-
CATALYST_DELIMITER
public static final char CATALYST_DELIMITER
- See Also:
- Constant Field Values
-
OBJECT_DELIMITER
public static final char OBJECT_DELIMITER
- See Also:
- Constant Field Values
-
MOLECULE_DELIMITER_STRING
public static final java.lang.String MOLECULE_DELIMITER_STRING
- See Also:
- Constant Field Values
-
OBJECT_DELIMITER_STRING
public static final java.lang.String OBJECT_DELIMITER_STRING
- See Also:
- Constant Field Values
-
INCLUDE_MAPPING
public static final int INCLUDE_MAPPING
- See Also:
- Constant Field Values
-
INCLUDE_COORDS
public static final int INCLUDE_COORDS
- See Also:
- Constant Field Values
-
INCLUDE_DRAWING_OBJECTS
public static final int INCLUDE_DRAWING_OBJECTS
- See Also:
- Constant Field Values
-
INCLUDE_CATALYSTS
public static final int INCLUDE_CATALYSTS
- See Also:
- Constant Field Values
-
INCLUDE_ALL
public static final int INCLUDE_ALL
- See Also:
- Constant Field Values
-
INCLUDE_RXN_CODE_ONLY
public static final int INCLUDE_RXN_CODE_ONLY
- See Also:
- Constant Field Values
-
INCLUDE_DEFAULT
public static final int INCLUDE_DEFAULT
- See Also:
- Constant Field Values
-
RETAIN_REACTANT_AND_PRODUCT_ORDER
public static final int RETAIN_REACTANT_AND_PRODUCT_ORDER
- See Also:
- Constant Field Values
-
-
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 reactionincludeReactants
-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 coordinatescoords
- may be nullmapping
- may be nullincludeReactants
-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
-
-