From 8e03ff5b192e7806f3ca1bf6d6cf30202d9e30ef Mon Sep 17 00:00:00 2001 From: Cyrus Date: Mon, 19 Aug 2024 19:13:22 +0200 Subject: [PATCH] Fixing linting. --- ecoli/experiments/metabolism_redux_sim.py | 7 +++---- notebooks/fbagd/ck.py | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/ecoli/experiments/metabolism_redux_sim.py b/ecoli/experiments/metabolism_redux_sim.py index ff48a42f8..0972d7746 100644 --- a/ecoli/experiments/metabolism_redux_sim.py +++ b/ecoli/experiments/metabolism_redux_sim.py @@ -12,10 +12,10 @@ from ecoli.experiments.ecoli_master_sim import EcoliSim, CONFIG_DIR_PATH from ecoli.library.json_state import get_state_from_file -from wholecell.utils import units import numpy as np -import pathlib, datetime +import pathlib +import datetime import dill def run_ecoli_with_metabolism_redux( @@ -48,7 +48,7 @@ def run_ecoli_with_metabolism_redux( query = [] folder = f'out/fbagd/{name}_{total_time}_{datetime.date.today()}/' - # save_sim_output(folder, query, sim, save_model=True) + save_sim_output(folder, query, sim, save_model=True) # disables growth rate control def run_ecoli_with_metabolism_redux_classic( @@ -282,7 +282,6 @@ def run_ecoli_with_default_metabolism( } - def save_sim_output(folder, query, sim, save_model=False): agents = sim.query()['agents'].keys() for agent in agents: diff --git a/notebooks/fbagd/ck.py b/notebooks/fbagd/ck.py index 2132bfac8..e85c9a37b 100644 --- a/notebooks/fbagd/ck.py +++ b/notebooks/fbagd/ck.py @@ -205,13 +205,13 @@ def construct_kinetic_objective(self, flow_data, enzyme_data, n_flux_set, n_rxn, def create_objective_function(self, cfwd, crev, c, Km_s, Km_p, Km_i, Km_a, y_s, y_p, - denom_expr, dmdt=None, l=0.001, e=0.000001, f=1, g = 0.00000001, c_prior = 8): + denom_expr, dmdt=None, l_w=0.001, e=0.000001, f=1, g = 0.00000001, c_prior = 8): loss = 0 l1 = cp.sum(cp.hstack([cfwd])) - l2 = cp.sum(cp.hstack([crev])) + cp.sum(cp.hstack([-Km_s, -Km_p])) # regularization - l1_c = cp.sum(cp.hstack([c])) # weak regularization for concentrations + # l2 = cp.sum(cp.hstack([crev])) + cp.sum(cp.hstack([-Km_s, -Km_p])) # regularization + # l1_c = cp.sum(cp.hstack([c])) # weak regularization for concentrations prior = cp.norm1(cp.hstack([cp.vec(c) - c_prior])) @@ -224,8 +224,8 @@ def create_objective_function(self, cfwd, crev, c, Km_s, Km_p, Km_i, Km_a, y_s, # loss += cp.norm1(cp.pos(cp.log_sum_exp(LSE_expr[i]))) for i in range(len(denom_expr)): loss += f * denom_expr[i] - loss += (l * l1 - + e * prior + loss += (l_w * l1 + + e * prior # + g * l1_c ) @@ -316,9 +316,9 @@ def evaluate_flux_reconstruction(self, vE, nE, n_flux_set, n_rxn, S_b, S_s_nz, S for i in range(n_rxn): # sum terms are separate in logsumexp. one per saturation term (row in C_alpha, C_beta) - n_term_s = np.sum(d_alpha == i) - n_term_p = np.sum(d_beta == i) - n_term = n_term_s + n_term_p + # n_term_s = np.sum(d_alpha == i) + # n_term_p = np.sum(d_beta == i) + # n_term = n_term_s + n_term_p Km_s_idx = np.nonzero(S_s_nz[1, :] == i) S_s_idx = S_s_nz[0, S_s_nz[1, :] == i] # negate -1 entries @@ -362,11 +362,11 @@ def __init__(self): def forward_step(self, cn, nE, S_matrix, cfwd, crev, Km_s, Km_p, Km_i, Km_a, S_s_nz, S_p_nz, S_s_mol, S_p_mol, S_b, C_alpha, C_beta, d_alpha, d_beta, n_rxn, met_s_nz, met_p_nz, met_i_nz, met_a_nz, debug=True, noise=0): - sat_expr = [] + # sat_expr = [] nfwd_sat = np.zeros(n_rxn) nback_sat = np.zeros(n_rxn) nsat = np.zeros(n_rxn) - v_cur = np.zeros(n_rxn) + # v_cur = np.zeros(n_rxn) S_x = csr_matrix(S_b) C_alpha_x = csr_matrix(C_alpha)