Skip to content

Commit

Permalink
updated data model root enum
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Mar 15, 2024
1 parent f4f0f6a commit 35a5232
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 102 deletions.
1 change: 1 addition & 0 deletions biosimulator_processes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from builder import ProcessTypes
import importlib
from biosimulator_processes.data_model import SedDataModel


# Define a list of processes to attempt to import and register
Expand Down
2 changes: 2 additions & 0 deletions biosimulator_processes/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ class SedDataModel:
ReactionParameter = ReactionParameter
ReactionChange = ReactionChange
ModelUnits = ModelUnits
ModelFilepath = ModelFilepath
BiomodelID = BiomodelID


# --- Non-Pydantic FromDict classes
Expand Down
135 changes: 33 additions & 102 deletions notebooks/biobuilder_api_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"id": "initial_id",
"metadata": {
"ExecuteTime": {
"end_time": "2024-03-15T18:23:17.150069Z",
"start_time": "2024-03-15T18:23:16.597581Z"
"end_time": "2024-03-15T18:43:01.424516Z",
"start_time": "2024-03-15T18:43:00.646819Z"
},
"collapsed": true
},
Expand Down Expand Up @@ -49,12 +49,12 @@
" {'name': 'Alfonso JC'},\n",
" {'name': 'Hatzikirou H', 'orcid': '0000-0002-1270-7885'}]},\n",
" 'files': {'main': [{'name': 'Reppas2015.xml', 'fileSize': '62675'}],\n",
" 'additional': [{'name': 'Reppas2015.cps',\n",
" 'fileSize': '81326',\n",
" 'description': 'CPS file of the model in COPASI'},\n",
" {'name': 'Reppas2015.sedml',\n",
" 'additional': [{'name': 'Reppas2015.sedml',\n",
" 'fileSize': '2191',\n",
" 'description': 'Auto-generated SEDML file'}]},\n",
" 'description': 'Auto-generated SEDML file'},\n",
" {'name': 'Reppas2015.cps',\n",
" 'fileSize': '81326',\n",
" 'description': 'CPS file of the model in COPASI'}]},\n",
" 'history': {'revisions': [{'version': 2,\n",
" 'submitted': 1562858737000,\n",
" 'submitter': 'Jinghao Men',\n",
Expand Down Expand Up @@ -101,55 +101,11 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "1511e9dc3b8c6ab9",
"metadata": {
"ExecuteTime": {
"end_time": "2024-03-15T18:23:17.465844Z",
"start_time": "2024-03-15T18:23:17.344343Z"
},
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"biobuilder_api_demo.ipynb parameter_scan.ipynb\r\n",
"cobra_process_composer.ipynb playground.ipynb\r\n",
"copasi_process_composer.ipynb smoldyn_process_composer.ipynb\r\n",
"data_model_demo.ipynb tellurium_process_composer.ipynb\r\n",
"\u001b[34mout\u001b[m\u001b[m\r\n"
]
}
],
"source": [
"!ls"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "e68fa1f2f2e08512",
"metadata": {
"ExecuteTime": {
"end_time": "2024-03-15T18:23:18.068343Z",
"start_time": "2024-03-15T18:23:18.066049Z"
},
"collapsed": false
},
"outputs": [],
"source": [
"sys.path.insert(0, '../biolab')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "f6a546ba276abc26",
"id": "e3218a2629726818",
"metadata": {
"ExecuteTime": {
"end_time": "2024-03-15T18:23:20.648738Z",
"start_time": "2024-03-15T18:23:18.674280Z"
"end_time": "2024-03-15T18:43:05.302270Z",
"start_time": "2024-03-15T18:43:03.402327Z"
},
"collapsed": false
},
Expand All @@ -166,66 +122,41 @@
}
],
"source": [
"from biosimulator_processes.data_model import SedDataModel as dm\n",
"\n",
"tc_model = dm.TimeCourseModel(model_source=caravagna_model_filepath)"
"from process_bigraph import pp\n",
"from biosimulator_processes.biosimulator_builder import BuildPrompter\n",
"from biosimulator_processes import SedDataModel as sed "
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "60076f3628327fd2",
"execution_count": 4,
"id": "871b58285775fb24",
"metadata": {
"ExecuteTime": {
"end_time": "2024-03-15T18:23:32.903109Z",
"start_time": "2024-03-15T18:23:32.899425Z"
"end_time": "2024-03-15T18:43:51.744011Z",
"start_time": "2024-03-15T18:43:51.655633Z"
},
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"ModelFilepath(value='../biosimulator_processes/model_files/Caravagna2010.xml')"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
"ename": "AttributeError",
"evalue": "type object 'SedDataModel' has no attribute 'BiomodelID'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[4], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# 1a. define a model for the process composition. In this case, just one model to be re-used as configuration for the processes we create:\u001b[39;00m\n\u001b[0;32m----> 3\u001b[0m simple_tc_model \u001b[38;5;241m=\u001b[39m sed\u001b[38;5;241m.\u001b[39mTimeCourseModel(model_source\u001b[38;5;241m=\u001b[39m\u001b[43msed\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mBiomodelID\u001b[49m(value\u001b[38;5;241m=\u001b[39mtumor_control_biomodel_id))\n\u001b[1;32m 5\u001b[0m pp(simple_tc_model)\n",
"\u001b[0;31mAttributeError\u001b[0m: type object 'SedDataModel' has no attribute 'BiomodelID'"
]
}
],
"source": [
"tc_model.model_source"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e3218a2629726818",
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from process_bigraph import pp\n",
"from biosimulator_processes.biosimulator_builder import BuildPrompter\n",
"from biosimulator_processes.data_model import TimeCourseProcess, TimeCourseModel"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "871b58285775fb24",
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# 1a. define a model for the process composition. In this case, just one model to be re-used as configuration for the processes we create:\n",
"\n",
"tc_model = TimeCourseModel(model_source=tumor_control_biomodel_id)\n",
"simple_tc_model = sed.TimeCourseModel(model_source=sed.BiomodelID(value=tumor_control_biomodel_id))\n",
"\n",
"pp(tc_model)"
"pp(simple_tc_model)"
]
},
{
Expand All @@ -239,7 +170,7 @@
"source": [
"# 1b. define a TimeCourse process instance using the above object as a parameter. The other parameter is method. See BasiCO documentation for more details on solvers\n",
"\n",
"tc_process = TimeCourseProcess(model=tc_model, method='tauleap')"
"simple_tc_process = sed.TimeCourseProcess(model=simple_tc_model, method='tauleap')"
]
},
{
Expand All @@ -253,7 +184,7 @@
"source": [
"# >> The process model instance is viewable as a dataclass...\n",
"\n",
"pp(tc_process)"
"pp(simple_tc_process)"
]
},
{
Expand All @@ -267,7 +198,7 @@
"source": [
"# >> ...or a dict:\n",
"\n",
"pp(tc_process.to_dict())"
"pp(simple_tc_process.to_dict())"
]
},
{
Expand Down Expand Up @@ -295,7 +226,7 @@
"source": [
"# 3. add process(es) to the bigraph with the Time Course model instance we created above. For now, just one process will be added.\n",
"\n",
"prompter.add_single_process(config=tc_process)"
"prompter.add_single_process(config=simple_tc_process)"
]
},
{
Expand Down Expand Up @@ -351,7 +282,7 @@
"source": [
"# 6. Save the composite to a document:\n",
"\n",
"prompter.builder_instance.write(filename='demo_tumor_control_composite')"
"prompter.builder_instance.write(filename='demo_tumor_control_composite_2')"
]
},
{
Expand Down

0 comments on commit 35a5232

Please sign in to comment.