name | arguments | returns |
__init__ | reactants: Union[int, str, list], products: Union[int, str, list],
forward_rate=None, reverse_rate=None,
delta_H=None, delta_S=None, delta_G=None, temp=None | |
Create the structure for a new SINGLE chemical reaction,
optionally including its kinetic and/or thermodynamic data.
All the involved chemicals must be already registered - use add_chemical() if needed.
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 forward_rate: [OPTIONAL] Forward reaction rate constant
:param reverse_rate: [OPTIONAL] Reverse reaction rate constant
: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), in Joules
:param temp: [OPTIONAL] Temperature in Kelvins. For now, assumed constant everywhere,
and unvarying (or very slowly varying)
|
name | arguments | returns |
set_macro_enzyme | macromolecule: str, site_number: int | None |
Register that the given macromolecule, at the given site on it,
catalyzes this reaction
:param macromolecule: Name of macromolecule acting as a catalyst
:param site_number: Integer to identify a binding site on the above macromolecule
:return: None
|
name | arguments | returns |
extract_reactants | self | [(int, str, int)] |
Return a list of triplets with details of the reactants of the given reaction,
incl. their stoichiometry, name and reaction order
:return: A list of triplets of the form (stoichiometry, species name, reaction order)
|
name | arguments | returns |
extract_reactants_formula | self | str |
Return a string with a user-friendly form of the left (reactants) side of the reaction formula
EXAMPLE: "CH4 + 2 O2"
:return: A string with one side of a chemical reaction
|
name | arguments | returns |
extract_products | self | [(int, str, int)] |
Return a list of triplet with details of the products of the given reaction,
incl. their stoichiometry, name and reaction order
:return: A list of triplets of the form (stoichiometry, species name, reaction order)
|
name | arguments | returns |
extract_products_formula | self | str |
Return a string with a user-friendly form of the right (products) side of the reaction formula
:return: A string with one side of a chemical reaction
|
name | arguments | returns |
extract_forward_rate | self | float |
:return: The value of the forward rate constant for this reaction
|
name | arguments | returns |
extract_reverse_rate | self | float |
:return: The value of the reverse (back) rate constant for this reaction
|
name | arguments | returns |
extract_equilibrium_constant | self | float |
:return: The value of the equilibrium constant for this reaction
|
name | arguments | returns |
unpack_for_dynamics | self | tuple |
A convenient unpacking meant for dynamics simulations
that need the reactants, the products, and the forward and reverse rate constants
:return: A 4-element tuple, containing:
(reactants , products , forward rate constant , reverse rate constant)
Note: both reactants products are lists of triplets
|
name | arguments | returns |
extract_stoichiometry | term :(int, str, int) | int |
Return the stoichiometry coefficient, from a reaction TERM
:param term: A triplet (int, str, int) representing a reaction term
:return: An integer with the stoichiometry coefficient
|
name | arguments | returns |
extract_species_name | term :(int, str, int) | str |
Return the name of the chemical species, from a reaction TERM
:param term: A triplet (int, str, int) representing a reaction term
:return: The name of the chemical species in the term
|
name | arguments | returns |
extract_rxn_order | term :(int, str, int) | int |
Return the reaction order, from a reaction TERM
:param term: A triplet (int, str, int) representing a reaction term
:return: An integer with the reaction order for this term
|
name | arguments | returns |
extract_rxn_properties | self | {} |
Create a dictionary with the numerical properties of the given reaction
(skipping any lists or None values)
Possible values include:
forward and reverse reaction rates, ΔH, ΔS, ΔG, K (equilibrium constant)
:return: EXAMPLE: {'kF': 3.0, 'kR': 2.0, 'delta_G': -1005.1305052750387, 'K': 1.5}
|
name | arguments | returns |
extract_chemicals_in_reaction | exclude_enzyme=False | Set[str] |
Return a SET of names (being a set, it's NOT in any particular order)
identifying all the chemicals appearing in this reaction.
Optionally, exclude any that participate in a catalytic role
(appearing identically on both sides of the reaction)
:param exclude_enzyme: If True, any enzyme, if present, won't be included
:return: A SET of indices of the chemicals involved in this reaction
Note: being a set, it's NOT in any particular order
|
name | arguments | returns |
extract_reactant_names | exclude_enzyme=False | [str] |
In the order in which they appear when the reaction was first defined
:param exclude_enzyme: If True, any enzyme, if present, won't be included
:return: List of chemical names
|
name | arguments | returns |
extract_product_names | exclude_enzyme=False | [str] |
In the order in which they appear when the reaction was first defined
:param exclude_enzyme: If True, any enzyme, if present, won't be included
:return: List of chemical names
|
name | arguments | returns |
describe | concise=False | str |
Return as a string, a user-friendly plain-text form of the 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 concise: If True, less detail is shown
:return: A string with a description of the specified reaction
|
name | arguments | returns |
reaction_quotient | conc, explain=False | Union[np.double, Tuple[np.double, str]] |
Compute the "Reaction Quotient" (aka "Mass–action Ratio"),
given the concentrations of chemicals involved in this reaction
:param conc: Dictionary with the concentrations of the species involved in the reaction.
The keys are the chemical names
EXAMPLE: {'A': 23.9, 'B': 36.1}
:param explain: If True, it also returns the math formula being used for the computation
EXAMPLES: "([C][D]) / ([A][B])"
"[B] / [A]^2"
:return: If explain is False, return value for the "Reaction Quotient" (aka "Mass–action Ratio");
if True, return a pair with that quotient and a string with the math formula that was used.
Note that the reaction quotient is a Numpy scalar that might be np.inf or np.nan
|
name | arguments | returns |
_standard_form_chem_eqn | eqn_side: list | str |
Return a user-friendly form of a side of a chemical equation.
EXAMPLE: turn [(1, 0, 1), (2, 8, 1)] into "Fe + 2 Cl" (if species 0 is named "Fe" and species 8 is "Cl")
Note: the reaction order is NOT used
:param eqn_side: A list encoding either side of a chemical equation
:return: A string with a user-friendly form of a side of a chemical equation
|
name | arguments | returns |
_parse_reaction_term | term: Union[str, tuple, list], name="term" | (int, str, int) |
Accept various ways to specify a reaction term, and return a standardized triplet form for it.
NOTE: A) if the stoichiometry coefficient isn't specified, it defaults to 1
B) if the reaction order isn't specified, it defaults to the stoichiometry coefficient
In the passed tuples or lists:
- required 1st entry is the stoichiometry
- required 2nd entry is the chemical name
- optional 3rd one is the reaction order. If unspecified, it defaults to the stoichiometry
If just a string is being passed, it is taken to be the chemical name,
with stoichiometry and reaction order both 1
EXAMPLES:
"F" gets turned into: (1, "F", 1) - defaults used for stoichiometry and reaction order
(2, "F") (2, "F", 2) - default used for reaction order
(2, "F", 1) (2, "F", 1) - no defaults invoked
It's equally acceptable to use LISTS in lieu of tuples
:param term: A string (a chemical name)
OR a pair (stoichiometry coeff, name)
OR a triplet (stoichiometry coeff, name, reaction order)
:param name: An optional nickname, handy to refer to this term in error messages if needed
(for example, "reactant" or "product")
:return: A standardized triplet of the form (stoichiometry, species_name, reaction_order),
where stoichiometry and reaction_order are integers, while species_name is a string
|
name | arguments | returns |
_set_kinetic_and_thermodynamic | forward_rate, reverse_rate,
delta_H, delta_S, delta_G, temp | None |
Set all the kinetic and thermodynamic data derivable - directly or indirectly - from the passed arguments,
storing it in object attributes.
Raise an Exception if any inconsistency is detected.
:param forward_rate:
:param reverse_rate:
:param delta_H:
:param delta_S:
:param delta_G:
:param temp:
:return: None
|