Skip to content

Commit

Permalink
Fixing linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrus-bio committed Aug 19, 2024
1 parent b652920 commit 8e03ff5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
7 changes: 3 additions & 4 deletions ecoli/experiments/metabolism_redux_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand Down
20 changes: 10 additions & 10 deletions notebooks/fbagd/ck.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))


Expand All @@ -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
)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8e03ff5

Please sign in to comment.