Skip to content

Commit ebe380c

Browse files
committed
bugfixes related to pamparametrizer
1 parent 9325907 commit ebe380c

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed

Scripts/pam_generation_uniprot_id.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def parse_reaction2protein(enzyme_db: pd.DataFrame, model:cobra.Model) -> dict:
276276
# no enzyme information found
277277
print('No enzyme information found for reaction: ' + rxn.id)
278278
enzyme_id = 'Enzyme_' + rxn.id
279-
gpr_info = parse_gpr_information_for_protein2genes(rxn.gpr, rxn_id)
279+
gpr_info = parse_gpr_information_for_protein2genes(rxn.gpr)
280280

281281
rxn2protein[rxn.id] = {enzyme_id: {
282282
**kcat_dict,
@@ -439,3 +439,9 @@ def filter_sublists(nested_list, target_string):
439439
ecoli_pam.change_reaction_bounds('EX_glc__D_e', -10, 0)
440440
ecoli_pam.optimize()
441441
print(ecoli_pam.objective.value)
442+
import pickle
443+
444+
with open('path_to_your_pickle_file.pkl', 'wb') as file:
445+
p = pickle.dump(ecoli_pam, file)
446+
with open('path_to_your_pickle_file.pkl', 'rb') as file:
447+
ob = pickle.load(file)

src/PAModelpy/Enzyme.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,30 @@ def add_enzymes(self, enzymes: DictList):
380380
else:
381381
self._model.enzymes.append(enzyme)
382382

383+
def __copy__(self) -> "EnzymeComplex":
384+
"""Copy the enzyme complex.
385+
386+
Returns:
387+
PAModelpy.Enzyme.EnzymeComplex: A new enzyme complex that is a copy of the original enzyme.
388+
"""
389+
390+
cop = copy(super(EnzymeComplex, self))
391+
return cop
392+
393+
def __deepcopy__(self, memo: dict) -> "EnzymeComplex":
394+
"""Copy the enzyme complex with memo.
395+
396+
Args:
397+
memo (dict): Automatically passed parameter.
398+
399+
Returns:
400+
PAModelpy.Enzyme.EnzymeComplex: A new enzyme complex that is a copy of the original enzyme with memo.
401+
"""
402+
403+
cop = deepcopy(super(EnzymeComplex, self), memo)
404+
return cop
405+
406+
383407
class EnzymeVariable(Reaction):
384408
"""EnzymeVariable is a class for holding information regarding the variable representing an enzyme in the model.
385409
For each reaction, the enzyme variables are summarized in a CatalyticEvent.

src/PAModelpy/EnzymeSectors.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ def add(self, model):
176176
kcat = dict(
177177
(k, v) for k, v in enzyme_dict.items() if k == "f" or k == "b"
178178
)
179-
protein_reaction = enzyme_dict['protein_reaction_association']
179+
if 'protein_reaction_association' in enzyme_dict.keys():
180+
protein_reaction = enzyme_dict['protein_reaction_association']
181+
else:
182+
protein_reaction = enzyme_id
180183

181184
# get molar mass of enzyme or replace with default value
182185
if "molmass" in enzyme_dict.keys():

src/PAModelpy/PAModel.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,6 @@ def calculate_csc(self, obj_value, mu, mu_ub, mu_lb, mu_ec_f, mu_ec_b):
999999
len(self.capacity_sensitivity_coefficients)
10001000
] = new_row_LB
10011001

1002-
print(self.enzymes)
10031002
for enzyme in self.enzymes:
10041003
for catalyzing_enzyme in self._get_catalyzing_enzymes_for_enzyme(enzyme):
10051004
ce = self.enzymes.get_by_id(catalyzing_enzyme)
@@ -1168,12 +1167,13 @@ def change_total_protein_constraint(self, p_tot):
11681167
self.solver.update()
11691168

11701169
def change_sector_parameters(
1171-
self, sector, slope: float, intercept: float, lin_rxn_id: str
1170+
self, sector, slope: float, intercept: float, lin_rxn_id: str, print_change = False
11721171
):
1173-
# input in g/gDW
1174-
print(f"Changing the slope and intercept of the {sector.id}")
1175-
print(f"Changing slope from {sector.slope} to {slope*1e3} mg/gcdw/h")
1176-
print(f"Changing intercept from {sector.intercept} to {intercept*1e3} mg/gcdw")
1172+
if print_change:
1173+
# input in g/gDW
1174+
print(f"Changing the slope and intercept of the {sector.id}")
1175+
print(f"Changing slope from {sector.slope} to {slope*1e3} mg/gcdw/h")
1176+
print(f"Changing intercept from {sector.intercept} to {intercept*1e3} mg/gcdw")
11771177

11781178
prev_intercept = sector.intercept
11791179
# *1e3 to convert g to mg

0 commit comments

Comments
 (0)