-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d731f43
commit 8959d69
Showing
18 changed files
with
1,493 additions
and
2,350 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,32 @@ | ||
from dataclasses import dataclass | ||
|
||
from process_bigraph.experiments.parameter_scan import RunProcess | ||
|
||
from biosimulator_processes import CORE | ||
|
||
|
||
@dataclass | ||
class OutputAspectVerification: | ||
aspect_type: str # one of: 'names', 'values'. TODO: Add more | ||
is_verified: bool | ||
expected_data: any | ||
process_data: any | ||
|
||
|
||
class ODEProcess(RunProcess): | ||
def __init__(self, config=None, core=CORE, **kwargs): | ||
"""ODE-based wrapper of RunProcess from process_bigraph. | ||
kwargs: | ||
'process_address': 'string', | ||
'process_config': 'tree[any]', | ||
'observables': 'list[path]', | ||
'timestep': 'float', | ||
'runtime': 'float' | ||
""" | ||
configuration = config or kwargs | ||
configuration['observables'] = kwargs.get('observables') or self.set_observables() | ||
super().__init__(configuration, core) | ||
|
||
def set_observables(self): | ||
return [(k, v) for k, v in self.process.inputs().items()] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import matplotlib.pyplot as plt | ||
from process_bigraph.experiments.parameter_scan import RunProcess | ||
|
||
from biosimulator_processes import CORE | ||
from biosimulator_processes.steps.ode_simulation import ODEProcess | ||
|
||
|
||
def get_observables(proc: RunProcess): | ||
observables = [] | ||
for port_name, port_dict in proc.process.inputs().items(): | ||
if port_name.lower() == 'floating_species_concentrations': | ||
if isinstance(port_dict, dict): | ||
for name, typeVal in port_dict.items(): | ||
obs = [port_name, name] | ||
observables.append(obs) | ||
else: | ||
obs = [port_name] | ||
observables.append(obs) | ||
return observables | ||
|
||
|
||
def generate_ode_instance(process_address: str, model_fp: str, step_size: float, duration: float) -> ODEProcess: | ||
ode_process_config = {'model': {'model_source': model_fp}} | ||
proc = RunProcess( | ||
config={ | ||
'process_address': process_address, | ||
'process_config': ode_process_config, | ||
'timestep': step_size, | ||
'runtime': duration}, | ||
core=CORE) | ||
obs = get_observables(proc) | ||
|
||
return ODEProcess( | ||
address=process_address, | ||
model_fp=model_fp, | ||
observables=obs, | ||
step_size=step_size, | ||
duration=duration) | ||
|
||
|
||
def plot_ode_output_data(data: dict): | ||
time = data['results']['time'] | ||
spec_outputs = [] | ||
for name, output in data['results']['floating_species_concentrations'].items(): | ||
spec_outputs.append({name: output}) | ||
|
||
# Plotting the data | ||
plt.figure(figsize=(10, 8)) | ||
for output in spec_outputs: | ||
for name, out in output.items(): | ||
plt.plot(time, out, label=name) | ||
|
||
plt.xlabel('Time') | ||
plt.ylabel('Concentration') | ||
plt.title('Species Concentrations Over Time') | ||
plt.legend() | ||
plt.grid(True) | ||
plt.show() | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.