Commit 577d7cfc authored by eladnoor's avatar eladnoor

more updates and bug fixes

parent 24d9f31c
......@@ -35,8 +35,9 @@ install_requires =
sbtab>=0.9.49
matplotlib>=3.0.0
requests
component-contribution>=0.1.3
python_requires = >=3.5
equilibrator-cache>=0.1.4
component-contribution>=0.1.0
python_requires = >=3.6
tests_require =
tox
packages = find:
......@@ -78,6 +79,7 @@ multi_line_output = 4
lines_after_imports = 2
known_first_party = equilibrator_api
known_third_party =
pytest
numpy
pandas
pybel
......@@ -88,6 +90,9 @@ known_third_party =
pyparsing
sbtab
matplotlib
equilibrator_api
equilibrator_cache
component_contribution
# See the docstring in versioneer.py for instructions. Note that you must
# re-run 'versioneer.py setup' after changing this section, and commit the
......
......@@ -29,10 +29,4 @@ from ._version import get_versions
__version__ = get_versions()['version']
del get_versions
from .pathway import Pathway
from .bounds import Bounds
from .phased_reaction import PhasedReaction
#from .reaction_matcher import ReactionMatcher
#from .reaction_matcher import CompoundMatcher
#from .query_parser import QueryParser, ParseError
......@@ -30,12 +30,12 @@ from typing import Dict, Iterable, TextIO, Tuple
import pandas as pd
import pkg_resources
from equilibrator_cache import Compound
from equilibrator_cache.compound_cache import ccache
from numpy import log
from equilibrator_api import settings
from equilibrator_api.concs import ConcentrationConverter
from equilibrator_cache import Compound
from equilibrator_cache.compound_cache import ccache
class InvalidBounds(Exception):
......
......@@ -28,11 +28,11 @@
from typing import Dict, List, Tuple
import numpy as np
from component_contribution import GibbsEnergyPredictor
from equilibrator_cache import Compound
from equilibrator_api import settings
from equilibrator_api.phased_reaction import PhasedReaction
from equilibrator_cache import Compound
class ComponentContribution(object):
......@@ -156,7 +156,7 @@ class ComponentContribution(object):
ln_RI = (2.0 / abs_sum_coeff) * dGm_r_prime / self.RT
return ln_RI
def E0_prime(self, reaction):
def E0_prime(self, reaction: PhasedReaction) -> float:
"""
Calculate the E'0 of a single half-reaction
"""
......
......@@ -30,6 +30,9 @@ import logging
from typing import Callable, Iterable, List, TextIO, Tuple
import numpy as np
from equilibrator_cache.compound_cache import Compound, ccache
from equilibrator_cache.reaction import (
create_stoichiometric_matrix_from_reactions)
from sbtab import SBtab
from equilibrator_api.bounds import DEFAULT_BOUNDS, Bounds
......@@ -37,9 +40,6 @@ from equilibrator_api.component_contribution import ComponentContribution
from equilibrator_api.phased_reaction import PhasedReaction
from equilibrator_api.settings import RT
from equilibrator_api.thermo_models import PathwayThermoModel
from equilibrator_cache.compound_cache import Compound, ccache
from equilibrator_cache.reaction import (
create_stoichiometric_matrix_from_reactions)
class PathwayParseError(Exception):
......
......@@ -29,12 +29,12 @@ import logging
from typing import Callable, Dict
import numpy as np
from equilibrator_api import settings
from equilibrator_cache import Compound
from equilibrator_cache.compound_cache import ccache
from equilibrator_cache.reaction import Reaction
from equilibrator_api import settings
# list of compounds that are non aqueous (we keep their formation energies
# as they appear in component-contribution, and only override their possible
......
# The MIT License (MIT)
#
# Copyright (c) 2013 Weizmann Institute of Science
# Copyright (c) 2018 Institute for Molecular Systems Biology,
# ETH Zurich
# Copyright (c) 2018 Novo Nordisk Foundation Center for Biosustainability,
# Technical University of Denmark
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import pytest
from equilibrator_api import Compound, Reaction
def test_phase():
cpd = Compound(Reaction.COMPOUND_DICT['C00011'])
assert cpd.phase == 'aqueous'
assert cpd.dG0_prime(7, 14, 0.1) == pytest.approx(-386.0, abs=1e-2)
cpd = Compound(Reaction.COMPOUND_DICT['C00011'], phase='gas')
assert cpd.dG0_prime(7, 14, 0.1) == pytest.approx(-394.36, abs=1e-2)
cpd = Compound(Reaction.COMPOUND_DICT['C00001'])
assert cpd.phase == 'liquid'
with pytest.raises(ValueError):
Compound(Reaction.COMPOUND_DICT['C00001'], phase='aqueous')
......@@ -28,7 +28,9 @@
import inspect
import os
from equilibrator_api import ReactionMatcher
import pytest
from equilibrator_api.reaction_matcher import ReactionMatcher
TEST_DIR = os.path.dirname(
......@@ -36,6 +38,9 @@ TEST_DIR = os.path.dirname(
def test_reaction_matcher():
pytest.skip("We need to completely reimplement ReactionMatcher after the "
"updates done in equilibrator-cache")
# warnings.simplefilter('ignore', ResourceWarning)
formulas = [('ATP + H2O <=> ADP + Phosphate',
......
......@@ -31,7 +31,8 @@ import warnings
import pytest
from equilibrator_api import Pathway, PhasedReaction
from equilibrator_api import PhasedReaction
from equilibrator_api.pathway import Pathway
TEST_DIR = os.path.dirname(
......@@ -54,12 +55,13 @@ def test_mdf():
assert pp_mdf_data.mdf == pytest.approx(1.69, abs=1e-2)
shadow_prices = pp_mdf_data.reaction_df['shadow_price']
shadow_prices = pp_mdf_data.reaction_df.set_index(
'reaction_id').shadow_price
assert shadow_prices[0] == pytest.approx(0.0, abs=1e-2)
assert shadow_prices[3] == pytest.approx(0.25, abs=1e-2)
assert shadow_prices[4] == pytest.approx(0.25, abs=1e-2)
assert shadow_prices[5] == pytest.approx(0.50, abs=1e-2)
assert shadow_prices['glucokinas_R00299'] == pytest.approx(0.0, abs=1e-2)
assert shadow_prices['fructose_b_R01070'] == pytest.approx(0.25, abs=1e-2)
assert shadow_prices['triose_pho_R01015'] == pytest.approx(0.25, abs=1e-2)
assert shadow_prices['glyceralde_R01061'] == pytest.approx(0.50, abs=1e-2)
compound_prices = pp_mdf_data.compound_df.set_index('compound').shadow_price
......@@ -67,9 +69,9 @@ def test_mdf():
assert compound_prices['nad'] == pytest.approx(1.24, abs=1e-2)
assert compound_prices['nadh'] == pytest.approx(-1.24, abs=1e-2)
# test the mdf_plot() runs without crashing
pp_mdf_data.mdf_plot
# try:
# pp_mdf_data.mdf_plot
# except:
# pytest.fail("MDF plot function raises exception")
# test the mdf_plot and conc_plot run without crashing
try:
pp_mdf_data.mdf_plot
pp_mdf_data.conc_plot
except:
pytest.fail("MDF plot function raises exception")
......@@ -30,10 +30,10 @@ import os
import warnings
import pytest
from equilibrator_cache.compound_cache import ccache
from equilibrator_api.component_contribution import ComponentContribution
from equilibrator_api.phased_reaction import PhasedReaction
from equilibrator_cache.compound_cache import ccache
TEST_DIR = os.path.dirname(
......@@ -72,7 +72,7 @@ def test_gibbs_energy_pyruvate_decarboxylase():
cc = ComponentContribution(pH=7.0, ionic_strength=0.1)
dG0_prime, dG0_uncertainty = cc.dG0_prime(reaction)
assert dG0_prime == pytest.approx(-18.3, abs=1e-1)
assert dG0_prime == pytest.approx(-18.1, abs=1e-1)
assert dG0_uncertainty == pytest.approx(3.3, abs=1e-1)
......@@ -86,5 +86,5 @@ def test_reduction_potential():
cc = ComponentContribution(pH=7.0, ionic_strength=0.1)
E0_prime_mV, E0_uncertainty = cc.E0_prime(reaction)
assert E0_prime_mV == pytest.approx(-174.8, abs=1e-1)
assert E0_prime_mV == pytest.approx(-178.1, abs=1e-1)
assert E0_uncertainty == pytest.approx(3.3, abs=1e-1)
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