Skip to content

Commit

Permalink
set up comets demo for profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
eagmon committed Aug 1, 2024
1 parent fb72151 commit b564808
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions process_bigraph/experiments/comets.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def apply_non_negative(schema, current, update, core):

# TODO -- check the function signature of the apply method and report missing keys upon registration

MODEL_FOR_TESTING = load_model('textbook')

class DynamicFBA(Process):
"""
Performs dynamic FBA.
Expand All @@ -46,6 +48,7 @@ class DynamicFBA(Process):

config_schema = {
'model_file': 'string',
'model': 'Any',
'kinetic_params': 'map[tuple[float,float]]',
'biomass_reaction': {
'_type': 'string',
Expand All @@ -59,11 +62,17 @@ class DynamicFBA(Process):
def __init__(self, config, core):
super().__init__(config, core)

if not 'xml' in self.config['model_file']:
if self.config['model_file'] == 'TESTING':
self.model = MODEL_FOR_TESTING
elif not 'xml' in self.config['model_file']:
# use the textbook model if no model file is provided
self.model = load_model(self.config['model_file'])
else:
elif isinstance(self.config['model_file'], str):
self.model = cobra.io.read_sbml_model(self.config['model_file'])
else:
# error handling
raise ValueError('Invalid model file')


for reaction_id, bounds in self.config['bounds'].items():
if bounds['lower'] is not None:
Expand Down Expand Up @@ -385,7 +394,7 @@ def run_diffusion_process():


def run_comets():
n_bins = (10, 10)
n_bins = (6, 6)

initial_glucose = np.random.uniform(low=0, high=20, size=n_bins)
initial_acetate = np.random.uniform(low=0, high=0, size=n_bins)
Expand All @@ -397,7 +406,9 @@ def run_comets():
dfba_processes_dict[f'[{i},{j}]'] = {
'_type': 'process',
'address': 'local:DynamicFBA',
'config': dfba_config(),
'config': dfba_config(
model_file='TESTING' # load the same model for all processes
),
'inputs': {
'substrates': {
'glucose': ['..', 'fields', 'glucose', i, j],
Expand Down Expand Up @@ -471,7 +482,7 @@ def run_comets():

sim = Composite({'state': composite_state}, core=core)

sim.update({}, 10.0)
sim.update({}, 100.0)

results = sim.gather_results()

Expand Down

0 comments on commit b564808

Please sign in to comment.