Skip to content

biomodels

Utilities for downloading biomodel models.

The downloads go through the shared session of pymetadata, which retries the transient error responses (429, 500, 502, 503, 504) with an exponential backoff and times out after 30 seconds, so a single hiccup of the BioModels service does not fail a download.

download_file

download_file(url, path)

Download a file.

A transient error response is retried, see the module documentation.

Parameters:

Name Type Description Default
url str

url to download from

required
path Path

file the content is written to

required

Returns:

Type Description
Path

The path the content was written to.

Raises:

Type Description
HTTPError

if the server answered with an error status

RequestException

if the server could not be reached

download_biomodel_omex

download_biomodel_omex(biomodel_id, omex_path)

Download omex for biomodel id.

This downloads the latest version of the OMEX from biomodels via the rest service.

:returns: path to omex Raises :class:HTTPError, if one occurred, i.e. if the model does not exist.

download_biomodel_sbml

download_biomodel_sbml(
    biomodel_id, output_dir, output_format="sbml"
)

Download SBML file for biomodel.

Retrieves the archive from biomodels and gets the SBML files from it. Stores the raw SBML files for output_format='sbml' or creates an OMEX archive in case of output_format='omex'.

:param output_format: 'sbml' or 'omex'

:return: list of location strings Raises :class:HTTPError, if one occurred, i.e. if the model does not exist. Raises :class:ValueError, if invalid format string is provided.

query_curated_biomodels

query_curated_biomodels()

Query the identifiers of the curated biomodels.

A transient error response is retried, see the module documentation.

Returns:

Type Description
list[str]

The sorted identifiers of the manually curated models.

Raises:

Type Description
HTTPError

if the server answered with an error status

RequestException

if the server could not be reached