Skip to content

Commit

Permalink
updated for source info
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Mar 15, 2024
1 parent 35a5232 commit 5f303c6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 99 deletions.
15 changes: 9 additions & 6 deletions biosimulator_processes/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


from typing import Dict, List, Union, Tuple, Optional, Any
import requests
from types import NoneType
from dataclasses import dataclass, asdict
from abc import ABC, abstractmethod
Expand Down Expand Up @@ -198,10 +199,10 @@ def get_model_source_info(self, source: str, validator, **kwargs):
"""Currently only support BioModel id."""
return validator(source, **kwargs)

def get_biomodel_model_source_info(self, biomodel_id: Union[BiomodelID, str]) -> Dict:
source_id = biomodel_id.value if isinstance(biomodel_id, biolab.BiomodelID) else biomodel_id
def get_biomodel_model_source_info(self, biomodel_id: str) -> Dict:
"""Return information about the BioModel ID passed."""
return requests.get(
url=f'https://www.ebi.ac.uk/biomodels/{source_idß}',
url=f'https://www.ebi.ac.uk/biomodels/{biomodel_id}',
headers={'accept': 'application/json'}).json()

def set_model_source_info(self, **kwargs):
Expand All @@ -226,7 +227,11 @@ def __init__(self,
# TODO: extract functionality for algorithms related to UTC sims
self.model_id = self.set_id(model_id)
self.model_name = self.set_name(model_name)
self.set_source()
source_id = self.model_source.value \
if isinstance(self.model_source, BiomodelID) or isinstance(self.model_source, ModelFilepath) \
else self.model_source
if 'BIOMD' in source_id:
self.source_info = self.get_biomodel_model_source_info(source_id)


class SteadyStateModel(SedModel):
Expand All @@ -241,7 +246,6 @@ def __init__(self,
super().__init__(model_source, model_id, model_name, model_language, model_changes, model_units)
self.model_id = self.set_id(model_id)
self.model_name = self.set_name(model_name)
self.set_source()


class SpatialModel(SedModel):
Expand All @@ -256,7 +260,6 @@ def __init__(self,
super().__init__(model_source, model_id, model_name, model_language, model_changes, model_units)
self.model_id = self.set_id(model_id)
self.model_name = self.set_name(model_name)
self.set_source()


@dataclass
Expand Down
Binary file not shown.
100 changes: 7 additions & 93 deletions notebooks/biobuilder_api_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,67 +12,12 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "initial_id",
"metadata": {
"ExecuteTime": {
"end_time": "2024-03-15T18:43:01.424516Z",
"start_time": "2024-03-15T18:43:00.646819Z"
},
"collapsed": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n"
]
},
{
"data": {
"text/plain": [
"{'name': 'Reppas2015 - tumor control via alternating immunostimulating and immunosuppressive phases',\n",
" 'description': 'The paper describes a model of tumor control via alternating immunostimulating and immunosuppressive phases. \\r\\nCreated by COPASI 4.25 (Build 207) \\r\\n\\r\\nThis model is described in the article: \\r\\nIn silico tumor control induced via alternating immunostimulating and immunosuppressive phases\\r\\nAI Reppas, JCL Alfonso, and H Hatzikirou\\r\\nVirulence 7:2, 174--186\\r\\n\\r\\nAbstract: \\r\\nDespite recent advances in the field of Oncoimmunology, the success potential of immunomodulatory therapies against cancer remains to be elucidated. One of the reasons is the lack of understanding on the complex interplay between tumor growth dynamics and the associated immune system responses. Toward this goal, we consider a mathematical model of vascularized tumor growth and the corresponding effector cell recruitment dynamics. Bifurcation analysis allows for the exploration of model’s dynamic behavior and the determination of these parameter regimes that result in immune-mediated tumor control. In this work, we focus on a particular tumor evasion regime that involves tumor and effector cell concentration oscillations of slowly increasing and decreasing amplitude, respectively. Considering a temporal multiscale analysis, we derive an analytically tractable mapping of model solutions onto a weakly negatively damped harmonic oscillator. Based on our analysis, we propose a theory-driven intervention strategy involving immunostimulating and immunosuppressive phases to induce long-term tumor control.\\r\\n\\r\\nTo cite BioModels Database, please use: BioModels Database: An enhanced, curated and annotated resource for published quantitative kinetic models . \\r\\nTo the extent possible under law, all copyright and related or neighbouring rights to this encoded model have been dedicated to the public domain worldwide. \\r\\nPlease refer to CC0 Public Domain Dedication for more information.',\n",
" 'format': {'name': 'SBML', 'version': 'L3V1'},\n",
" 'publication': {'journal': 'Virulence',\n",
" 'title': 'In silico tumor control induced via alternating immunostimulating and immunosuppressive phases.',\n",
" 'affiliation': 'a Center for Advancing Electronics; Technische Universität Dresden ; Dresden , Germany.',\n",
" 'synopsis': \"Despite recent advances in the field of Oncoimmunology, the success potential of immunomodulatory therapies against cancer remains to be elucidated. One of the reasons is the lack of understanding on the complex interplay between tumor growth dynamics and the associated immune system responses. Toward this goal, we consider a mathematical model of vascularized tumor growth and the corresponding effector cell recruitment dynamics. Bifurcation analysis allows for the exploration of model's dynamic behavior and the determination of these parameter regimes that result in immune-mediated tumor control. In this work, we focus on a particular tumor evasion regime that involves tumor and effector cell concentration oscillations of slowly increasing and decreasing amplitude, respectively. Considering a temporal multiscale analysis, we derive an analytically tractable mapping of model solutions onto a weakly negatively damped harmonic oscillator. Based on our analysis, we propose a theory-driven intervention strategy involving immunostimulating and immunosuppressive phases to induce long-term tumor control.\",\n",
" 'year': 2016,\n",
" 'month': '1',\n",
" 'volume': '7',\n",
" 'issue': '2',\n",
" 'pages': '174-186',\n",
" 'link': 'http://identifiers.org/pubmed/26305801',\n",
" 'authors': [{'name': 'Reppas AI'},\n",
" {'name': 'Alfonso JC'},\n",
" {'name': 'Hatzikirou H', 'orcid': '0000-0002-1270-7885'}]},\n",
" 'files': {'main': [{'name': 'Reppas2015.xml', 'fileSize': '62675'}],\n",
" 'additional': [{'name': 'Reppas2015.sedml',\n",
" 'fileSize': '2191',\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",
" 'comment': 'Edited model metadata online.'},\n",
" {'version': 3,\n",
" 'submitted': 1562858822000,\n",
" 'submitter': 'Jinghao Men',\n",
" 'comment': 'Automatically added model identifier BIOMD0000000749'}]},\n",
" 'firstPublished': 1562858819000,\n",
" 'submissionId': 'MODEL1907110002',\n",
" 'publicationId': 'BIOMD0000000749'}"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"import sys\n",
"\n",
Expand Down Expand Up @@ -100,27 +45,12 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "e3218a2629726818",
"metadata": {
"ExecuteTime": {
"end_time": "2024-03-15T18:43:05.302270Z",
"start_time": "2024-03-15T18:43:03.402327Z"
},
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CobraProcess registered successfully.\n",
"CopasiProcess registered successfully.\n",
"SmoldynProcess registered successfully.\n",
"TelluriumProcess registered successfully.\n"
]
}
],
"outputs": [],
"source": [
"from process_bigraph import pp\n",
"from biosimulator_processes.biosimulator_builder import BuildPrompter\n",
Expand All @@ -129,32 +59,16 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "871b58285775fb24",
"metadata": {
"ExecuteTime": {
"end_time": "2024-03-15T18:43:51.744011Z",
"start_time": "2024-03-15T18:43:51.655633Z"
},
"collapsed": false
},
"outputs": [
{
"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'"
]
}
],
"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",
"simple_tc_model = sed.TimeCourseModel(model_source=sed.BiomodelID(value=tumor_control_biomodel_id))\n",
"simple_tc_model = sed.TimeCourseModel(model_source=tumor_control_biomodel_id)\n",
"\n",
"pp(simple_tc_model)"
]
Expand Down

0 comments on commit 5f303c6

Please sign in to comment.