This guide is for versions 1.0.0rc.6+ (Release Candidate)
Manage the reaction-specific classes, such as ReactionUnimolecular, ReactionSynthesis, ReactionDecomposition, ReactionGeneric, ReactionEnzyme, etc. (this class was formerly called "Reactions")
name | arguments | returns |
---|---|---|
__init__ | chem_data | |
:param chem_data: Object of type "ChemData" |
name | arguments | returns |
---|---|---|
number_of_reactions | include_inactive=False | int |
Return the number of registered chemical reactions :param include_inactive: If True, disabled reactions are also included :return: The number of registered chemical reactions |
name | arguments | returns |
---|---|---|
active_reaction_indices | [int] | |
Return a list of the reaction index numbers of all the active reactions :return: A list of integers, to identify the active reactions by their indices |
name | arguments | returns |
---|---|---|
assert_valid_rxn_index | index :int | None |
Raise an Exception if the specified reaction index isn't valid :param index: An integer that indexes the reaction of interest (numbering starts at 0) :return: None |
name | arguments | returns |
---|---|---|
get_chem_data | ||
name | arguments | returns |
---|---|---|
get_reaction | i :int | |
Return the data structure of the i-th reaction, in the order in which reactions were added (numbering starts at 0) :param i: An integer that indexes the reaction of interest (numbering starts at 0) :return: An object of one of the various individual reaction classes, such as "ReactionGeneric" and "ReactionEnz" |
name | arguments | returns |
---|---|---|
get_reactants | i :int | [(int, int, int)] |
Return a list of triplets with details of the reactants of the i-th reaction :param i: The index (0-based) to identify the reaction of interest :return: A list of triplets of the form (stoichiometry, species index, reaction order) |
name | arguments | returns |
---|---|---|
get_reactants_formula | i :int | str |
Return a string with a user-friendly form of the left (reactants) side of the reaction formula :param i: The index (0-based) to identify the reaction of interest :return: A string with a user-friendly form of the left (reactants) side of the chemical reaction |
name | arguments | returns |
---|---|---|
get_products | i :int | [(int, int, int)] |
Return a list of triplets with details of the products of the i-th reaction :param i: The index (0-based) to identify the reaction of interest :return: A list of triplets of the form (stoichiometry, species index, reaction order) |
name | arguments | returns |
---|---|---|
get_products_formula | i :int | str |
Return a string with a user-friendly form of the right (products) side of the reaction formula :param i: The index (0-based) to identify the reaction of interest :return: A string with a user-friendly form of the right (products) side of the chemical reaction |
name | arguments | returns |
---|---|---|
get_forward_rate | i :int | float |
Return the value of the forward rate constant of the i-th reaction :param i: The integer index (0-based) to identify the reaction of interest :return: The value of the forward rate constant for the above reaction |
name | arguments | returns |
---|---|---|
get_reverse_rate | i :int | float |
Return the value of the reverse (back) rate constant of the i-th reaction :param i: The integer index (0-based) to identify the reaction of interest :return: The value of the reverse (back) rate constant for the above reaction |
name | arguments | returns |
---|---|---|
get_chemicals_in_reaction | rxn_index :int | {int} |
Return a SET of indices (being a set, they're NOT in any particular order) of all the chemicals participating in the i-th reaction :param rxn_index: An integer with the (zero-based) index to identify the reaction of interest :return: A SET of indices of the chemicals involved in the above reaction Note: being a set, it's NOT in any particular order |
name | arguments | returns |
---|---|---|
get_chemicals_indexes_in_reaction | rxn_index :int | [int] |
Return a sorted list of the indexes of all the chemicals participating in the i-th reaction :param rxn_index: An integer with the (zero-based) index to identify the reaction of interest :return: A sorted list of indices of the chemicals involved in the above reaction |
name | arguments | returns |
---|---|---|
register_reaction | rxn, temp=None | int |
Register a SINGLE chemical reaction from its reaction-specific object, and set all its kinetic and/or thermodynamic data from the available information, including the value of the temperature (stored in object variable.) All the involved chemicals can be either previously registered, or not. :param rxn: One of the specific Reaction classes, such as ReactionUnimolecular, ReactionSynthesis, ReactionDecomposition, ReactionEnz, ReactionGeneric :return: Integer index of the newly-added reaction (in the list self.reaction_list, stored as object variable) |
name | arguments | returns |
---|---|---|
add_reaction | reactants :Union[int, str, list], products :Union[int, str, list], kF=None, forward_rate=None, kR=None, reverse_rate=None, enzyme=None, k1_F=None, k1_R=None, k2_F=None, reaction_type=None, **kwargs | int |
Create and register a new SINGLE chemical reaction, optionally including its kinetic and/or thermodynamic data. All the involved chemicals can be either previously registered, or not. NOTE: in the reactants and products, if the stoichiometry coefficients aren't specified, they're assumed to be 1. The reaction orders, if not specified, are assumed to be equal to their corresponding stoichiometry coefficients. The full structure of each term in the list of reactants and of products is the triplet: (stoichiometry coefficient, name, reaction order) EXAMPLES of formats to use for each term in the lists of the reactants and of the products: "F" is taken to mean (1, "F", 1) - default stoichiometry and reaction order (2, "F") is taken to mean (2, "F", 2) - stoichiometry coefficient used as default for reaction order (2, "F", 1) means stoichiometry coefficient 2 and reaction order 1 - no defaults invoked It's equally acceptable to use LISTS in lieu of tuples for the pair or triplets :param reactants: A list of triplets (stoichiometry, species name, reaction order), or simplified terms in various formats; for details, see above. If not a list, it will get turned into one :param products: A list of triplets (stoichiometry, species name, reaction order of REVERSE reaction), or simplified terms in various formats; for details, see above. If not a list, it will get turned into one :param kF: [OPTIONAL] Forward reaction rate constant :param forward_rate: [OPTIONAL] DEPRECATED name for kF :param kR: [OPTIONAL] Reverse reaction rate constant :param reverse_rate: [OPTIONAL] DEPRECATED name for kR :param delta_H: [OPTIONAL] Change in Enthalpy (from reactants to products) :param delta_S: [OPTIONAL] Change in Entropy (from reactants to products) :param delta_G: [OPTIONAL] Change in Free Energy (from reactants to products) :param reaction_type: [OPTIONAL] :return: Integer index of the newly-added reaction (in the list self.reaction_list, stored as object variable) |
name | arguments | returns |
---|---|---|
clear_reactions_data | None | |
Get rid of all the reactions; start again with "an empty slate" (but still with reference to the same data object about the chemicals and their properties) :return: None |
name | arguments | returns |
---|---|---|
inactivate_reaction | i :int | None |
Mark the i-th reaction as "inactive/disabled" (essentially, "deleted", but holding its positional index, to avoid a change in index in other reactions) WARNING: Not yet supported by the dynamical modules; DON'T USE YET in simulations! :param i: Zero-based index of the reaction to disable :return: None |
name | arguments | returns |
---|---|---|
describe_reactions | concise=False | None |
Print out a user-friendly plain-text form of ALL the reactions. If wanting to describe just 1 reaction, use single_reaction_describe() EXAMPLE (not concise): Number of reactions: 2 (0) CH4 + 2 O2 <-> CO2 + 2 H2O (kF = 3.0 / kR = 2.0 / Delta_G = -1,005.13 / K = 1.5) | 1st order in all reactants & products (1) A + B <-> C (kF = 5.0 / kR = 1.0 / Delta_G = / K = 5.0) | 1st order in all reactants & products Chemicals involved in the above reactions: {'CH4', 'O2', 'H2O', 'A', 'B', 'C'} :param concise: If True, less detail is shown :return: None |
name | arguments | returns |
---|---|---|
multiple_reactions_describe | rxn_list=None, concise=False | [str] |
The counterpart of single_reaction_describe() for many reactions. Return a list of strings, each string being a (concise or not) user-friendly plain-text form of each of the reactions :param rxn_list: Either a list of integers, to identify the reactions of interest, or None, meaning ALL reactions :param concise: If True, less detail is shown :return: A list of strings; each string is the description of one of the reactions |
name | arguments | returns |
---|---|---|
single_reaction_describe | rxn_index: int, concise=False | str |
Return as a string, a user-friendly plain-text form of the given reaction EXAMPLE (concise): "CH4 + 2 O2 <-> CO2 + 2 H2O" EXAMPLE (not concise): "CH4 + 2 O2 <-> CO2 + 2 H2O (kF = 3.0 / kR = 2.0 / Delta_G = -1,005.13 / K = 1.5) | 1st order in all reactants & products" :param rxn_index: Integer to identify the reaction of interest :param concise: If True, less detail is shown :return: A string with a description of the specified reaction |
name | arguments | returns |
---|---|---|
labels_of_active_chemicals | sort_by_index=False | [str] |
Return a list of the labels of all the chemicals involved in ANY of the registered reactions, but NOT counting chemicals that always appear in a catalytic role in all the reactions they participate in (if a chemical participates in a non-catalytic role in ANY reaction, it'll appear here) The list is not in any particular order, unless sort_by_index is True :param sort_by_index: If True, the list is sorted by the index (order of registration) of the chemicals in it :return: A set of chemical labels |
name | arguments | returns |
---|---|---|
number_of_active_chemicals | int | |
Return the number of all the chemicals involved in ANY of the registered reactions, but NOT counting chemicals that always appear in a catalytic role in all the reactions they participate in (if a chemical participates in a non-catalytic role in ANY reaction, it'll appear here) |
name | arguments | returns |
---|---|---|
indexes_of_active_chemicals | [int] | |
Return the ordered list (numerically sorted) of the INDEX numbers of all the chemicals involved in ANY of the registered reactions, but NOT counting chemicals that always appear in a catalytic role in all the reactions they participate in (if a chemical participates in a non-catalytic role in ANY reaction, it'll appear here.) EXAMPLE: [2, 7, 8] if only those 3 chemicals (with indexes of, respectively, 2, 7 and 8) are actively involved in ANY of the registered reactions CAUTION: the concept of "active chemical" might change in future versions, where only SOME of the reactions are simulated |
name | arguments | returns |
---|---|---|
names_of_enzymes | Set[str] | |
Return the set of the names of the enzymes (catalysts) involved in any of the registered reactions (regardless of whether they might participate in a non-enzymatic role in other reactions) |
name | arguments | returns |
---|---|---|
prepare_graph_network | dict | |
Prepare and return a data structure with chemical-reaction data in a network format, ready to be passed to the front end, for network-diagram visualization with the Cytoscape.js library (in the graph module "vue_cytoscape") EXAMPLE of the graph structure part of the returned object for an A <-> B reaction: [{'id': 'C-0', 'labels': ['Chemical'], 'name': 'A', 'diff_rate': None}, {'id': 'C-1', 'labels': ['Chemical'], 'name': 'B', 'diff_rate': None}, {'id': 'R-0', 'labels': ['Reaction'], 'name': 'RXN', 'kF': 3.0, 'kR': 2.0, 'K': 1.5, 'Delta_G': -1005.13}, {'id': 'edge-1', 'name': 'produces', 'source': 'R-0', 'target': 'C-1', 'stoich': 1, 'rxn_order': 1}, {'id': 'edge-2', 'name': 'reacts', 'source': 'C-0', 'target': 'R-0', 'stoich': 1, 'rxn_order': 1} ] :return: A dictionary with 3 keys: 'structure', 'color_mapping', 'caption_mapping' |
name | arguments | returns |
---|---|---|
plot_reaction_network | graphic_component :str, unpack=False | None |
Send a plot of the network of reactions to the HTML log file, also including a brief summary of all the reactions EXAMPLE of usage: plot_reaction_network("vue_cytoscape_2") :param graphic_component: The name of a Vue component that accepts a "graph_data" argument, an object with the following keys 'structure', 'color_mapping' and 'caption_mapping' For more details, see ChemData.prepare_graph_network() :param unpack: Use True for Vue components that require their data unpacked into individual arguments; False for that accept a single data argument, named "graph_data" :return: None |