Skip to content

Commit

Permalink
fixed running of sensitivity analysis when total protein constriant i…
Browse files Browse the repository at this point in the history
…s active
  • Loading branch information
SamiralVdB committed Jul 3, 2024
1 parent 5b88d94 commit 283818c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/PAModelpy/PAModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,14 +865,17 @@ def calculate_csc(self, obj_value, mu, mu_ub, mu_lb, mu_ec_f, mu_ec_b):
#treat sectors separately if there is not a total protein constraint
else:
for sector in self.sectors:
constraint = 'sector'
rxn_id = 'R_' + sector.id
enzyme_id = sector.id
ca_coefficient = self.constraints[enzyme_id].ub * mu[mu['rxn_id'] == sector.id]['shadow_prices'].iloc[0] / obj_value

new_row = [rxn_id, enzyme_id, constraint, ca_coefficient]
# add new_row to dataframe
self.capacity_sensitivity_coefficients.loc[len(self.capacity_sensitivity_coefficients)] = new_row
try:
constraint = 'sector'
rxn_id = 'R_' + sector.id
enzyme_id = sector.id
ca_coefficient = self.constraints[enzyme_id].ub * mu[mu['rxn_id'] == sector.id]['shadow_prices'].iloc[0] / obj_value

new_row = [rxn_id, enzyme_id, constraint, ca_coefficient]
# add new_row to dataframe
self.capacity_sensitivity_coefficients.loc[len(self.capacity_sensitivity_coefficients)] = new_row
except:
continue

for rxn in self.reactions:
# LB
Expand Down

0 comments on commit 283818c

Please sign in to comment.