Commit 059060fd authored by eladnoor's avatar eladnoor

minor touches to code readability

parent e4bb6092
......@@ -35,19 +35,18 @@ The easiest way to get eQuilibrator-API up and running is using virtualenv, PyPI
```
virtualenv -p python3 equilibrator
source equilibrator/bin/activate
pip install equilibrator-api jupyter
curl https://gitlab.com/elad.noor/equilibrator-api/raw/develop/scripts/equilibrator_cmd.ipynb > equilibrator_cmd.ipynb
jupyter notebook
pip install equilibrator-api
```
Then select the notebook called `equilibrator_cmd.ipynb` and follow the examples in it.
You can then either follow the examples below and write your own code, or start by opening the
provided jupyter notebook:
Alternatively, you could install from source. Make sure you have [git-lfs](https://git-lfs.github.com/)
installed before cloning the repository:
```
git clone https://gitlab.com/elad.noor/equilibrator-api.git
cd equilibrator-api
python setup.py install
```
pip install jupyter
curl https://gitlab.com/elad.noor/equilibrator-api/raw/develop/scripts/equilibrator_cmd.ipynb > equilibrator_cmd.ipynb
jupyter notebook
```
Then select the notebook called `equilibrator_cmd.ipynb` and follow the examples in it.
## Example Usage
......@@ -63,7 +62,7 @@ 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 = "KEGG:C00002 + KEGG:C00001 = KEGG:C00008 + KEGG:C00009"
rxn_str = "kegg:C00002 + kegg:C00001 = kegg:C00008 + kegg:C00009"
rxn = Reaction.parse_formula(rxn_str)
```
......@@ -84,14 +83,14 @@ 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' = %s \u00B1 %s\n" % (standard_dg_prime, uncertainty))
print(f"dG0' = {standard_dg_prime:.1f} \u00B1 {uncertainty:1.f}")
```
You can also calculate the [reversibility index](https://doi.org/10.1093/bioinformatics/bts317) for this reaction.
```python
ln_RI = eq_api.ln_reversibility_index(rxn)
print('ln(Reversibility Index) = %s\n' % ln_RI)
print(f"ln(Reversibility Index) = {ln_RI:.1f}")
```
The reversibility index is a measure of the degree of the reversibility of the
......
......@@ -38,7 +38,6 @@ def main(args):
"""Run main script, calculates the reaction Gibbs energy change."""
from equilibrator_api import (
Q_, ComponentContribution, Reaction, ureg) # isort:skip
ureg.default_format = ".2f"
p_h = Q_(args.ph)
assert p_h.check(None)
......
......@@ -59,7 +59,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
......@@ -205,7 +205,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {
"scrolled": true
},
......
......@@ -62,7 +62,6 @@ def main(args):
from equilibrator_api import (
Q_, ComponentContribution, Reaction, ureg) # isort:skip
ureg.default_format = ".2f"
p_h = Q_(args.ph)
assert p_h.check(None)
......@@ -80,7 +79,7 @@ def main(args):
assert temperature.check("[temperature]")
sys.stderr.write(f"pH = {p_h}\n")
sys.stderr.write(f"I = {ionic_strength:.2g}\n")
sys.stderr.write(f"I = {ionic_strength}\n")
sys.stderr.write(f"T = {temperature}\n")
sys.stderr.flush()
......
......@@ -37,6 +37,9 @@ from equilibrator_cache.thermodynamic_constants import (
default_pMg, default_T, physiological_concentration,
standard_concentration, ureg)
ureg.default_format = ".2f"
ureg.setup_matplotlib(True)
ccache = CompoundCache()
default_phase = 'aqueous'
......
......@@ -106,7 +106,7 @@ class PhasedReaction(Reaction):
compound: Compound
) -> Tuple[PhasedCompound, float]:
"""Get the PhasedCompound object by the Compound object."""
# TODO: This is not ideal. We should try to not keep to dictionaries (
# TODO: This is not ideal. We should try to not keep two dictionaries (
# one with Compounds and one with PhasedCompounds).
for phased_compound, coeff in self.sparse_with_phases.items():
if phased_compound.compound == compound:
......
......@@ -159,8 +159,6 @@ class PathwayMDFData(object):
:return: matplotlib Figure
"""
ureg.setup_matplotlib(True)
data_df = self.compound_df.copy()
data_df['y'] = np.arange(0, data_df.shape[0])
......
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