class TestAssertionIrreversible: @pytest.fixture(autouse=True) def setup_items(self): self.reaction = Reaction("r1") self.evidence = Evidence(entity=self.reaction, assertion="Irreversible") def test_not_valid_if_reaction_reversible(self): self.reaction.lower_bound = -1000. self.reaction.upper_bound = 1000. assert self.evidence.is_valid() is False def test_valid_if_irreversible(self): self.reaction.lower_bound = 0. self.reaction.upper_bound = 1000. assert self.evidence.is_valid() is True self.reaction.lower_bound = -1000. self.reaction.upper_bound = 0. assert self.evidence.is_valid() is True def test_reaction_needed(self): evidence = Evidence(assertion="Irreversible") assert evidence.is_valid() is None def test_fix_reaction(self): self.reaction.lower_bound = -1000. self.reaction.upper_bound = 1000. status = self.evidence.fix() assert status is True assert self.reaction.lower_bound == 0. assert self.reaction.upper_bound == 1000. def test_fix_nonstandard_boundary_kept(self): self.reaction.lower_bound = -1000. self.reaction.upper_bound = 500. status = self.evidence.fix() assert status is True assert self.reaction.lower_bound == 0. assert self.reaction.upper_bound == 500.
class TestAssertionCatalyzingReaction: @pytest.fixture(autouse=True) def setup_items(self): self.reaction = Reaction("r1") self.gene = Gene("g1") self.evidence = Evidence(entity=self.gene, target=self.reaction, assertion="Catalyzing reaction") def test_valid_if_gene_in_reaction(self): self.reaction.add_child(self.gene) assert self.evidence.is_valid() is True def test_invalid_if_gene_not_in_reaction(self): assert self.evidence.is_valid() is False def test_gene_needed(self): evidence = Evidence(entity=self.gene, assertion="Catalyzing reaction") assert evidence.is_valid() is None def test_reaction_needed(self): evidence = Evidence(target=self.reaction, assertion="Catalyzing reaction") assert evidence.is_valid() is None def test_fix_gene_added(self): assert self.gene not in self.reaction.genes status = self.evidence.fix() assert status is True assert self.gene in self.reaction.genes
class TestAssertionPresent: @pytest.fixture(autouse=True) def setup_items(self): self.reaction = Reaction("r1") self.evidence = Evidence(entity=self.reaction, assertion="Present") def test_valid_if_reaction_is_active(self): self.reaction.lower_bound = -1000. self.reaction.upper_bound = 0. assert self.evidence.is_valid() is True self.reaction.upper_bound = 1000. assert self.evidence.is_valid() is True self.reaction.lower_bound = 0. assert self.evidence.is_valid() is True def test_invalid_if_reaction_not_active(self): self.reaction.lower_bound = 0. self.reaction.upper_bound = 0. assert self.evidence.is_valid() is False def test_valid_if_metabolite_entity(self): self.evidence.set_entity(Metabolite("m1")) assert self.evidence.is_valid() is True def test_entity_needed(self): evidence = Evidence() assert evidence.is_valid() is None def test_fixing_not_implemented(self): self.reaction.lower_bound = 0 self.reaction.upper_bound = 0 self.evidence.fix() assert self.reaction.lower_bound == 0. assert self.reaction.upper_bound == 0.