Skip to content

Commit

Permalink
bugfixes related to pamparametrizer
Browse files Browse the repository at this point in the history
  • Loading branch information
SamiralVdB committed Jul 30, 2024
1 parent 9325907 commit ebe380c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
8 changes: 7 additions & 1 deletion Scripts/pam_generation_uniprot_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def parse_reaction2protein(enzyme_db: pd.DataFrame, model:cobra.Model) -> dict:
# no enzyme information found
print('No enzyme information found for reaction: ' + rxn.id)
enzyme_id = 'Enzyme_' + rxn.id
gpr_info = parse_gpr_information_for_protein2genes(rxn.gpr, rxn_id)
gpr_info = parse_gpr_information_for_protein2genes(rxn.gpr)

rxn2protein[rxn.id] = {enzyme_id: {
**kcat_dict,
Expand Down Expand Up @@ -439,3 +439,9 @@ def filter_sublists(nested_list, target_string):
ecoli_pam.change_reaction_bounds('EX_glc__D_e', -10, 0)
ecoli_pam.optimize()
print(ecoli_pam.objective.value)
import pickle

with open('path_to_your_pickle_file.pkl', 'wb') as file:
p = pickle.dump(ecoli_pam, file)
with open('path_to_your_pickle_file.pkl', 'rb') as file:
ob = pickle.load(file)
24 changes: 24 additions & 0 deletions src/PAModelpy/Enzyme.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,30 @@ def add_enzymes(self, enzymes: DictList):
else:
self._model.enzymes.append(enzyme)

def __copy__(self) -> "EnzymeComplex":
"""Copy the enzyme complex.
Returns:
PAModelpy.Enzyme.EnzymeComplex: A new enzyme complex that is a copy of the original enzyme.
"""

cop = copy(super(EnzymeComplex, self))
return cop

def __deepcopy__(self, memo: dict) -> "EnzymeComplex":
"""Copy the enzyme complex with memo.
Args:
memo (dict): Automatically passed parameter.
Returns:
PAModelpy.Enzyme.EnzymeComplex: A new enzyme complex that is a copy of the original enzyme with memo.
"""

cop = deepcopy(super(EnzymeComplex, self), memo)
return cop


class EnzymeVariable(Reaction):
"""EnzymeVariable is a class for holding information regarding the variable representing an enzyme in the model.
For each reaction, the enzyme variables are summarized in a CatalyticEvent.
Expand Down
5 changes: 4 additions & 1 deletion src/PAModelpy/EnzymeSectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ def add(self, model):
kcat = dict(
(k, v) for k, v in enzyme_dict.items() if k == "f" or k == "b"
)
protein_reaction = enzyme_dict['protein_reaction_association']
if 'protein_reaction_association' in enzyme_dict.keys():
protein_reaction = enzyme_dict['protein_reaction_association']
else:
protein_reaction = enzyme_id

# get molar mass of enzyme or replace with default value
if "molmass" in enzyme_dict.keys():
Expand Down
12 changes: 6 additions & 6 deletions src/PAModelpy/PAModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,6 @@ def calculate_csc(self, obj_value, mu, mu_ub, mu_lb, mu_ec_f, mu_ec_b):
len(self.capacity_sensitivity_coefficients)
] = new_row_LB

print(self.enzymes)
for enzyme in self.enzymes:
for catalyzing_enzyme in self._get_catalyzing_enzymes_for_enzyme(enzyme):
ce = self.enzymes.get_by_id(catalyzing_enzyme)
Expand Down Expand Up @@ -1168,12 +1167,13 @@ def change_total_protein_constraint(self, p_tot):
self.solver.update()

def change_sector_parameters(
self, sector, slope: float, intercept: float, lin_rxn_id: str
self, sector, slope: float, intercept: float, lin_rxn_id: str, print_change = False
):
# input in g/gDW
print(f"Changing the slope and intercept of the {sector.id}")
print(f"Changing slope from {sector.slope} to {slope*1e3} mg/gcdw/h")
print(f"Changing intercept from {sector.intercept} to {intercept*1e3} mg/gcdw")
if print_change:
# input in g/gDW
print(f"Changing the slope and intercept of the {sector.id}")
print(f"Changing slope from {sector.slope} to {slope*1e3} mg/gcdw/h")
print(f"Changing intercept from {sector.intercept} to {intercept*1e3} mg/gcdw")

prev_intercept = sector.intercept
# *1e3 to convert g to mg
Expand Down

0 comments on commit ebe380c

Please sign in to comment.