Commit f759a9d5 authored by eladnoor's avatar eladnoor

fixing bug in _decompose_reaction (protons were causing nans)

parent d2bf1f24
Pipeline #46748107 failed with stage
in 19 minutes and 28 seconds
......@@ -51,14 +51,14 @@ instance reads all the data that is used to calculate thermodynamic potentials o
```python
from equilibrator_api import ComponentContribution, Reaction, ureg
eq_api = ComponentContribution(pH=6.5, ionic_strength=ureg('0.2 M')) # loads data
eq_api = ComponentContribution(p_h=ureg("6.5"), ionic_strength=ureg('200 mM')) # set pH and I
```
You can parse a reaction from a KEGG-style reaction string. The example given
is ATP hydrolysis to ADP and inorganic phosphate.
```python
rxn_str = "C00002 + C00001 = C00008 + C00009"
rxn_str = "KEGG:C00002 + KEGG:C00001 = KEGG:C00008 + KEGG:C00009"
rxn = Reaction.parse_formula(rxn_str)
```
......@@ -68,7 +68,7 @@ easy to accidentally write unbalanced reactions in this KEGG-style format and
so we always check ourselves.
```python
if not rxn.is_balanced(raise_exception=False):
if not rxn.is_balanced():
print('%s is not balanced' % rxn)
```
......@@ -79,7 +79,7 @@ calculate the standard change in Gibbs potential due to this reaction.
# You control the pH and ionic strength!
# ionic strength is in Molar units.
standard_dg_prime, uncertainty = eq_api.standard_dg_prime(rxn)
print("dG0' = %.1f \u00B1 %.1f kJ/mol\n" % (standard_dg_prime, uncertainty))
print("dG0' = %s \u00B1 %sl\n" % (standard_dg_prime, uncertainty))
```
You can also calculate the [reversibility index](https://doi.org/10.1093/bioinformatics/bts317) for this reaction.
......
......@@ -45,6 +45,9 @@ def test_gibbs_energy_atp_hydrolysis(comp_contribution):
# ATP + H2O = ADP + Pi
formula = "KEGG:C00002 + KEGG:C00001 = KEGG:C00008 + KEGG:C00009"
reaction = Reaction.parse_formula(formula)
assert reaction.is_balanced()
compound_to_conc = {ccache.get_compound('KEGG:C00002'): Q_("1mM"),
ccache.get_compound('KEGG:C00008'): Q_("10mM"),
ccache.get_compound('KEGG:C00009'): Q_("10mM")}
......@@ -70,6 +73,8 @@ def test_gibbs_energy_pyruvate_decarboxylase(comp_contribution):
formula = "KEGG:C00022 = KEGG:C00084 + KEGG:C00011"
reaction = Reaction.parse_formula(formula)
assert reaction.is_balanced()
standard_dg_prime, dg_uncertainty = comp_contribution.standard_dg_prime(
reaction)
......@@ -84,6 +89,8 @@ def test_reduction_potential(comp_contribution):
formula = "KEGG:C00036 = KEGG:C00149"
reaction = Reaction.parse_formula(formula)
assert reaction.check_half_reaction_balancing() == 2
standard_e_prime, e_uncertainty = comp_contribution.standard_e_prime(
reaction)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment