Skip to content

Commit

Permalink
updated version and instances and enhanced readme
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Jan 9, 2024
1 parent 137169e commit 158d08a
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 3 deletions.
129 changes: 128 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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[
<INSTANCE-NAME>['_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 `<INSTANCE-NAME>` 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)}')
2 changes: 1 addition & 1 deletion biosimulator_processes/_VERSION.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.11'
__version__ = '0.0.12'
2 changes: 1 addition & 1 deletion biosimulator_processes/tests/model_files/minE_model.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 158d08a

Please sign in to comment.