diff --git a/notebooks/demo_compose.ipynb b/notebooks/demo_compose.ipynb new file mode 100644 index 000000000..e6509dfc7 --- /dev/null +++ b/notebooks/demo_compose.ipynb @@ -0,0 +1,752 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "808b6a4b-0894-4a8e-99d8-bf11b3164b6a", + "metadata": {}, + "source": [ + "## Examples with ```CopasiProcess``` using ``builder.Builder`` and ``biosimulator_processes.data_model``" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "b385dca6-942d-472c-9963-13b8cb33843c", + "metadata": { + "ExecuteTime": { + "end_time": "2024-03-01T20:26:45.156450Z", + "start_time": "2024-03-01T20:26:43.414577Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "CobraProcess registered successfully.\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/alex/Library/Caches/pypoetry/virtualenvs/biosimulator-processes-KVuYbFzt-py3.10/lib/python3.10/site-packages/pydantic/_internal/_fields.py:151: UserWarning: Field \"model_id\" has conflict with protected namespace \"model_\".\n", + "\n", + "You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.\n", + " warnings.warn(\n", + "/Users/alex/Library/Caches/pypoetry/virtualenvs/biosimulator-processes-KVuYbFzt-py3.10/lib/python3.10/site-packages/pydantic/_internal/_fields.py:151: UserWarning: Field \"model_source\" has conflict with protected namespace \"model_\".\n", + "\n", + "You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.\n", + " warnings.warn(\n", + "/Users/alex/Library/Caches/pypoetry/virtualenvs/biosimulator-processes-KVuYbFzt-py3.10/lib/python3.10/site-packages/pydantic/_internal/_fields.py:151: UserWarning: Field \"model_language\" has conflict with protected namespace \"model_\".\n", + "\n", + "You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.\n", + " warnings.warn(\n", + "/Users/alex/Library/Caches/pypoetry/virtualenvs/biosimulator-processes-KVuYbFzt-py3.10/lib/python3.10/site-packages/pydantic/_internal/_fields.py:151: UserWarning: Field \"model_name\" has conflict with protected namespace \"model_\".\n", + "\n", + "You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.\n", + " warnings.warn(\n", + "/Users/alex/Library/Caches/pypoetry/virtualenvs/biosimulator-processes-KVuYbFzt-py3.10/lib/python3.10/site-packages/pydantic/_internal/_fields.py:151: UserWarning: Field \"model_changes\" has conflict with protected namespace \"model_\".\n", + "\n", + "You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.\n", + " warnings.warn(\n", + "/Users/alex/Library/Caches/pypoetry/virtualenvs/biosimulator-processes-KVuYbFzt-py3.10/lib/python3.10/site-packages/pydantic/_internal/_fields.py:151: UserWarning: Field \"model_units\" has conflict with protected namespace \"model_\".\n", + "\n", + "You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "CopasiProcess registered successfully.\n", + "SmoldynProcess registered successfully.\n", + "TelluriumProcess registered successfully.\n" + ] + } + ], + "source": [ + "from builder import Builder, Process\n", + "from process_bigraph import pp, pf \n", + "from biosimulator_processes import CORE\n", + "from biosimulator_processes.data_model import *\n", + "from biosimulator_processes.biosimulator_builder import BiosimulatorBuilder" + ] + }, + { + "cell_type": "markdown", + "id": "a403d619-4dbe-49cc-8f24-29a83e31fe15", + "metadata": {}, + "source": [ + "#### Initialize a fresh instance of the `BiosimulatorBuilder`, which is inherently configured by `biosimulator_processes.CORE`." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "b6260555-2bad-4834-adc5-e6d358063579", + "metadata": { + "ExecuteTime": { + "end_time": "2024-03-01T20:26:45.156955Z", + "start_time": "2024-03-01T20:26:45.154066Z" + } + }, + "outputs": [], + "source": [ + "b = BiosimulatorBuilder()" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "40cde984-cfdf-4571-af9c-3a3755e3763c", + "metadata": { + "ExecuteTime": { + "end_time": "2024-03-01T20:26:45.163368Z", + "start_time": "2024-03-01T20:26:45.157609Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": "['TelluriumProcess',\n 'ram-emitter',\n 'CobraProcess',\n 'SmoldynProcess',\n 'console-emitter',\n 'CopasiProcess']" + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "###### list registered processes\n", + "\n", + "b.list_processes()" + ] + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from basico import *\n", + "from basico import biomodels\n", + "\n", + "\n", + "model = load_biomodel('BIOMD0000000861')" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-01T20:26:47.219279Z", + "start_time": "2024-03-01T20:26:45.160804Z" + } + }, + "id": "9279a6fec5ad0c48", + "execution_count": 4 + }, + { + "cell_type": "code", + "outputs": [ + { + "data": { + "text/plain": " compartment type unit initial_concentration \\\nname \nEpoRJAK2 cyt reactions nmol/l 3.976220e+00 \nEpoRpJAK2 cyt reactions nmol/l 0.000000e+00 \np1EpoRpJAK2 cyt reactions nmol/l 0.000000e+00 \np2EpoRpJAK2 cyt reactions nmol/l 0.000000e+00 \np12EpoRpJAK2 cyt reactions nmol/l 0.000000e+00 \nEpoRJAK2_CIS cyt reactions nmol/l 0.000000e+00 \nSHP1 cyt reactions nmol/l 2.672510e+01 \nSHP1Act cyt reactions nmol/l 0.000000e+00 \nSTAT5 cyt reactions nmol/l 7.975350e+01 \npSTAT5 cyt reactions nmol/l 0.000000e+00 \nnpSTAT5 nuc reactions nmol/l 0.000000e+00 \nCISnRNA1 nuc reactions nmol/l 0.000000e+00 \nCISnRNA2 nuc reactions nmol/l 0.000000e+00 \nCISnRNA3 nuc reactions nmol/l 0.000000e+00 \nCISnRNA4 nuc reactions nmol/l 0.000000e+00 \nCISnRNA5 nuc reactions nmol/l 0.000000e+00 \nCISRNA cyt reactions nmol/l 0.000000e+00 \nCIS cyt reactions nmol/l 0.000000e+00 \nSOCS3nRNA1 nuc reactions nmol/l 0.000000e+00 \nSOCS3nRNA2 nuc reactions nmol/l 0.000000e+00 \nSOCS3nRNA3 nuc reactions nmol/l 0.000000e+00 \nSOCS3nRNA4 nuc reactions nmol/l 0.000000e+00 \nSOCS3nRNA5 nuc reactions nmol/l 0.000000e+00 \nSOCS3RNA cyt reactions nmol/l 0.000000e+00 \nSOCS3 cyt reactions nmol/l 0.000000e+00 \nEpo cyt reactions nmol/l 1.249970e-07 \n\n initial_particle_number initial_expression expression \\\nname \nEpoRJAK2 9.578143e+14 \nEpoRpJAK2 0.000000e+00 \np1EpoRpJAK2 0.000000e+00 \np2EpoRpJAK2 0.000000e+00 \np12EpoRpJAK2 0.000000e+00 \nEpoRJAK2_CIS 0.000000e+00 \nSHP1 6.437693e+15 \nSHP1Act 0.000000e+00 \nSTAT5 1.921147e+16 \npSTAT5 0.000000e+00 \nnpSTAT5 0.000000e+00 \nCISnRNA1 0.000000e+00 \nCISnRNA2 0.000000e+00 \nCISnRNA3 0.000000e+00 \nCISnRNA4 0.000000e+00 \nCISnRNA5 0.000000e+00 \nCISRNA 0.000000e+00 \nCIS 0.000000e+00 \nSOCS3nRNA1 0.000000e+00 \nSOCS3nRNA2 0.000000e+00 \nSOCS3nRNA3 0.000000e+00 \nSOCS3nRNA4 0.000000e+00 \nSOCS3nRNA5 0.000000e+00 \nSOCS3RNA 0.000000e+00 \nSOCS3 0.000000e+00 \nEpo 3.010998e+07 \n\n concentration particle_number rate particle_number_rate \\\nname \nEpoRJAK2 3.976220e+00 9.578143e+14 -0.314737 -7.581552e+13 \nEpoRpJAK2 0.000000e+00 0.000000e+00 0.314737 7.581552e+13 \np1EpoRpJAK2 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \np2EpoRpJAK2 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \np12EpoRpJAK2 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nEpoRJAK2_CIS 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nSHP1 2.672510e+01 6.437693e+15 0.000000 0.000000e+00 \nSHP1Act 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nSTAT5 7.975350e+01 1.921147e+16 0.000000 0.000000e+00 \npSTAT5 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nnpSTAT5 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nCISnRNA1 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nCISnRNA2 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nCISnRNA3 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nCISnRNA4 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nCISnRNA5 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nCISRNA 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nCIS 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nSOCS3nRNA1 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nSOCS3nRNA2 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nSOCS3nRNA3 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nSOCS3nRNA4 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nSOCS3nRNA5 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nSOCS3RNA 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nSOCS3 0.000000e+00 0.000000e+00 0.000000 0.000000e+00 \nEpo 1.249970e-07 3.010998e+07 0.000000 0.000000e+00 \n\n key sbml_id \nname \nEpoRJAK2 Metabolite_0 EpoRJAK2 \nEpoRpJAK2 Metabolite_1 EpoRpJAK2 \np1EpoRpJAK2 Metabolite_2 p1EpoRpJAK2 \np2EpoRpJAK2 Metabolite_3 p2EpoRpJAK2 \np12EpoRpJAK2 Metabolite_4 p12EpoRpJAK2 \nEpoRJAK2_CIS Metabolite_5 EpoRJAK2_CIS \nSHP1 Metabolite_6 SHP1 \nSHP1Act Metabolite_7 SHP1Act \nSTAT5 Metabolite_8 STAT5 \npSTAT5 Metabolite_9 pSTAT5 \nnpSTAT5 Metabolite_10 npSTAT5 \nCISnRNA1 Metabolite_11 CISnRNA1 \nCISnRNA2 Metabolite_12 CISnRNA2 \nCISnRNA3 Metabolite_13 CISnRNA3 \nCISnRNA4 Metabolite_14 CISnRNA4 \nCISnRNA5 Metabolite_15 CISnRNA5 \nCISRNA Metabolite_16 CISRNA \nCIS Metabolite_17 CIS \nSOCS3nRNA1 Metabolite_18 SOCS3nRNA1 \nSOCS3nRNA2 Metabolite_19 SOCS3nRNA2 \nSOCS3nRNA3 Metabolite_20 SOCS3nRNA3 \nSOCS3nRNA4 Metabolite_21 SOCS3nRNA4 \nSOCS3nRNA5 Metabolite_22 SOCS3nRNA5 \nSOCS3RNA Metabolite_23 SOCS3RNA \nSOCS3 Metabolite_24 SOCS3 \nEpo Metabolite_25 Epo ", + "text/html": "
\n | compartment | \ntype | \nunit | \ninitial_concentration | \ninitial_particle_number | \ninitial_expression | \nexpression | \nconcentration | \nparticle_number | \nrate | \nparticle_number_rate | \nkey | \nsbml_id | \n
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name | \n\n | \n | \n | \n | \n | \n | \n | \n | \n | \n | \n | \n | \n |
EpoRJAK2 | \ncyt | \nreactions | \nnmol/l | \n3.976220e+00 | \n9.578143e+14 | \n\n | \n | 3.976220e+00 | \n9.578143e+14 | \n-0.314737 | \n-7.581552e+13 | \nMetabolite_0 | \nEpoRJAK2 | \n
EpoRpJAK2 | \ncyt | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.314737 | \n7.581552e+13 | \nMetabolite_1 | \nEpoRpJAK2 | \n
p1EpoRpJAK2 | \ncyt | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_2 | \np1EpoRpJAK2 | \n
p2EpoRpJAK2 | \ncyt | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_3 | \np2EpoRpJAK2 | \n
p12EpoRpJAK2 | \ncyt | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_4 | \np12EpoRpJAK2 | \n
EpoRJAK2_CIS | \ncyt | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_5 | \nEpoRJAK2_CIS | \n
SHP1 | \ncyt | \nreactions | \nnmol/l | \n2.672510e+01 | \n6.437693e+15 | \n\n | \n | 2.672510e+01 | \n6.437693e+15 | \n0.000000 | \n0.000000e+00 | \nMetabolite_6 | \nSHP1 | \n
SHP1Act | \ncyt | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_7 | \nSHP1Act | \n
STAT5 | \ncyt | \nreactions | \nnmol/l | \n7.975350e+01 | \n1.921147e+16 | \n\n | \n | 7.975350e+01 | \n1.921147e+16 | \n0.000000 | \n0.000000e+00 | \nMetabolite_8 | \nSTAT5 | \n
pSTAT5 | \ncyt | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_9 | \npSTAT5 | \n
npSTAT5 | \nnuc | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_10 | \nnpSTAT5 | \n
CISnRNA1 | \nnuc | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_11 | \nCISnRNA1 | \n
CISnRNA2 | \nnuc | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_12 | \nCISnRNA2 | \n
CISnRNA3 | \nnuc | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_13 | \nCISnRNA3 | \n
CISnRNA4 | \nnuc | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_14 | \nCISnRNA4 | \n
CISnRNA5 | \nnuc | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_15 | \nCISnRNA5 | \n
CISRNA | \ncyt | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_16 | \nCISRNA | \n
CIS | \ncyt | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_17 | \nCIS | \n
SOCS3nRNA1 | \nnuc | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_18 | \nSOCS3nRNA1 | \n
SOCS3nRNA2 | \nnuc | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_19 | \nSOCS3nRNA2 | \n
SOCS3nRNA3 | \nnuc | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_20 | \nSOCS3nRNA3 | \n
SOCS3nRNA4 | \nnuc | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_21 | \nSOCS3nRNA4 | \n
SOCS3nRNA5 | \nnuc | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_22 | \nSOCS3nRNA5 | \n
SOCS3RNA | \ncyt | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_23 | \nSOCS3RNA | \n
SOCS3 | \ncyt | \nreactions | \nnmol/l | \n0.000000e+00 | \n0.000000e+00 | \n\n | \n | 0.000000e+00 | \n0.000000e+00 | \n0.000000 | \n0.000000e+00 | \nMetabolite_24 | \nSOCS3 | \n
Epo | \ncyt | \nreactions | \nnmol/l | \n1.249970e-07 | \n3.010998e+07 | \n\n | \n | 1.249970e-07 | \n3.010998e+07 | \n0.000000 | \n0.000000e+00 | \nMetabolite_25 | \nEpo | \n