From 158d08ab7378917a74fb3aed863d852fc6fd1a96 Mon Sep 17 00:00:00 2001 From: alexPatrie Date: Tue, 9 Jan 2024 13:50:23 -0500 Subject: [PATCH] updated version and instances and enhanced readme --- README.md | 129 +++++++++++++++++- biosimulator_processes/_VERSION.py | 2 +- .../tests/model_files/minE_model.txt | 2 +- 3 files changed, 130 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c935eb534..b908318a5 100644 --- a/README.md +++ b/README.md @@ -48,4 +48,131 @@ Mac, please adhere to the following instructions: scripts/install-with-smoldyn-for-mac-silicon.sh ### Quick Start Example: -#### TODO: Add quickstart example of instance declarations. + +Composing, running, and viewing the results of a composite simulation can be achieved in as little as 4 steps. +In this example, we use the `CopasiProcess` implementation to compose a sbml-based simulation. + +1. Define the composite instance according to the `process_bigraph.Composite` API and relative process + implementation (in this case the `CopasiProcess`). Each instance of the Copasi process requires the specification + of an SBML model file, which is specified in the inner key, `'config'` : + + from process_bigraph import Composite, pf + + instance = { + 'copasi': { + '_type': 'process', + 'address': 'local:copasi', + 'config': { + 'model_file': 'biosimulator_processes/tests/model_files/Caravagna2010.xml' + }, + 'inputs': { + 'floating_species': ['floating_species_store'], + 'model_parameters': ['model_parameters_store'], + 'time': ['time_store'], + }, + 'outputs': { + 'floating_species': ['floating_species_store'], + 'time': ['time_store'], + } + }, + 'emitter': { + '_type': 'step', + 'address': 'local:ram-emitter', + 'config': { + 'ports': { + 'inputs': { + 'floating_species': 'tree[float]', + 'time': 'float' + }, + 'output': { + 'floating_species': 'tree[float]', + 'time': 'float' + } + } + }, + 'inputs': { + 'floating_species': ['floating_species_store'], + 'time': ['time_store'] + } + } + } + + As you can see, each instance definition is expected to have the following key heirarchy: + + instance[ + ['_type', 'address', 'config', 'inputs', 'outputs'], + ['emitter']['_type', 'address', 'config', 'inputs', 'outputs'] + ] + Each instance requires at least one process and one emitter. Usually, there may be multiple processes and just + one emitter, thereby sharing memory amongst the chained processes. + + Both `` and `'emitter'` share the same inner keys. Here, pay close attention to how the `'address'` + is set for both the instance name and emitter. + +2. Create a `process_bigraph.Composite` instance: + + workflow = Composite({ + 'state': instance + }) + +3. Run the composite instance which is configured by the `instance` that we defined: + + workflow.run(10) + +4. Gather and pretty print results: + + results = workflow.gather_results() + print(f'RESULTS: {pf(results)}') + + +A simplified view of the above script: + + + from process_bigraph import Composite, pf + + >> instance = { + 'copasi': { + '_type': 'process', + 'address': 'local:copasi', + 'config': { + 'model_file': 'biosimulator_processes/tests/model_files/Caravagna2010.xml' + }, + 'inputs': { + 'floating_species': ['floating_species_store'], + 'model_parameters': ['model_parameters_store'], + 'time': ['time_store'], + }, + 'outputs': { + 'floating_species': ['floating_species_store'], + 'time': ['time_store'], + } + }, + 'emitter': { + '_type': 'step', + 'address': 'local:ram-emitter', + 'config': { + 'ports': { + 'inputs': { + 'floating_species': 'tree[float]', + 'time': 'float' + }, + 'output': { + 'floating_species': 'tree[float]', + 'time': 'float' + } + } + }, + 'inputs': { + 'floating_species': ['floating_species_store'], + 'time': ['time_store'] + } + } + } + + >> workflow = Composite({ + 'state': instance + }) + + >> workflow.run(10) + >> results = workflow.gather_results() + >> print(f'RESULTS: {pf(results)}') diff --git a/biosimulator_processes/_VERSION.py b/biosimulator_processes/_VERSION.py index ad3cf1dd2..b459ff205 100644 --- a/biosimulator_processes/_VERSION.py +++ b/biosimulator_processes/_VERSION.py @@ -1 +1 @@ -__version__ = '0.0.11' +__version__ = '0.0.12' diff --git a/biosimulator_processes/tests/model_files/minE_model.txt b/biosimulator_processes/tests/model_files/minE_model.txt index 054f3b506..ef8eaa011 100644 --- a/biosimulator_processes/tests/model_files/minE_model.txt +++ b/biosimulator_processes/tests/model_files/minE_model.txt @@ -22,7 +22,7 @@ define L_PARAM2 1.5 # half of cell length minus radius define NUMBER_MIND 4000 # number of MinD in cell 4000 define NUMBER_MINE 1400 # number of MinE in cell 1400 -define TIME_STOP 10 # stopping time +define TIME_STOP 1 # stopping time #define KICK_START 1 # start with MinD_ATP at an end