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

Commit

Permalink
updated copasi process for schema and process notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Feb 27, 2024
1 parent 0f3d26e commit 19c0028
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 22 deletions.
8 changes: 3 additions & 5 deletions biosimulator_processes/processes/copasi_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,10 @@ def fetch_biomodel(term: str, index: int = 0):
class CopasiProcess(Process):
# TODO: Update this in constructor
config_schema = {
'model_file': {
'_type': 'string',
'_default': ''
},
'model_file': 'string',
#
'reactions': {
'name': {
'reaction_name': {
'scheme': 'string'
},
},
Expand Down
128 changes: 111 additions & 17 deletions notebooks/copasi_process.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"id": "initial_id",
"metadata": {
"collapsed": true
"collapsed": true,
"ExecuteTime": {
"end_time": "2024-02-27T15:36:56.096550Z",
"start_time": "2024-02-27T15:36:56.091278Z"
}
},
"outputs": [],
"source": [
Expand All @@ -18,20 +22,45 @@
"cell_type": "code",
"outputs": [],
"source": [
"from basico import *\n",
"from process_bigraph import Composite, pf \n",
"from biosimulator_processes.copasi_process import CopasiProcess"
"from biosimulator_processes.processes.copasi_process import CopasiProcess"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-02-27T15:36:57.246146Z",
"start_time": "2024-02-27T15:36:57.239860Z"
}
},
"id": "c6c10dc5988e52d4",
"execution_count": 16
},
{
"cell_type": "markdown",
"source": [
"### Example 1: Define a single process instance and a corresponding emitter"
],
"metadata": {
"collapsed": false
},
"id": "ac92611c7adf47e1"
},
{
"cell_type": "markdown",
"source": [
"##### 1. Define the schema by which our Composite instance will be configured"
],
"metadata": {
"collapsed": false
},
"id": "c6c10dc5988e52d4"
"id": "8608877d697af60c"
},
{
"cell_type": "code",
"outputs": [],
"source": [
"# 1. Define the sim state schema:\n",
"initial_sim_state = {\n",
"instance = {\n",
" 'copasi': {\n",
" '_type': 'process',\n",
" 'address': 'local:copasi',\n",
Expand Down Expand Up @@ -64,57 +93,103 @@
" 'time': ['time_store'],\n",
" }\n",
" }\n",
"}\n",
"\n",
"\n",
"\n",
"\n",
"\n"
"}"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-02-27T15:44:23.766224Z",
"start_time": "2024-02-27T15:44:23.760968Z"
}
},
"id": "77636dbde3fa6b74",
"execution_count": 19
},
{
"cell_type": "markdown",
"source": [],
"metadata": {
"collapsed": false
},
"id": "ab745a55ff67da50"
},
{
"cell_type": "markdown",
"source": [
"##### 2. Instantiate the Process-Bigraph-Engine with the Composite class"
],
"metadata": {
"collapsed": false
},
"id": "77636dbde3fa6b74"
"id": "e5199aee6d533761"
},
{
"cell_type": "code",
"outputs": [],
"source": [
"# 2. Make the composite:\n",
"workflow = Composite({\n",
" 'state': initial_sim_state\n",
" 'state': instance\n",
"})"
],
"metadata": {
"collapsed": false
},
"id": "4c2ef631b005be61"
},
{
"cell_type": "markdown",
"source": [
"##### 3. Run the Composite workflow with the Engine"
],
"metadata": {
"collapsed": false
},
"id": "6a402e48fbc30a5b"
},
{
"cell_type": "code",
"outputs": [],
"source": [
"# 3. Run the composite workflow:\n",
"workflow.run(10)"
],
"metadata": {
"collapsed": false
},
"id": "98676149a4ce822f"
},
{
"cell_type": "markdown",
"source": [
"##### 4. Gather and neatly-print the results."
],
"metadata": {
"collapsed": false
},
"id": "d0ff3a2822a8fa2c"
},
{
"cell_type": "code",
"outputs": [],
"source": [
"# 4. Gather and pretty print results\n",
"results = workflow.gather_results()\n",
"\n",
"print(f'RESULTS: {pf(results)}')"
],
"metadata": {
"collapsed": false
},
"id": "c15cee593ef000a7"
},
{
"cell_type": "markdown",
"source": [
"##### 5. Plot/Analyze the results with Plotly"
],
"metadata": {
"collapsed": false
},
"id": "b098a589f08ce138"
},
{
"cell_type": "code",
"outputs": [],
Expand All @@ -125,6 +200,25 @@
"collapsed": false
},
"id": "297504800772775e"
},
{
"cell_type": "markdown",
"source": [
"### Example 2: Define multiple processes in the same instance for a parameter scan"
],
"metadata": {
"collapsed": false
},
"id": "2afe93d975ed2aee"
},
{
"cell_type": "code",
"outputs": [],
"source": [],
"metadata": {
"collapsed": false
},
"id": "6157c1b8f1f67d05"
}
],
"metadata": {
Expand Down

0 comments on commit 19c0028

Please sign in to comment.