Skip to content

Commit

Permalink
made sure enzymes and associated complexes get removed properly
Browse files Browse the repository at this point in the history
  • Loading branch information
SamiralVdB committed Jul 23, 2024
1 parent fed9fa7 commit 8e77e51
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/PAModelpy/PAModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,10 @@ def remove_enzymes(
self.enzymes.remove(enzyme)
enzyme._model = None

# remove enzyme complexes related to this enzyme
for complex in self.enzymes.query(enzyme.id):
self.remove_enzymes(complex)

# remove variable related to the enzyme
self.enzyme_variables.remove(enzyme.enzyme_variable)
forward = enzyme.enzyme_variable.forward_variable
Expand Down
26 changes: 26 additions & 0 deletions tests/unit_tests/test_pamodel/test_pamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from cobra.io import load_json_model

from src.PAModelpy import PAModel,Config,ActiveEnzymeSector, UnusedEnzymeSector, TransEnzymeSector
from tests.unit_tests.test_pamodel.test_pam_generation import set_up_toy_pam_with_isozymes_and_enzymecomplex

def test_if_pamodel_change_kcat_function_works():
#arrange
Expand Down Expand Up @@ -155,6 +156,31 @@ def test_if_pamodel_remove_sectors_can_remove_translational_protein_sector():
assert toy_pam.constraints[toy_pam.TOTAL_PROTEIN_CONSTRAINT_ID].ub == tpc_ub + sector.intercept
assert all(coeff == 0 for coeff in lin_coeff.values())

def test_if_pamodel_remove_enzymes_removes_all_constraints():
# Arrange
toy_pam = set_up_toy_pam_with_isozymes_and_enzymecomplex(sensitivity=False)
enz_to_remove = 'E10'
ce_names = ['CE_R3_E3_E10_E11', 'R2_E10']
ec_names = ['EC_E3_E10_E11_f', 'EC_E3_E10_E11_b', 'EC_E10_f', 'EC_E10_b']

# Act
toy_pam.remove_enzymes(enz_to_remove)

# Assert
# catalytic events should be removed
for ce in ce_names:
assert ce not in list(toy_pam.reactions)

# constraints should be removed
for ec in ec_names:
assert not any(ec==key for key in toy_pam.constraints.keys())

# enzymes and enzyme variables should not be there
assert len(toy_pam.enzymes.query(enz_to_remove)) == 0
assert len(toy_pam.enzyme_variables.query(enz_to_remove)) == 0



#######################################################################################################
#HELPER METHODS
#######################################################################################################
Expand Down

0 comments on commit 8e77e51

Please sign in to comment.