booldog.io.biomodels
API to download and use SBML-qual models from the BioModels database (https://www.biomodels.org/) directly.
Attributes
MAMO accessions for models that are compatible with BoolDog. |
|
BioModels model identifier for an example SBML-qual model (Chaouiya2013 |
Functions
|
Fetch SBML from BioModels by model id |
|
Fetch model info/metadata from BioModels by model id. |
|
Downloads a file from a model in BioModels, via |
Module Contents
- booldog.io.biomodels.logger
- booldog.io.biomodels.BIOMODELS_BASE_URL = 'https://www.biomodels.org/'
- booldog.io.biomodels.MAMO_ACCESSIONS = ['MAMO_0000030', 'MAMO_0000053']
MAMO accessions for models that are compatible with BoolDog.
The list contains the following accessions: * MAMO_0000030: logical model (http://identifiers.org/mamo/MAMO_0000030) * MAMO_0000053: Boolean model (http://identifiers.org/mamo/MAMO_0000053)
- Type:
list
- booldog.io.biomodels.EXAMPLE_MODEL_ID = 'BIOMD0000000562'
BioModels model identifier for an example SBML-qual model (Chaouiya2013 - EGF and TNFalpha mediated signalling pathway). See https://www.ebi.ac.uk/biomodels/BIOMD0000000562 for more details.
- Type:
str
- booldog.io.biomodels.fetch_model(model_id, sbml_file=None, local_file=None, check_modelling_approach=False)
Fetch SBML from BioModels by model id
- Parameters:
model_id (str) – BioModels model identifier (e.g. ‘BIOMD0000000562’)
sbml_file (str) – Currently unused: this argument’s value is discarded and always overwritten by the name found in the model’s metadata (via
model_info['files']['main'], the first entry whose description starts with “sbml”/”SBML”) before use.local_file (str or path-like) – Name of path to save the downloaded model to. Optional, if not given will save the model to the a file in the cwd with the name as on the remote server.
check_modelling_approach (Bool) – Whether to check modelling annotation “modellingApproach” falls into Boolean or logical modelling.
- Returns:
local_file – Name of the local file containing the download.
- Return type:
str
- Raises:
ValueError – If
check_modelling_approachis True and the model’s “modellingApproach” annotation is not inMAMO_ACCESSIONS; if the model’s format (per its metadata) is not SBML; if no file in the model’s metadata has a description starting with “SBML”/”sbml”; or if the download request fails (see_download()).
Notes
This first collects the model info/metadata, and uses the ‘files’ –> ‘main’ attribute to find a file whose description starts with ‘SBML’/’sbml’ (case-insensitive). If more than one file matches, the last matching entry in the list is used (the loop does not stop at the first match).
Will always overwrite an existing file.
- booldog.io.biomodels.fetch_model_info(model_id)
Fetch model info/metadata from BioModels by model id.
- Parameters:
model_id (str) – BioModels model identifier (e.g. ‘BIOMD0000000562’)
- Returns:
Model info/metadata as a dictionary, parsed directly from the JSON response of BioModels’
GET /{model_id}?format=jsonendpoint.- Return type:
dict
- booldog.io.biomodels._download(model_id, filename=None, local_file=None)
Downloads a file from a model in BioModels, via
GET /model/download/{model_id}.- Parameters:
model_id (str) – BioModels model identifier (e.g. ‘BIOMD0000000562’)
filename (str, optional) – Name of a specific file within the model’s archive to download (passed as the
filenamequery parameter). If None, the whole model archive is downloaded instead.local_file (str or path-like, optional) – Path to save the downloaded content to. If None, defaults to
filename(if given) or"{model_id}.omex"(if not), saved relative to the current working directory.
- Returns:
local_file – Name/path of the local file containing the download.
- Return type:
str or Path
- Raises:
ValueError – If the HTTP response indicates failure (non-OK status code).