Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
added copasi process docs to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Feb 28, 2024
1 parent 44dad45 commit 623983b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 19 deletions.
23 changes: 22 additions & 1 deletion biosimulator_processes/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import Dict
from basico import biomodels, load_model_from_string
from process_bigraph import Composite, pf


def fetch_biomodel_by_term(term: str, index: int = 0):
Expand All @@ -18,11 +20,30 @@ def fetch_biomodel_by_term(term: str, index: int = 0):


def fetch_biomodel(model_id: str):
# TODO: make this generalizable
sbml = biomodels.get_content_for_model(model_id)
return load_model_from_string(sbml)


def generate_copasi_process_instance(config: dict, instance_name: str):
def play_composition(instance: dict, duration: int):
"""Configure and run a Composite workflow"""
workflow = Composite({
'state': instance
})
workflow.run(duration)
results = workflow.gather_results()
print(f'RESULTS: {pf(results)}')
return results


def generate_copasi_process_instance(instance_name: str, config: Dict) -> Dict:
"""Generate an instance of a single copasi process which is named `instance_name`
and configured by `config` formatted to the process bigraph Composite API.
Args:
instance_name:`str`: name of the new instance referenced by PBG.
config:`Dict`: see `biosimulator_processes.processes.copasi_process.CopasiProcess`
"""
return {
instance_name: {
'_type': 'process',
Expand Down
47 changes: 29 additions & 18 deletions notebooks/copasi_process_composer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "initial_id",
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2024-02-28T21:35:30.970032Z",
"start_time": "2024-02-28T21:35:30.965409Z"
}
},
"outputs": [],
"source": [
"import sys \n",
Expand All @@ -24,12 +29,27 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "c6c10dc5988e52d4",
"metadata": {
"collapsed": false
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-02-28T21:35:36.900035Z",
"start_time": "2024-02-28T21:35:34.590082Z"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CobraProcess registered successfully.\n",
"CopasiProcess registered successfully.\n",
"SmoldynProcess registered successfully.\n",
"TelluriumProcess registered successfully.\n"
]
}
],
"source": [
"import os \n",
"from basico import *\n",
Expand All @@ -41,16 +61,7 @@
{
"cell_type": "code",
"outputs": [],
"source": [
"def play_composition(instance: dict, duration: int):\n",
" workflow = Composite({\n",
" 'state': instance\n",
" })\n",
" workflow.run(duration)\n",
" results = workflow.gather_results()\n",
" print(f'RESULTS: {pf(results)}')\n",
" return results"
],
"source": [],
"metadata": {
"collapsed": false
},
Expand Down Expand Up @@ -376,12 +387,12 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-02-28T21:21:05.924230Z",
"start_time": "2024-02-28T21:21:05.401040Z"
"end_time": "2024-02-28T21:35:19.452122Z",
"start_time": "2024-02-28T21:35:19.448652Z"
}
},
"id": "56fe39f779b76c37",
"execution_count": 2
"execution_count": 3
},
{
"cell_type": "code",
Expand Down

0 comments on commit 623983b

Please sign in to comment.