biomodels


Namebiomodels JSON
Version 0.3.2 PyPI version JSON
download
home_page
SummaryDownload from the BioModels API
upload_time2024-02-03 22:36:36
maintainer
docs_urlNone
author
requires_python>=3.9
licenseMIT License Copyright (c) 2023 Mauro Silberberg Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords biomodels omex sbml sed-ml
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # BioModels

`biomodels` is a Python library to download models from [BioModels](https://www.ebi.ac.uk/biomodels/).
Models are cached locally in the OS user cache directory,
so they will not be redownloaded every time.

## Usage

### Get model metadata

The first time we download a file,
it will let us know that it is being downloaded
and cached locally.

```python
>>> import biomodels
>>> metadata = biomodels.get_metadata("BIOMD0000000012")  # doctest: +SKIP
Downloading data from 'https://www.ebi.ac.uk/biomodels/model/files/BIOMD0000000012?format=json' to file '.../Caches/biomodels/model/files/BIOMD0000000012'.
SHA256 hash of downloaded file: ...
Use this value as the 'known_hash' argument of 'pooch.retrieve' to ensure that the file hasn't changed if it is downloaded again in the future.
```

Later, this file will get fetched from the local cache,
instead of being redownloaded.

```python
>>> metadata = biomodels.get_metadata("BIOMD12")  # no need to input the leading zeros
>>> metadata
    name                         description                            size
--  ---------------------------  -----------------------------------  ------
 0  BIOMD0000000012_url.xml      main                                  46274
 1  BIOMD0000000012-biopax2.owl  Auto-generated BioPAX (Level 2)       16748
 2  BIOMD0000000012-biopax3.owl  Auto-generated BioPAX (Level 3)       23577
 3  BIOMD0000000012.m            Auto-generated Octave file             4994
 4  BIOMD0000000012.pdf          Auto-generated PDF file              205156
 5  BIOMD0000000012.png          Auto-generated Reaction graph (PNG)   39018
 6  BIOMD0000000012.sci          Auto-generated Scilab file              154
 7  BIOMD0000000012.svg          Auto-generated Reaction graph (SVG)   35750
 8  BIOMD0000000012.vcml         Auto-generated VCML file              60183
 9  BIOMD0000000012.xpp          Auto-generated XPP file                4114
10  BIOMD0000000012_urn.xml      Auto-generated SBML file with URNs    47097
```

### Get a particular file

To get a particular file,
you can either pass the filename and model_id:

```python
>>> biomodels.get_file("BIOMD0000000012_url.xml", model_id="BIOMD12")
PosixPath('<CACHE_DIR>/biomodels/model/download/BIOMD0000000012/BIOMD0000000012_url.xml')
```

or choose one from the metadata:

```python
>>> path = biomodels.get_file(metadata[0])
>>> path
PosixPath('<CACHE_DIR>/biomodels/model/download/BIOMD0000000012/BIOMD0000000012_url.xml')
```

Then, you can use that `Path` object to load the file:

```python
>>> print(path.read_text())
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level2/version3" metaid="_153818" level="2" version="3">
...
```

### Get COMBINE archive

If you are interested in all the model files,
it might be better to download the COMBINE archive,
which is a compressed file (260KB vs 500KB for this small model):

```python
>>> omex = biomodels.get_omex("BIOMD12")
>>> omex
    location                     format                                                                 master
--  ---------------------------  ---------------------------------------------------------------------  --------
 0                               https://identifiers.org/combine.specifications/omex                    False
 1  BIOMD0000000012-biopax2.owl  https://identifiers.org/combine.specifications/biopax.level-2          False
 2  BIOMD0000000012-biopax3.owl  https://identifiers.org/combine.specifications/biopax.level-3          False
 3  BIOMD0000000012.m            https://purl.org/NET/mediatypes/application/x.unknown                  False
 4  BIOMD0000000012.pdf          https://purl.org/NET/mediatypes/application/pdf                        False
 5  BIOMD0000000012.png          https://purl.org/NET/mediatypes/image/png                              False
 6  BIOMD0000000012.sci          https://purl.org/NET/mediatypes/application/x.unknown                  False
 7  BIOMD0000000012.svg          https://purl.org/NET/mediatypes/application/xml                        False
 8  BIOMD0000000012.vcml         https://purl.org/NET/mediatypes/application/xml                        False
 9  BIOMD0000000012.xpp          https://purl.org/NET/mediatypes/application/x.unknown                  False
10  BIOMD0000000012_manual.png   https://purl.org/NET/mediatypes/image/png                              False
11  BIOMD0000000012_manual.svg   https://purl.org/NET/mediatypes/application/xml                        False
12  BIOMD0000000012_url.xml      https://identifiers.org/combine.specifications/sbml.level-2.version-3  True
13  BIOMD0000000012_urn.xml      https://identifiers.org/combine.specifications/sbml.level-2.version-3  False
14  manifest.xml                 https://identifiers.org/combine.specifications/omex-manifest           False
15  metadata.rdf                 https://identifiers.org/combine.specifications/omex-metadata           False
```

We can select a particular file by indexing:

```python
>>> content = omex[12]
>>> content
Content(location='BIOMD0000000012_url.xml', format='https://identifiers.org/combine.specifications/sbml.level-2.version-3', master=True)
```

Then,
you can get a `zipfile.Path` object with the `Content.path` attribute,
and read the contents from the OMEX file:

```python
>>> print(content.path.read_text())
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level2/version3" metaid="_153818" level="2" version="3">
...
```

## Installation

```
pip install biomodels
```

## Development

We are using pytest for testing,
and pre-commit hooks to format and lint the codebase.

To easily set-up a development environment,
run the following commands:

```
git clone https://github.com/maurosilber/biomodels
cd biomodels
conda env create --file environment-dev.yml
pre-commit install
```

which assume you have git and conda preinstalled.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "biomodels",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "biomodels,OMEX,SBML,SED-ML",
    "author": "",
    "author_email": "Mauro Silberberg <maurosilber@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/73/6b/f8809c816326724ac5cbddff0da65c556bde5946060ff2759414ec471d53/biomodels-0.3.2.tar.gz",
    "platform": null,
    "description": "# BioModels\n\n`biomodels` is a Python library to download models from [BioModels](https://www.ebi.ac.uk/biomodels/).\nModels are cached locally in the OS user cache directory,\nso they will not be redownloaded every time.\n\n## Usage\n\n### Get model metadata\n\nThe first time we download a file,\nit will let us know that it is being downloaded\nand cached locally.\n\n```python\n>>> import biomodels\n>>> metadata = biomodels.get_metadata(\"BIOMD0000000012\")  # doctest: +SKIP\nDownloading data from 'https://www.ebi.ac.uk/biomodels/model/files/BIOMD0000000012?format=json' to file '.../Caches/biomodels/model/files/BIOMD0000000012'.\nSHA256 hash of downloaded file: ...\nUse this value as the 'known_hash' argument of 'pooch.retrieve' to ensure that the file hasn't changed if it is downloaded again in the future.\n```\n\nLater, this file will get fetched from the local cache,\ninstead of being redownloaded.\n\n```python\n>>> metadata = biomodels.get_metadata(\"BIOMD12\")  # no need to input the leading zeros\n>>> metadata\n    name                         description                            size\n--  ---------------------------  -----------------------------------  ------\n 0  BIOMD0000000012_url.xml      main                                  46274\n 1  BIOMD0000000012-biopax2.owl  Auto-generated BioPAX (Level 2)       16748\n 2  BIOMD0000000012-biopax3.owl  Auto-generated BioPAX (Level 3)       23577\n 3  BIOMD0000000012.m            Auto-generated Octave file             4994\n 4  BIOMD0000000012.pdf          Auto-generated PDF file              205156\n 5  BIOMD0000000012.png          Auto-generated Reaction graph (PNG)   39018\n 6  BIOMD0000000012.sci          Auto-generated Scilab file              154\n 7  BIOMD0000000012.svg          Auto-generated Reaction graph (SVG)   35750\n 8  BIOMD0000000012.vcml         Auto-generated VCML file              60183\n 9  BIOMD0000000012.xpp          Auto-generated XPP file                4114\n10  BIOMD0000000012_urn.xml      Auto-generated SBML file with URNs    47097\n```\n\n### Get a particular file\n\nTo get a particular file,\nyou can either pass the filename and model_id:\n\n```python\n>>> biomodels.get_file(\"BIOMD0000000012_url.xml\", model_id=\"BIOMD12\")\nPosixPath('<CACHE_DIR>/biomodels/model/download/BIOMD0000000012/BIOMD0000000012_url.xml')\n```\n\nor choose one from the metadata:\n\n```python\n>>> path = biomodels.get_file(metadata[0])\n>>> path\nPosixPath('<CACHE_DIR>/biomodels/model/download/BIOMD0000000012/BIOMD0000000012_url.xml')\n```\n\nThen, you can use that `Path` object to load the file:\n\n```python\n>>> print(path.read_text())\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" metaid=\"_153818\" level=\"2\" version=\"3\">\n...\n```\n\n### Get COMBINE archive\n\nIf you are interested in all the model files,\nit might be better to download the COMBINE archive,\nwhich is a compressed file (260KB vs 500KB for this small model):\n\n```python\n>>> omex = biomodels.get_omex(\"BIOMD12\")\n>>> omex\n    location                     format                                                                 master\n--  ---------------------------  ---------------------------------------------------------------------  --------\n 0                               https://identifiers.org/combine.specifications/omex                    False\n 1  BIOMD0000000012-biopax2.owl  https://identifiers.org/combine.specifications/biopax.level-2          False\n 2  BIOMD0000000012-biopax3.owl  https://identifiers.org/combine.specifications/biopax.level-3          False\n 3  BIOMD0000000012.m            https://purl.org/NET/mediatypes/application/x.unknown                  False\n 4  BIOMD0000000012.pdf          https://purl.org/NET/mediatypes/application/pdf                        False\n 5  BIOMD0000000012.png          https://purl.org/NET/mediatypes/image/png                              False\n 6  BIOMD0000000012.sci          https://purl.org/NET/mediatypes/application/x.unknown                  False\n 7  BIOMD0000000012.svg          https://purl.org/NET/mediatypes/application/xml                        False\n 8  BIOMD0000000012.vcml         https://purl.org/NET/mediatypes/application/xml                        False\n 9  BIOMD0000000012.xpp          https://purl.org/NET/mediatypes/application/x.unknown                  False\n10  BIOMD0000000012_manual.png   https://purl.org/NET/mediatypes/image/png                              False\n11  BIOMD0000000012_manual.svg   https://purl.org/NET/mediatypes/application/xml                        False\n12  BIOMD0000000012_url.xml      https://identifiers.org/combine.specifications/sbml.level-2.version-3  True\n13  BIOMD0000000012_urn.xml      https://identifiers.org/combine.specifications/sbml.level-2.version-3  False\n14  manifest.xml                 https://identifiers.org/combine.specifications/omex-manifest           False\n15  metadata.rdf                 https://identifiers.org/combine.specifications/omex-metadata           False\n```\n\nWe can select a particular file by indexing:\n\n```python\n>>> content = omex[12]\n>>> content\nContent(location='BIOMD0000000012_url.xml', format='https://identifiers.org/combine.specifications/sbml.level-2.version-3', master=True)\n```\n\nThen,\nyou can get a `zipfile.Path` object with the `Content.path` attribute,\nand read the contents from the OMEX file:\n\n```python\n>>> print(content.path.read_text())\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" metaid=\"_153818\" level=\"2\" version=\"3\">\n...\n```\n\n## Installation\n\n```\npip install biomodels\n```\n\n## Development\n\nWe are using pytest for testing,\nand pre-commit hooks to format and lint the codebase.\n\nTo easily set-up a development environment,\nrun the following commands:\n\n```\ngit clone https://github.com/maurosilber/biomodels\ncd biomodels\nconda env create --file environment-dev.yml\npre-commit install\n```\n\nwhich assume you have git and conda preinstalled.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Mauro Silberberg  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Download from the BioModels API",
    "version": "0.3.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/maurosilber/biomodels/issues",
        "Homepage": "https://github.com/maurosilber/biomodels"
    },
    "split_keywords": [
        "biomodels",
        "omex",
        "sbml",
        "sed-ml"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "24a41465d88ac1058e598fef80e3afcf77ef5e2dc4dc194716bb8b68aa6f8f9a",
                "md5": "83b7c2120129a92ffa830e1db4818c35",
                "sha256": "e0a3baa0a7b93c3c14ab3a4508f56be2a3746bd33b8cef6a780e094eb17f30cf"
            },
            "downloads": -1,
            "filename": "biomodels-0.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "83b7c2120129a92ffa830e1db4818c35",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 9145,
            "upload_time": "2024-02-03T22:36:35",
            "upload_time_iso_8601": "2024-02-03T22:36:35.526380Z",
            "url": "https://files.pythonhosted.org/packages/24/a4/1465d88ac1058e598fef80e3afcf77ef5e2dc4dc194716bb8b68aa6f8f9a/biomodels-0.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "736bf8809c816326724ac5cbddff0da65c556bde5946060ff2759414ec471d53",
                "md5": "5aacbcec089366d0789ae400fe9e8cd8",
                "sha256": "5dfbf021c16781159c0d1f1faf7da02115173151d35b0ef6685662f17520af3c"
            },
            "downloads": -1,
            "filename": "biomodels-0.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "5aacbcec089366d0789ae400fe9e8cd8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 11564,
            "upload_time": "2024-02-03T22:36:36",
            "upload_time_iso_8601": "2024-02-03T22:36:36.710292Z",
            "url": "https://files.pythonhosted.org/packages/73/6b/f8809c816326724ac5cbddff0da65c556bde5946060ff2759414ec471d53/biomodels-0.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-03 22:36:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "maurosilber",
    "github_project": "biomodels",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "biomodels"
}
        
Elapsed time: 3.25548s