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 charCATALYST_DELIMITERstatic intINCLUDE_ALLstatic intINCLUDE_CATALYSTSstatic intINCLUDE_COORDSstatic intINCLUDE_DEFAULTstatic intINCLUDE_DRAWING_OBJECTSstatic intINCLUDE_MAPPINGstatic intINCLUDE_RXN_CODE_ONLYstatic charMOLECULE_DELIMITERstatic java.lang.StringMOLECULE_DELIMITER_STRINGstatic charOBJECT_DELIMITERstatic java.lang.StringOBJECT_DELIMITER_STRINGstatic charPRODUCT_IDENTIFIERstatic intRETAIN_REACTANT_AND_PRODUCT_ORDER
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Reactiondecode(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 Reactiondecode(java.lang.String s, boolean ensureCoordinates)static Reactiondecode(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 Reactiondecode(java.lang.String s, int includeOptions, Reaction rxn)Creates a Reaction object by interpreting a reaction string encoded by this class.static Reactiondecode(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.Stringencode(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
-
-