Skip to content

Commit

Permalink
clean up copasi
Browse files Browse the repository at this point in the history
  • Loading branch information
eagmon committed Feb 14, 2024
1 parent 0b3bf0e commit b1ec62c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 34 deletions.
31 changes: 3 additions & 28 deletions biosimulator_processes/copasi_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,9 @@ def __init__(self, config=None):
# Load the single cell model into Basico
self.copasi_model_object = load_model(self.config['model_file'])

# TODO -- make this configurable.
self.input_ports = [
'floating_species',
'model_parameters',
'time',
# 'boundary_species',
# 'compartments',
# 'parameters',
# 'stoichiometries',
]

self.output_ports = [
'floating_species',
'time',
]

# Get the species (floating and boundary)
# Get the species (floating only) TODO: add boundary species
self.floating_species_list = get_species(model=self.copasi_model_object).index.tolist()
self.floating_species_initial = get_species(model=self.copasi_model_object)['concentration'].tolist()
# self.boundary_species_list = get_species(model=self.copasi_model_object).index.tolist()
# self.boundary_species_initial = get_species(model=self.copasi_model_object)['concentration'].tolist()

# Get the list of parameters and their values
self.model_parameters_list = get_parameters(model=self.copasi_model_object).index.tolist()
Expand All @@ -59,12 +41,10 @@ def __init__(self, config=None):

def initial_state(self):
floating_species_dict = dict(zip(self.floating_species_list, self.floating_species_initial))
# boundary_species_dict = dict(zip(self.boundary_species_list, self.boundary_species_initial))
model_parameters_dict = dict(zip(self.model_parameters_list, self.model_parameter_values))
return {
'time': 0.0,
'floating_species': floating_species_dict,
# 'boundary_species': boundary_species_dict,
'model_parameters': model_parameters_dict
}

Expand All @@ -78,9 +58,6 @@ def inputs(self):
return {
'time': 'float',
'floating_species': floating_species_type,
# TODO -- this should be a float with a set updater
# 'boundary_species': {
# species_id: 'float' for species_id in self.boundary_species_list},
'model_parameters': {
param_id: 'float' for param_id in self.model_parameters_list},
'reactions': {
Expand All @@ -102,10 +79,8 @@ def outputs(self):
def update(self, inputs, interval):

# set copasi values according to what is passed in states
for port_id, values in inputs.items():
if port_id in self.input_ports: # only update from input ports
for cat_id, value in values.items():
set_species(name=cat_id, initial_concentration=value, model=self.copasi_model_object)
for cat_id, value in inputs['floating_species'].items():
set_species(name=cat_id, initial_concentration=value, model=self.copasi_model_object)

# run model for "interval" length; we only want the state at the end
timecourse = run_time_course(
Expand Down
9 changes: 3 additions & 6 deletions biosimulator_processes/experiments/parameter_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@ def test_param_scan_copasi():
'_type': 'process',
'address': 'local:copasi',
'config': {
'model_file': 'tests/model_files/Caravagna2010.xml'
'model_file': 'model_files/Caravagna2010.xml'
},
'inputs': {
'floating_species': ['floating_species_store'],
# 'boundary_species': ['boundary_species_store'],
'model_parameters': ['model_parameters_store'],
'time': ['time_store'],
# 'compartments': ['compartments_store'],
# 'parameters': ['parameters_store'],
# 'stoichiometries': ['stoichiometries_store']
'reactions': ['reactions_store']
},
'outputs': {
'floating_species': ['floating_species_store'],
Expand Down Expand Up @@ -62,7 +59,7 @@ def run_param_scan_cobra():
'_type': 'process',
'address': 'local:cobra',
'config': {
'model_file': 'tests/model_files/e_coli_core.xml'
'model_file': 'model_files/e_coli_core.xml'
},
'inputs': {
'model': ['model_store'],
Expand Down

0 comments on commit b1ec62c

Please sign in to comment.