Skip to content

Commit

Permalink
Merge pull request #705 from carrascomj/fix-test-essentiality
Browse files Browse the repository at this point in the history
fix: point to ids column instead of index
  • Loading branch information
phantomas1234 committed Oct 5, 2020
2 parents ea06738 + 5a6524d commit a5e62e6
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 20 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ History

Next Release
------------
* Fix bug caused from upstream changes -> cobrapy -> pandas.

0.11.1 (2020-08-10)
-------------------
Expand Down
7 changes: 4 additions & 3 deletions src/memote/experimental/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ def load_growth(self, model):
minimal_growth_rate=minimal_growth_rate,
)
if growth.medium is not None:
assert growth.medium in self.media, (
"Growth-experiment '{}' has an undefined medium '{}'."
"".format(exp_id, growth.medium)
assert (
growth.medium in self.media
), "Growth-experiment '{}' has an undefined medium '{}'.".format(
exp_id, growth.medium
)
growth.medium = self.media[growth.medium]
growth.load()
Expand Down
2 changes: 1 addition & 1 deletion src/memote/experimental/essentiality.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def evaluate(self, model):
essen = single_gene_deletion(
model, gene_list=self.data["gene"], processes=1
)
essen["gene"] = [list(g)[0] for g in essen.index]
essen["gene"] = [list(g)[0] for g in essen["ids"]]
essen["essential"] = (essen["growth"] < self.minimal_growth_rate) | essen[
"growth"
].isna()
Expand Down
24 changes: 21 additions & 3 deletions tests/test_for_suite/test_for_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,24 @@ def complete_failure(base):
return base


@pytest.mark.parametrize("model, code", [("complete_failure", 1),], indirect=["model"])
@pytest.mark.parametrize(
"model, code",
[
("complete_failure", 1),
],
indirect=["model"],
)
def test_test_model_code(model, code):
assert api.test_model(model) == code


@pytest.mark.parametrize("model", ["complete_failure",], indirect=["model"])
@pytest.mark.parametrize(
"model",
[
"complete_failure",
],
indirect=["model"],
)
def test_test_model_result(model):
_, result = api.test_model(model, results=True)
# TODO: Once introduced perform schema checks here.
Expand All @@ -73,7 +85,13 @@ def test_test_model_timeout(model):
assert model.solver.configuration.timeout == 1


@pytest.mark.parametrize("model", ["complete_failure",], indirect=["model"])
@pytest.mark.parametrize(
"model",
[
"complete_failure",
],
indirect=["model"],
)
def test_snapshot_report_file(model, tmpdir):
filename = str(tmpdir.join("index.html"))
_, results = api.test_model(model, results=True, pytest_args=["--tb", "no"])
Expand Down
5 changes: 4 additions & 1 deletion tests/test_for_suite/test_for_reporting/test_for_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
},
"test_basic": {"cases": ["test_number"], "title": "Basic Information"},
},
"weights": {"test_number": 1.0, "test_parametrized": 1.0,},
"weights": {
"test_number": 1.0,
"test_parametrized": 1.0,
},
}


Expand Down
18 changes: 15 additions & 3 deletions tests/test_for_support/test_for_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,11 @@ def test_find_nonzero_constrained_reactions(model, num):

@pytest.mark.parametrize(
"model, num",
[("empty", 0), ("unconstrained_rxn", 0), ("zero_constrained_rxn", 1),],
[
("empty", 0),
("unconstrained_rxn", 0),
("zero_constrained_rxn", 1),
],
indirect=["model"],
)
def test_find_zero_constrained_reactions(model, num):
Expand All @@ -725,7 +729,11 @@ def test_find_zero_constrained_reactions(model, num):

@pytest.mark.parametrize(
"model, num",
[("empty", 0), ("unconstrained_rxn", 0), ("irreversible_rxn", 1),],
[
("empty", 0),
("unconstrained_rxn", 0),
("irreversible_rxn", 1),
],
indirect=["model"],
)
def test_find_irreversible_reactions(model, num):
Expand All @@ -736,7 +744,11 @@ def test_find_irreversible_reactions(model, num):

@pytest.mark.parametrize(
"model, num",
[("empty", 0), ("unconstrained_rxn", 1), ("zero_constrained_rxn", 0),],
[
("empty", 0),
("unconstrained_rxn", 1),
("zero_constrained_rxn", 0),
],
indirect=["model"],
)
def test_find_unconstrained_reactions(model, num):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_for_support/test_for_biomass.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def sum_within_deviation(base):

@register_with(MODEL_REGISTRY)
def sum_outside_of_deviation(base):
""" Same as above, yet here H2O is on the wrong side of the equation
"""Same as above, yet here H2O is on the wrong side of the equation
which will throw off the balance.
"""
met_a = cobra.Metabolite("lipid_c", "H744")
Expand Down
48 changes: 41 additions & 7 deletions tests/test_for_support/test_for_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,16 @@ def test_find_unconserved_metabolites(model, inconsistent):
"model, inconsistent",
[
("textbook", []),
("figure_1", [("A'", "B'", "C'",)]),
(
"figure_1",
[
(
"A'",
"B'",
"C'",
)
],
),
("equation_8", [("A",), ("B",), ("C",)]),
("figure_2", [("X",)]),
],
Expand Down Expand Up @@ -670,7 +679,11 @@ def test_find_mass_unbalanced_reactions(model, num):

@pytest.mark.parametrize(
"model, num",
[("loopy_toy_model", 3), ("loopless_toy_model", 0), ("infeasible_toy_model", 0),],
[
("loopy_toy_model", 3),
("loopless_toy_model", 0),
("infeasible_toy_model", 0),
],
indirect=["model"],
)
def test_find_stoichiometrically_balanced_cycles(model, num):
Expand Down Expand Up @@ -702,7 +715,12 @@ def test_find_deadends(model, num):


@pytest.mark.parametrize(
"model, num", [("gap_model", 1), ("gapfilled_model", 0),], indirect=["model"]
"model, num",
[
("gap_model", 1),
("gapfilled_model", 0),
],
indirect=["model"],
)
def test_find_disconnected(model, num):
"""Expect the appropriate amount of disconnected to be found."""
Expand All @@ -712,7 +730,11 @@ def test_find_disconnected(model, num):

@pytest.mark.parametrize(
"model, num",
[("gap_model", 4), ("gap_model_2", 1), ("gapfilled_model", 0),],
[
("gap_model", 4),
("gap_model_2", 1),
("gapfilled_model", 0),
],
indirect=["model"],
)
def test_find_metabolites_not_produced_with_open_bounds(model, num):
Expand All @@ -723,7 +745,11 @@ def test_find_metabolites_not_produced_with_open_bounds(model, num):

@pytest.mark.parametrize(
"model, num",
[("gap_model", 4), ("gap_model_2", 1), ("gapfilled_model", 0),],
[
("gap_model", 4),
("gap_model_2", 1),
("gapfilled_model", 0),
],
indirect=["model"],
)
def test_parallel_find_metabolites_not_produced_with_open_bounds(model, num):
Expand All @@ -735,7 +761,11 @@ def test_parallel_find_metabolites_not_produced_with_open_bounds(model, num):

@pytest.mark.parametrize(
"model, num",
[("gap_model", 4), ("gap_model_2", 1), ("gapfilled_model", 0),],
[
("gap_model", 4),
("gap_model_2", 1),
("gapfilled_model", 0),
],
indirect=["model"],
)
def test_find_metabolites_not_consumed_with_open_bounds(model, num):
Expand All @@ -746,7 +776,11 @@ def test_find_metabolites_not_consumed_with_open_bounds(model, num):

@pytest.mark.parametrize(
"model, num",
[("gap_model", 4), ("gap_model_2", 1), ("gapfilled_model", 0),],
[
("gap_model", 4),
("gap_model_2", 1),
("gapfilled_model", 0),
],
indirect=["model"],
)
def test_parallel_find_metabolites_not_consumed_with_open_bounds(model, num):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_for_support/test_for_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,9 @@ def test_find_converting_reactions(model, met_pair, expected):

@pytest.mark.parametrize(
"model, reaction_id, bounds",
[("one_exchange", "EX_abc_e", (-1000, 1000)),],
[
("one_exchange", "EX_abc_e", (-1000, 1000)),
],
indirect=["model"],
)
def test_open_boundaries(model, reaction_id, bounds):
Expand Down

0 comments on commit a5e62e6

Please sign in to comment.