Package: biomodels
BioModelsbiomodelsis a Python library to download models fromBioModels.
Models are cached locally in the OS user cache directory,
so they will not be redownloaded every time.UsageGet model metadataThe first time we download a file,
it will let us know that it is being downloaded
and cached locally.>>>importbiomodels>>>metadata=biomodels.get_metadata("BIOMD0000000012")# doctest: +SKIPDownloadingdatafrom'https://www.ebi.ac.uk/biomodels/model/files/BIOMD0000000012?format=json'tofile'.../Caches/biomodels/model/files/BIOMD0000000012'.SHA256hashofdownloadedfile:...Usethisvalueasthe'known_hash'argumentof'pooch.retrieve'toensurethatthefilehasn't changed if it is downloaded again in the future.Later, this file will get fetched from the local cache,
instead of being redownloaded.>>>metadata=biomodels.get_metadata("BIOMD12")# no need to input the leading zeros>>>metadatanamedescriptionsize----------------------------------------------------------------------0BIOMD0000000012_url.xmlmain462741BIOMD0000000012-biopax2.owlAuto-generatedBioPAX(Level2)167482BIOMD0000000012-biopax3.owlAuto-generatedBioPAX(Level3)235773BIOMD0000000012.mAuto-generatedOctavefile49944BIOMD0000000012.pdfAuto-generatedPDFfile2051565BIOMD0000000012.pngAuto-generatedReactiongraph(PNG)390186BIOMD0000000012.sciAuto-generatedScilabfile1547BIOMD0000000012.svgAuto-generatedReactiongraph(SVG)357508BIOMD0000000012.vcmlAuto-generatedVCMLfile601839BIOMD0000000012.xppAuto-generatedXPPfile411410BIOMD0000000012_urn.xmlAuto-generatedSBMLfilewithURNs47097Get a particular fileTo get a particular file,
you can either pass the filename and model_id:>>>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:>>>path=biomodels.get_file(metadata[0])>>>pathPosixPath('<CACHE_DIR>/biomodels/model/download/BIOMD0000000012/BIOMD0000000012_url.xml')Then, you can use thatPathobject to load the file:>>>print(path.read_text())<?xmlversion="1.0"encoding="UTF-8"?><sbmlxmlns="http://www.sbml.org/sbml/level2/version3"metaid="_153818"level="2"version="3">...Get COMBINE archiveIf 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):>>>omex=biomodels.get_omex("BIOMD12")>>>omexlocationformatmaster----------------------------------------------------------------------------------------------------------0https://identifiers.org/combine.specifications/omexFalse1BIOMD0000000012-biopax2.owlhttps://identifiers.org/combine.specifications/biopax.level-2False2BIOMD0000000012-biopax3.owlhttps://identifiers.org/combine.specifications/biopax.level-3False3BIOMD0000000012.mhttps://purl.org/NET/mediatypes/application/x.unknownFalse4BIOMD0000000012.pdfhttps://purl.org/NET/mediatypes/application/pdfFalse5BIOMD0000000012.pnghttps://purl.org/NET/mediatypes/image/pngFalse6BIOMD0000000012.scihttps://purl.org/NET/mediatypes/application/x.unknownFalse7BIOMD0000000012.svghttps://purl.org/NET/mediatypes/application/xmlFalse8BIOMD0000000012.vcmlhttps://purl.org/NET/mediatypes/application/xmlFalse9BIOMD0000000012.xpphttps://purl.org/NET/mediatypes/application/x.unknownFalse10BIOMD0000000012_manual.pnghttps://purl.org/NET/mediatypes/image/pngFalse11BIOMD0000000012_manual.svghttps://purl.org/NET/mediatypes/application/xmlFalse12BIOMD0000000012_url.xmlhttps://identifiers.org/combine.specifications/sbml.level-2.version-3True13BIOMD0000000012_urn.xmlhttps://identifiers.org/combine.specifications/sbml.level-2.version-3False14manifest.xmlhttps://identifiers.org/combine.specifications/omex-manifestFalse15metadata.rdfhttps://identifiers.org/combine.specifications/omex-metadataFalseWe can select a particular file by indexing:>>>content=omex[12]>>>contentContent(location='BIOMD0000000012_url.xml',format='https://identifiers.org/combine.specifications/sbml.level-2.version-3',master=True)Then,
you can get azipfile.Pathobject with theContent.pathattribute,
and read the contents from the OMEX file:>>>print(content.path.read_text())<?xmlversion="1.0"encoding="UTF-8"?><sbmlxmlns="http://www.sbml.org/sbml/level2/version3"metaid="_153818"level="2"version="3">...Installationpip install biomodelsDevelopmentWe 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 installwhich assume you have git and conda preinstalled.