Skip to content

Commit

Permalink
refactor: change scope of room_model and room_solution to module; mov…
Browse files Browse the repository at this point in the history
…e geometric_fba_model to respective module
  • Loading branch information
synchon authored and Midnighter committed Aug 20, 2018
1 parent b6c09cd commit 8ee8eaa
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 47 deletions.
50 changes: 3 additions & 47 deletions cobra/test/test_flux_analysis/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

from __future__ import absolute_import

import pytest
from pandas import Series

import cobra.util.solver as sutil
import pytest
from cobra.core import Metabolite, Model, Reaction, Solution

# The scipy interface is currently unstable and may yield errors or infeasible
Expand All @@ -31,7 +31,7 @@ def qp_solvers(request):
return request.param


@pytest.fixture(scope="session")
@pytest.fixture(scope="module")
def room_model():
"""
Generate ROOM model as described in [1]_
Expand Down Expand Up @@ -72,7 +72,7 @@ def room_model():
return test_model


@pytest.fixture(scope="session")
@pytest.fixture(scope="module")
def room_solution():
"""
Generate ROOM solution as described in [1]_
Expand All @@ -97,47 +97,3 @@ def room_solution():
reduced_costs=reduced_costs,
shadow_prices=shadow_prices)
return sol


@pytest.fixture(scope="session")
def geometric_fba_model():
"""
Generate geometric FBA model as described in [1]_
References
----------
.. [1] Smallbone, Kieran & Simeonidis, Vangelis. (2009).
Flux balance analysis: A geometric perspective.
Journal of theoretical biology.258. 311-5.
10.1016/j.jtbi.2009.01.027.
"""
test_model = Model('geometric_fba_paper_model')

test_model.add_metabolites(Metabolite('A'))
test_model.add_metabolites(Metabolite('B'))

v_1 = Reaction('v1', upper_bound=1.0)
v_1.add_metabolites({test_model.metabolites.A: 1.0})

v_2 = Reaction('v2', lower_bound=-1000.0)
v_2.add_metabolites({test_model.metabolites.A: -1.0,
test_model.metabolites.B: 1.0})

v_3 = Reaction('v3', lower_bound=-1000.0)
v_3.add_metabolites({test_model.metabolites.A: -1.0,
test_model.metabolites.B: 1.0})

v_4 = Reaction('v4', lower_bound=-1000.0)
v_4.add_metabolites({test_model.metabolites.A: -1.0,
test_model.metabolites.B: 1.0})

v_5 = Reaction('v5')
v_5.add_metabolites({test_model.metabolites.A: 0.0,
test_model.metabolites.B: -1.0})

test_model.add_reactions([v_1, v_2, v_3, v_4, v_5])

test_model.objective = 'v5'

return test_model
46 changes: 46 additions & 0 deletions cobra/test/test_flux_analysis/test_geometric.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,55 @@
import numpy as np
from pandas import Series

import pytest
from cobra.core import Metabolite, Model, Reaction, Solution
from cobra.flux_analysis import geometric_fba


@pytest.fixture(scope="module")
def geometric_fba_model():
"""
Generate geometric FBA model as described in [1]_
References
----------
.. [1] Smallbone, Kieran & Simeonidis, Vangelis. (2009).
Flux balance analysis: A geometric perspective.
Journal of theoretical biology.258. 311-5.
10.1016/j.jtbi.2009.01.027.
"""
test_model = Model('geometric_fba_paper_model')

test_model.add_metabolites(Metabolite('A'))
test_model.add_metabolites(Metabolite('B'))

v_1 = Reaction('v1', upper_bound=1.0)
v_1.add_metabolites({test_model.metabolites.A: 1.0})

v_2 = Reaction('v2', lower_bound=-1000.0)
v_2.add_metabolites({test_model.metabolites.A: -1.0,
test_model.metabolites.B: 1.0})

v_3 = Reaction('v3', lower_bound=-1000.0)
v_3.add_metabolites({test_model.metabolites.A: -1.0,
test_model.metabolites.B: 1.0})

v_4 = Reaction('v4', lower_bound=-1000.0)
v_4.add_metabolites({test_model.metabolites.A: -1.0,
test_model.metabolites.B: 1.0})

v_5 = Reaction('v5')
v_5.add_metabolites({test_model.metabolites.A: 0.0,
test_model.metabolites.B: -1.0})

test_model.add_reactions([v_1, v_2, v_3, v_4, v_5])

test_model.objective = 'v5'

return test_model


def test_geometric_fba_benchmark(model, benchmark, all_solvers):
"""Benchmark geometric_fba."""
model.solver = all_solvers
Expand Down

0 comments on commit 8ee8eaa

Please sign in to comment.